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

watch iptables counters
This will allow you to watch as matches occur in real-time. To filter out only ACCEPT, DROP, LOG..etc, then run the following command: watch 'iptables -nvL | grep -v "0 0" && grep "ACCEPT"' The -v is used to do an inverted filter. ie. NOT "0 0"

Find all files currently open in Vim and/or gVim
Catches .swp, .swo, .swn, etc. If you have access to lsof, it'll give you more compressed output and show you the associated terminals (e.g., pts/5, which you could then use 'w' to figure out where it's originating from): lsof | grep '\.sw.$' If you have swp files turned off, you can do something like: ps x | grep '[g,v]im', but it won't tell you about files open in buffers, via :e [file].

Easy way to scroll up und down to change to one of n last visited directories.
This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key. Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg...

Batch rename extension of all files in a folder, in the example from .txt to .md
Batch rename extension of all files in a folder, in the example from .txt to .md

Merge PDFs with Ghostscript wrapped in a function
This is an expansion on a previous entry, which I've wrapped in a function and placed in my profile. The "$@" is a positional parameter, much like "$*", but the parameters are passed on intact, without interpretation or expansion; so you can simply call the function like this: mergepdf * This will output a merged PDF of all PDFs in the current directory. Alternatively, you can simply list them like so: mergepdf 00.pdf 01.pdf 02.pdf ... N.B. Passing a wildcard will merge all PDFs in the current directory in name order, e.g. 00.pdf 01.pdf aa.pdf ab.pdf

How to establish a remote Gnu screen session that you can re-connect to
Long before tabbed terminals existed, people have been using Gnu screen to open many shells in a single text terminal. Combined with ssh, it gives you the ability to have many open shells with a single remote connection using the above options. If you detach with "Ctrl-a d" or if the ssh session is accidentally terminated, all processes running in your remote shells remain undisturbed, ready for you to reconnect. Other useful screen commands are "Ctrl-a c" (open new shell) and "Ctrl-a a" (alternate between shells). Read this quick reference for more screen commands: http://aperiodic.net/screen/quick_reference

How fast is the connexion to a URL, some stats from curl

Unencrypted voicechat
Sends the microphone input from PC1 to the speakers of PC2. Do the same in reverse to have an actual conversation ;) ... maybe with another port tough

Browse shared folder when you're the only Linux user
Under Ubuntu smbclient is part of the samba package. With the version I use (3.0.28a) cd-ing into folders with spaces in the name is a drag. You have to put the folder name in quotes: smb: \Shared\> cd "Marketing and PR"

Change the default editor for modifying the sudoers list.
On Ubuntu, the default editor for visudo is nano. To change the editor to something else (e.g., vi) use this command.


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: