Commands by 3rl4ng (1)

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

Search through all installed packages names (on RPM systems)
You can use wildcard with rpm search but you have to do 2 things: 1. use "-a" switch (means "all") with query ("-q") switch - argument is a pattern to use while searching for package names of all installed packages 2. protect wildcards, so that shell could not eat them - escape it with backslash ("\") or enclose all pattern between apostrophes ("'"): $ rpm -qa 'co*de' As you can see above it is possible to insert wildcards into middle of the pattern. If you want, you can add "-i" or another rpm query options, "-i" will print package information for all installed packages matching pattern.

list files recursively by size

from the console, start a second X server
This starts a very basic X session, with just a simple xterm. You can use this xterm to launch your preferred distant session. $ ssh -X john@otherbox gnome-session Try also startkde or fluxbox or xfce4-session. To switch between your two X servers, use CTRL+ALT+F7 and CTRL+ALT+F8.

use wget to check if a remote file exists
put your link [url] to check if exist the remote file

Shell function to exit script with error in exit status and print optional message to stderr
USAGE: die ERRNUM [MESSAGE]

run a VirtualBox virtual machine without a gui
you can launch a VirtualBox VM from the command line using VBoxManage, but that invokes it in a gui environment. If you want to just fire off your VM in the background, use VBoxHeadless as shown. To get the names and UUIDs of your VirtualBox VMs, type: $ VBoxManage list

random xkcd comic as xml

apt-get upgrade with bandwidth limit
Trickle is here: http://monkey.org/~marius/pages/?page=trickle Trickle is a simple bandwidth limiter

Easily scp a file back to the host you're connecting from
Place in .bashrc and invoke like this: "mecp /path/to/file", and it will copy the specified file(s) back to the desktop of the host you're ssh'ing in from. To easily upload a file from the host you're ssh'ing in from use this: ucp (){ scp ${SSH_CLIENT%% *}:Desktop/upload/* .; }

Find usb device in realtime
Using this command you can track a moment when usb device was attached.


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: