Command line snippet of the week: 3

Wouldn’t it be nice to check if a program is running? You can do that and make it start conditionally if it isn’t running. Very handy for service daemons that always need to be running. Can be used with cron as well:

ps -C servicedaemon || { servicedaemon & }

Replace servicedaemon with your own process that needs to be checked. The second servicedaemon value describes what program it needs to start if it’s not running.

divider

Command line snippet of the week: 2

The snippet this week will be about copying arguments without retyping everything. It would be easier to show you how this works:

$ cd /home/user/flx
cd: /home/user/flx: No such file or directory
$ mkdir !*
mkdir /home/user/flx

By using !* it repeats all arguments previously used. If you only want to use the second argument for example, you use !:2.

divider

Command line snippet of the week: 1

New year, new snippets! Belated good wishes from me as well :-)

Anyway, this week’s snippet is on basic steganography. In this case we would like to hide a rar file in a image, we can do that by doing the following:

cat picture.png archive.rar > hidden_archive_in_pic.png

This will create a valid png image for viewing with a secret rar file inside!
When you want to retrieve the hidden files, download the image, rename to .rar and extract.

divider