All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Remove old unused kernels from Red Hat Enterprise Linux 5 & Fedora 12/13
Install using yum install yum-utils Options include: --oldkernels Remove old kernel and kernel-devel packages --count=KERNELCOUNT Number of kernel packages to keep on the system (default 2) use package-cleanup --help for a complete list

Reverse ssh
Both hosts must be running ssh and also the outside host must have a port forwarded to port 22.

Convert records in columns to csv

Enable cd by variable names
Usage: $ mydir=/very/long/path/to/a/dir $ cd mydir I often need to cd where no man wants to go (i.e. long path). by enabling the shell option cdable_vars, I can tell cd to assume the destination is the name of a variable.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Search some text from all files inside a directory

extract column from csv file
extracts the 5th column using the delimiter ','

Simple complete system backup excluding files or directories
You can exclude more system folders or individual files which are not necessary for the backup and can be recreated after the restore procedure, like /lost+found, /mnt, /media, /tmp, /usr ... Restoring the above backup procedure is as simple as becoming root and typing: $ tar zxpf backup.tgz -C / You can extract any file or directory out of the backup.tgz file for recovery, for instance, if you have a corrupt or mis-configured fstab file, you could simply issue the command: $ tar zxpf backup.tgz /ect/fstab -C / Other options: v add verbose option to see files processed A far safer solution is to restore the desired files under a different directory, and then compare, move, or update the files to their original locations afterward.

Display information sent by browser
Have netcat listen on port 8000, point browser to http://localhost:8000/ and you see the information sent. netcat terminates as soon as your browser disconnects. I tested this command on my Fedora box but linuxrawkstar pointed out that he needs to use $ nc -l -p 8000 instead. This depends on the netcat version you use. The additional '-p' is required by GNU netcat that for example is used by Debian but not by the OpenBSD netcat port used by my Fedora system.

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: