More Helpful Commands in Linux

A backdrop of stars

Difficulty: Easy

Application: KStars

You may already have played with KStars, but how about creating a KStars backdrop image that’s updated every time you start up?

KStars can be run with the –dump switch, which dumps out an image from your startup settings, but doesn’t load the GUI at all. You can create a script to run this and generate a desktop image, which will change every day (or you can just use this method to generate images).

Run KStars like this:

kstars --dump --width 1024 --height 768 --filename = ~/kstarsback.png

You can add this to a script in your ~/.kde/Autostart folder to be run at startup. Find the file in Konqueror, drag it to the desktop and select ‘Set as wallpaper’ to use it as a randomly generated backdrop.

Open an SVG directly

Difficulty: Easy

Application: Inkscape

You can run Inkscape from a shell and immediately edit a graphic directly from a URL. Just type:

Editing without an editor

Difficulty: Intermediate

Application: Various

Very long files are often hard to manipulate with a text editor. If you need to do it regularly, chances are you’ll find it much faster to use some handy command-line tools instead, like in the following examples.

To print columns eg 1 and 3 from a file file1 into file2, we can use awk:

awk '{print $1, $3}' file1 > file2

To output only characters from column 8 to column 15 of file1, we can use cut:

cut -c 8-15 file1 > file2

To replace the word word1 with the word word2 in the file file1, we can use the sed command:

sed "s/word1/word2/g" file1 > file2

This is often a quicker way to get results than even opening a text editor.

Backup selected files only

Difficulty: Intermediate

Application: tar

Want to use tar to backup only certain files in a directory? Then you’ll want to use the -T flag as follows. First, create a file with the file you want to backup: