Hide

What's this?

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/

Get involved!

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using sudo from sorted by
Terminal - Commands using sudo - 400 results
sudo mount vmware-server-flat.vmdk /tmp/test/ -o ro,loop=/dev/loop1,offset=32768 -t ntfs
2013-07-29 14:45:29
User: JeremyinNC
Functions: mount sudo
0

Assumes XP/2000/2003. For Server 2008+ try offset=105,906,176 You can find this number in the System Information utility under Partition Starting Offset. UEFI based boxes you want partition 2 since the first is just the boot files (and FAT). This works with (storage side) snapshots which is handy for single file restores on NFS mounted VMware systems

sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys [key to get here]
2013-07-23 08:29:40
User: phattmatt
Functions: get sudo
0

If you are an unlucky sole behind a corporate firewall you will likely find that downloading gpg keys is blocked. This is because the hkp protocol uses port 11371 by default to transfer the key.

By adding "hkp://" to the beginning of the hostname and ":80" to the end you are asking gpg to try using port 80 to connect (less likely to be blocked by a firewall). This relies on the remote server answering to requests over port 80.

sudo port selfupdate && sudo port upgrade outdated && sudo port clean --all installed && sudo port -f uninstall inactive
sudo dumpe2fs /dev/sda1 | grep superblock
sudo /usr/sbin/exim -bp | sed -n '/\*\*\* frozen \*\*\*/,+1!p' | awk '{print $1}' | tr -d [:blank:] | grep @ | sort | uniq -c | sort -n
sudo lsof -p `sudo ps aux | grep -i neo4j | grep -v grep | awk '{ print $2 }'`
2013-06-02 10:15:30
User: andycunn
Functions: awk grep ps sudo
0

Inner "ps...grep..." command searches for a process matching the specified .

"lsof -p lists all file descriptors owned by . Includes open files, sockets, devices, etc...

sudo apt-cache dumpavail | grep Package | cut -d ' ' -f 2 > available.packages
sudo systemctl enable lxdm
sudo reboot
sudo nano /etc/modules-load.d/virtualbox.conf
2013-05-16 14:41:51
Functions: sudo
-1

To do this, we?ll use nano to create a new configuration file called ?virtualbox.conf?. This file will go in the ?/etc/modules-load.d? directory, which contains files that need to be loaded when Arch boots up. Since adding a file to this directory requires administrative permissions, we?ll need to precede our command with ?sudo? once again.

When nano brings up the blank file, add these three lines to it:

vboxguest

vboxsf

vboxvideo

As usual, when you?re finished entering text in nano, type Control-X to exit to the command line, and answer ?y? for yes when you?re asked whether you want to save your work, and then hit ?Return? to accept the filename. At this point, reboot your machine for the Guest Additions to take effect.

sudo pacman -S virtualbox-guest-utils
2013-05-16 14:39:38
Functions: sudo
0

Here you have to choose the correct kernel number, for example linux38.

sudo pacman -Scc
sudo mhwd-kernel linux00
2013-05-16 14:02:46
Functions: sudo
1

00 is the number of the linux kernel e.g. linux39

sudo pacman-mirrors -g
sudo pacman -Syu
2013-05-16 13:49:14
Functions: sudo
0

Warning: Instead of immediately updating as soon as updates are available, users must recognize that due to the nature of Arch's rolling release approach, an update may have unforeseen consequences. This means that it is not wise to update if, for example, one is about to deliver an important presentation. Rather, update during free time and be prepared to deal with any problems that may arise.

Pacman is a powerful package management tool, but it does not attempt to handle all corner cases. Read The Arch Way if this causes confusion. Users must be vigilant and take responsibility for maintaining their own system. When performing a system update, it is essential that users read all information output by pacman and use common sense. If a user-modified configuration file needs to be upgraded for a new version of a package, a .pacnew file will be created to avoid overwriting settings modified by the user. Pacman will prompt the user to merge them. These files require manual intervention from the user and it is good practice to handle them right after every package upgrade or removal. See Pacnew and Pacsave Files for more info.

Tip: Remember that pacman's output is logged in /var/log/pacman.log.

sudo useradd -U -m -s /bin/bash new_user
sudo su; sync; echo 3 > /proc/sys/vm/drop_caches
sudo shutdown -h now
sudo !-1
2013-04-22 03:45:14
User: datamining
Functions: sudo
0

this command also can run the last command as root

what's more, sudo !-2 can run the second last command as root , and so on

sudo shutdown -h <hour:minute>
sudo dmidecode --type 17
2013-04-18 20:13:07
User: FadeMind
Functions: sudo
Tags: ram dmidecode
0

Advanced information about RAM.

sudo apt-get install linux-headers-`uname -r`
2013-04-18 03:18:26
User: farazyashar
Functions: install sudo
2

Install the Linux kernel headers for currently running kernel version on Debian-based systems via apt-get

sudo sed -i 's/Exec=skype %U/Exec=skype --disable-cleanlooks -style GTK %U/' /usr/share/applications/skype.desktop
2013-04-17 08:43:00
User: FadeMind
Functions: sed sudo
0

Replace default command in skype.desktop file.

sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config -y && git clone https://github.com/hanschen/ksuperkey.git && cd ksuperkey && make && sudo mv ksuperkey /usr/bin/ksuperkey && cd ~ && rm -rf ksuperkey
2013-04-17 07:12:46
User: FadeMind
Functions: cd gcc install make mv rm sudo
0

Install Ksuperkey one command in Kubuntu.

You must manually add ksuperkey to autostart in System Settings KDE.

sudo sed -i 's/raspberrypi/pita1/' /etc/hosts /etc/hostname; sudo reboot
2013-04-16 07:27:41
User: egeoffray
Functions: sed sudo
0

Your computer's name is raspberrypi and you want to rename it to pita1.

This command will change both the hostname and the name used for netwrk communications.