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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
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.
Compares two versions with dpkg. It is not always obvious what version dpkg/apt will consider to be more recent. Operators include the following :
* These treat an empty version as earlier than any version: lt le eq ne ge gt.
* These treat an empty version as later than any version: lt-nl le-nl ge-nl gt-nl.
* These are provided only for compatibility with control file syntax: < > >.
This command doesn't output anything. It only returns with status 0 or 1, hence the echo "y" || echo "n" to get an output.
This command kills all processes with 'SomeCommand' in the process name. There are other more elegant ways to extract the process names from ps but they are hard to remember and not portable across platforms. Use this command with caution as you could accidentally kill other matching processes!
xargs is particularly handy in this case because it makes it easy to feed the process IDs to kill and it also ensures that you don't try to feed too many PIDs to kill at once and overflow the command-line buffer.
Note that if you are attempting to kill many thousands of runaway processes at once you should use 'kill -9'. Otherwise the system will try to bring each process into memory before killing it and you could run out of memory. Typically when you want to kill many processes at once it is because you are already in a low memory situation so if you don't 'kill -9' you will make things worse
These part of the command:
svn status | grep '^\?' => find new file or directory on working copy
sed -e 's/^\?//g' => remove "^" character on the first character of file name
xargs svn add => add file to subversion repository
You can modify above command to other circumtances, like revert addition files or commit files that have been modified. ^_^
Live extension of an ext3 file system on logical volume $v by 200GB without the need to unmount/remount.
Requires that you have 1) a version of resize2fs that contains code merged from ext2online, and 2) kernel support for online resizing. (e.g. RHEL 5)
Kills the most recently created firefox process.
Output: Version 3.2-0 (for example if you type # aptitude show bash | grep Vers
Depends on the language of your distribution, because the name of the word "Version" in other languages may be different.
This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations.
sudo dd if=/media/disk/backup/sda.backup of=/dev/sda
Alternatively, you can use an SSH connection to do your backups:
dd if=/dev/sda | ssh [email protected] dd of=~/backup/sda.backup
rsyncs files to a server excluding listed files
also a file can be used to exclude common exclude rules and/or to exclude a ton of files, like so:
rsync --exclude-from '~/.scripts/exclude.txt'
where exclude.txt has one rule per line:
On the Mac, the format ifconfig puts out is little different from Linux: the IP address is space separated, instead of colon. That makes parsing the IP address easier. See releated command for Linux/Unix:
a quick one-line way to disable caps lock while running X.
Edit the files, each in a separate tab. use gT and gt to move to the left- and right-tab, respectively. to add another tab while editing, type ':tabe filename'
This command will list a CSV list of infected files detected by clamav through squidclamav redirector.
Parses tektronic given csv files for both channel 1 and channel 2 and joins them together. Can be easily used by gnuplot after that.
Replace 'more' command with any command which is in your PATH.