commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Generated the CPU utilization stats with 5 lines /every 2 seconds.
Needs sysstat package to be installed prior to use sar.
List the files a process is using.
Copy the file with the given .extension at the source file's location. Eliminates the typing of long paths again and again.
Replace all ocurrences in the file.
The g option is to replace more than one occurrence in the same line. Whitout the g option, it only replace the first occurrence in the line.
This is a simple case of recursing through all directories, adding the '.bak' extension to every file. Of course, the 'cp $file $file.bak' could be any code you need to apply to your recursion, including tests, other functions, creating variables, doing math, etc. Simple and clean recursion.
Useful mainly for debugging or troubleshooting an application or system, such as X11, Apache, Bind, DHCP and others. Another useful switch that can be combined with -mmin, -mtime and so forth is -daystart. For example, to find files that were modified in the /etc directory only yesterday:
sudo find /etc -daystart -mtime 1 -type f
Redirect the local port 2000 to the remote port 3000. The same but UDP:
nc -u -l -p 2000 -c "nc -u example.org 3000"
It may be used to "convert" TCP client to UDP server (or viceversa):
nc -l -p 2000 -c "nc -u example.org 3000"
It allows customizing by means of lesspipe. You need to write a ~/.lessfilter script and put this into your ~/.bashrc:
Everyone on CLIFU needs to check this site out. Learn how to accomplish what you've been doing faster and more efficiently.
Saved my day, when my harddrive got stuck in read-only mode.
Traffic details on the Ethernet interface.
Search the pattern in bzip2 compressed file with out having to unzip.
Gives information about user's home directory and real name and shell user is having.
Get the hard disk information with out shutting down and opening the system.
It gives information on model no., serial no., cylinders/heads/sectors, and the supported features of the hard disk.
To know the OS distro and version, release.
Is same like /etc/redhat-release
This is useful if you have a program which doesn't work well with multicore CPUs. With taskset you can set its CPU affinity to run on only one core.
I use this command to save RTSP video streams over night from one of our national TV stations, so I won't have to squeeze the data through my slow internet connection when I want to watch it the next day.
For ease of use, you might want to put this in a file:
mplayer -dumpstream -dumpfile "$FILE" -playlist "$1"
allows simple C shell access to the power of bc - never could figure out how to do the same thing with Bash - that's why I use tcsh most of the time.