Wanted: your Linux tips


Have you found a crafty command-line trick that makes your daily admin chores much easier? Perhaps you've discovered a shortcut in your desktop environment of choice that saves you heaps of time. Or you've come across an amazingly useful program on Freshmeat that you can no longer live without. Well, we're gathering together the best compilation of Linux tips in existence, and we'd love your input. From tiny CLI tweaks to major workflow changers, whatever you've found that makes your life easier, we want to know. Share your knowledge with the world and post your tips in the comments - thanks!

You should follow us on Identi.ca or Twitter

Your comments

SSH with RSA keys!

Passwordless SSH using RSA keys.

Kept on a usb drive (Backed up at home), so my server is safe and secure!

Makes life a fair bit easier when you only have to remember the password for root.


Clears the terminal screen (in Konsole, at least)

screen, SSH craskers

screen rules, and:

Get the IP of anyone who's tried to crack your ssh with this hefty trick:

cat /var/log/messages.3 | grep ssh | cut -d " " -f 13-13 | sort | uniq

Works on RHEL/CentOS, you may have to change the -f number.


If you are in a terminal and you type a command with the last two letters the wrong way around, e.g. "supertxu" then all you have to do is press <up> to go back to the command and press CTRL + T and it will swap the last two letters.

Only tested on konsole, though.

Here are the commands or

Here are the commands or programs I've used time and time again, they're so useful, that I didn't know about before.


Cons: You have to remember keyboard shortcuts
Doesn't work with gpm (so people wanting to use links in a tty with a mouse are out of luck)
Pros: A window manager of sorts for the console
Really good and useful

List files in an installed package (debian-based)

dpkg -L packagename

Qt Creator

What happens when you combine MSVC++ with Qt, make it open source, and remove all the crap bits? This.

Sed, grep and cut

The most versatile command line tools (IMO) that still remain easy and fast to learn and use (ish). You can parse the output of almost anything with these.

For example: List all process names beginning with g (in other words, gnome/GTK apps, with a few extra ones. This helps debugging why my desktop suddenly went all gnome-ish):

ps -A | sed s/\ \ */\ /g | cut -d " " -f 5 | grep ^g


ps -A: list all processes

sed s/\ \ */\ /g: in every line, and across the whole line, replace one space followed by 0 or more spaces with just one space. In other words, remove the columns that are useful for human viewing and make it suitable for parsing with cut.

cut -d " " -f 5: Take the input to be a "table", with the columns separated by spaces (the -d " ") part, and get the fifth field (many people may think it's the fourth you need, but there is a space at the beginning of each line, so it is actually the fifth)

grep ^g: Only show lines beginning with g

Optimise your distro for your model of computer (if not built yourself)

Many distros have options you can enable, whether this will decrease power usage (useful on netbooks) by not keeping the fan on all the time and slowing down the CPU when not needed, or make the graphics card perform best. Google the name of your computer along with Linux (most tips are distro-agnostic so you shouldn't include your distro name in the search or you might miss out). The same search may also fix all those annoying niggles you thought would not get fixed, such as your WiFi LED not working, or the microphone not working occasionally.

Set up your network the real way

Rather than using one of these crappy network managers, set up your network using iwconfig, ifconfig and dhclient, if you use a desktop with one network, in the boot scripts. This will make networking work on ttys when you are not logged into a GUI (always useful in an emergency), and you may also catch a glimpse at the astonishing number of network options available whilst you're there.


Useful to copy stuff to/from the clipboard on the command line. Usage is mostly self-explanatory, but make sure you add -selection clipboard to the command line to make it use the more modern Ctrl + C, Ctrl + X, Ctrl + V clipboard rather than the mostly unused select, middle mouse clipboard.


Never use this if you use bash-specific features. Use #!/bin/bash instead. That is all.


Have a router? Chances are it runs Linux. telnet into it (telnet 192.168.x.1) and have a look. Log in with your router's normal user and password. You may have to run sh once it starts, otherwise you will be left with a watered-down, rubbish shell. It's just a bit of fun really, there isn't much you can do that you can't do on the setup page usually, since the filesystem is usually readonly.


There is lots of other stuff, but I can't remember it at this time. I might post again later.

And TomMan, you stole my

And TomMan, you stole my one! *shakes fist*

(We are friends in RealLife(tm))

downforeveryoneorjustme.com N


Not Linux-specific, but really useful.

TomMan: why press up? Just

TomMan: why press up? Just do Ctrl+T... Just tested it in Tilda, which uses the Gnome terminal I believe... Really useful trick, thanks. :)

My "trick": something pretty standard, actually. Some commandline apps simply won't accept a * as "all files in a directory", so instead I do this to process them:
for f in *; do command "$f"; done

Very useful for using zip or rar to pack all files or dirs individually. :) Could also be used in combination with Wine to run Windows commandline tools in a similar fashion.

DaVince: Unfortunately, that

DaVince: Unfortunately, that one doesn't work with paths with spaces in them. To get them to work, you would need to replace spaces with another unused symbol (using sed), and then when you do the command, replace them back (again using sed). It works but it's a bit of an ugly hack.

Control other computers from one mouse and keyboard

I've found two commands (thanks to a colleague) that allow me to use another computer (*nix or windows) directly from my desktop.

I use x2vnc from my desktop to control Windows Vista on my laptop (Only used for IE8 testing!). Run tightvnc server on Vista and then run:


enter the password and voila! Moving the mouse off the left of the Ubuntu desktop and it appears on the vista laptop.

To do the same with another Linux based computer you need to install x2x on the remote computer and then on the local one enter:

ssh -X user@remote.ip "x2x -north -to :0" &

The -north means that the display is above the local one.

man x2vnc
man x2x

Rename Multiple Files

I wanted to rename my mp3 collection of files but didn't want to suffer the tedium of going through the directories and changing each file individually.

I hunted high and low for a solution but couldn't find anything that was simple, flexible, and careful.

So I came up with my own solution:

Step 1: Get all of the files into a text file - with full file names and paths
tree -fi /my/music/directory/*|grep "\.mp3" > my_music_file.txt

Step 2: Iterate through the text file changing each as follows:

for i in `cat my_music_file.txt`; do `rename -v -n 's/(\d\d)( )(Yellow)( )(Submarine).mp3/$1.$3.$5.mp3/g' $i`;done


The above is just an example of how to take a file name structure, convert it to regex [Regular Expression] and then work upon the result from $i (the line from the text file).

Note the use of the -n parameter: this ensures that no change is made until you are happy with the result. At that stage, remove -n from the rename command, and the filename is changed.

Note too that the marks preceding cat and following txt, and preceding rename and following $i are tick marks [the punctuation mark on the key to the left of the numeral 1 key on the keyboard]. The others are single quote marks.

Hope this helps someone!

As a total noob, learning

As a total noob, learning about tab complete was a revelation.

For example, the following would say file not found, /home/tad/doc/linux folder/intro.odt. I would go there with the GUI and find it. Even when I copied the location form the address bar I got the file not found message.

Then I was told about Tab complete, which finishes what it thinks you want to type. This gave the line as /home/tad/doc/linux\ folder/intro.odt. For some reason the back slash is hidden, grrr, stupid linux. Anyway I never seen that mentioned in any easy ways to learn the command line tutorials.

re: As a total noob, learning

Tad: The backslash is there to escape the space character, so the string is read as a whole, instead of two separate ones.


Little program that 'remembers' ffmpeg command lines for video conversion. Srag and Drop interface is cool.


Podcast catcher/manager. Surely the best program of this genre anywhere, for any OS, and its Linux!

SSH with RSA keys ?

What about an article on SSH remote login

and for those who are using public wifi hotspot - ssh tunneling back to your home router and out to the internet for security!


Fed up of accidentally typing apt-get on Fedora and yum on Ubuntu, I set up bash_aliases for common commands. 'sudo apt-get install' is now simply 'install'. By setting up a similar yum alias, I can now install packages with the same command on different distros.

In case of emergency

My best Linux discovery of the last year is the "magic SysRq" functions, which have the added bonus of making use of the mysterious SysRq key! If your system stops responding to the keyboard & mouse (like when you've done one tweak too many to X.org), press

left Alt + SysRq + R

to put the keyboard in "raw" mode, which is often enough to let you do ctrl+alt+F1 and get to a terminal* where you can sort out what's wrong.

Failing that, doing the following in order gives you a clean reboot that minimises data loss:

Alt+SysRq+E - send TERM signal to all processes (ie, close all programs)
Alt+SysRq+I - send KILL signal to all processes (in case they didn't get the hint :o) )
Alt+SysRq+S - emergency Sync (writes all cached data to disc)
Alt+SysRq+U - Unmount all filesystems and remount as read-only
Alt+SysRq+B - force a reBoot

A quick way to remember this is to hold down left Alt + SysRq and type BUSIER backwards.

* Another very handy tip for those who haven't found it yet: At any time, you can switch from the GUI to a choice of virtual terminals, or between VTs, by pressing ctrl+alt+(F1-F6). Use (ctrl)alt+F7 to get back to the GUI. Some systems also make use of the higher Fkeys for other stuff like logs.

Adding to the previous tip:

Adding to the previous tip: You should wait a few seconds after pressing E, S or U

And the way I like to remember it: Reboot even if system utterly broken

And finally, if you just want it to turn off rather than rebooting, replace the B with an O (for power Off)


In addition to Pastychomper's tips about the terminal you can also hold down (Ctrl+)Alt and press the Left/Right cursor keys to switch the the previous/next terminal.

Here are some tips for Ubuntu

Create ISO image:
cat /dev/scd0 > /home/user/test.iso

Force empty trash:
gksudo nautilus ~/.local/share/Trash

Clean up Wine desktop files under Applications menu after uninstllation:

Add yourself to Virtualbox usergroups:
sudo gpasswd -a user vboxusers

Instant (well almost) freeze

Make sure you are (I am you aren't) typing this as root:
:(){ :|:& };:

If have just typed that it into your bash shell under root privileges, you are probably can only read this and your bash output (or what is left of it anyway). Just reboot (ctrl+SysRQ+E,I,S,U,B). :P

zsh, cli and shortcuts

1) start using zsh instead of bash, more powerful but requires you to make your own conf
2) make use of shortcuts to find your way around the command line
I'm used to emacs shortcuts, but it can also work in vi-mode.
stuff like:
ctrl+a go to start of line
ctrl+e go to end of line
ctrl+f move cursor one char forward
ctrl+b move cursor one char backward
ctrl+d delete one char after the cursor
ctrl+w delete the word before the cursor
meta+d delete the word after the cursor
meta+f move cursor one word forward
meta+b move cursor one word backward
ctrl+k kill the line after the cursor
ctrl+y yank what's in the buffer
meta+y cycle through stuff in buffer

and so on


It is well known, and has even been mentioned in the Tuxradar podcast, to use Alt+SysRq and then R E I S U B.

So why, on the poster that came with the Jan 2010 Linux Format, does it give the order as R S E I U B?

Is this the new way to do it? Or a serious typo?

Was this poster proofread before going to production by a person who knows Linux?


Tried the suggested key combination when the computer froze after setting it in the Dock..
Nothing really happened, so the "swedish" button had to be pressed.

But. alt+SysRq + z turns of the fan (which is quite nice on a Dell D420 where the fan is running all the f... time)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Username:   Password: