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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Psst. Open beta.

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:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using sudo from sorted by
Terminal - Commands using sudo - 443 results
sudo sh -c 'echo 1 > /proc/sys/kernel/dmesg_restrict'
2015-03-13 20:54:45
User: Blacksimon
Functions: sh sudo

Linux offers an interesting option to restrict the use of dmesg. It is available via /proc/sys/kernel/dmesg_restrict.

You can check the status with:

cat /proc/sys/kernel/dmesg_restrict

Alternatively you can use sysctl:

sudo sysctl -w kernel.dmesg_restrict=1

To make your change persistent across reboot, edit a fille in /etc/sysctl.d/.

sudo iptables -A INPUT -m limit --limit 2000/sec -j ACCEPT && sudo iptables -A INPUT -j DROP
2015-03-09 20:16:17
User: qdrizh
Functions: iptables sudo
Tags: iptables

VPS server hosts suspect DOS attack if PPS is too high. This limits packets at the interface level. Do "sudo apt-get install iptables-persistent" to make persistent, or, if you already have, reconfigure with "sudo dpkg-reconfigure iptables-persistent"

command foo bar | sudo tee /etc/write-protected > /dev/null
sudo gpg --refresh-keys; sudo apt-key update; sudo rm -rf /var/lib/apt/{lists,lists.old}; sudo mkdir -p /var/lib/apt/lists/partial; sudo apt-get clean all; sudo apt-get update
sudo netstat -tulpn | grep :8080
python -c "import pip; print(' '.join([x.project_name for x in pip.get_installed_distributions()]))" | xargs sudo pip install -U
sudo hdparm -B 200 /dev/sda
sudo tee /path/to/file < /dev/null
sudo bash -c "> /var/log/httpd/access_log"
for i in chmod chown; do sudo "$i" --reference=/home/user/copyfromfile /tmp/targetfile; done
2014-08-28 15:08:32
User: zlemini
Functions: chmod sudo

Copy both perms and owner group from one file to another.

sudo pip install rainbowstream && rainbowstream -iot
2014-08-20 06:45:16
User: DTVD
Functions: install sudo

Rainbow Stream is a smart and nice Twitter client on terminal.

Almost everything you can do with a GUI application can be done, even viewing an image.

- Tab-autocomplete, history browsing

- Beautiful built-in themes and custom configuration support

- Tweet's images directly on your terminal.

sudo dpkg -P $(dpkg -l yourPkgName* | awk '$2 ~ /yourPkgName.*/ && $1 ~ /.i/ {print $2}')
2014-08-06 22:40:32
User: wejn
Functions: awk sudo
Tags: dpkg purge

Recently in Debian Wheezy the dpkg command refuses to work with wildcards, so this is the one-liner alternative. (alternative to #13614)

sudo restart lightdm
sudo dpkg -P $(sudo dpkg -l yourPkgName* | awk '$2 ~ /yourPkgName.*/' | awk '$1 ~ /.i/' | awk '{print $2}')
2014-08-02 18:14:02
User: woohoo
Functions: awk sudo
Tags: dpkg purge

Recently in Debian Wheezy the dpkg command refuses to work with wildcards, so this is the one-liner alternative.

sudo bash -c "cd /PATH/TO/THE/DIRECTORY;bash"
2014-07-28 20:20:04
User: Zath
Functions: bash sudo

Change current working directory with root permissions.

Place this snippet in your .bashrc to add a new "sudocd" command:

function sudocd { sudo bash -c "cd $1;bash" }

Usage: sudocd DIRECTORY

Please note that if you will use this command to cd into directories with the permissions allowing only root to be in them, you will have to use sudo as a prefix to every command that changes/does something in that directory (yes, even ls).

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
sudo apt-get install msttcorefonts
sudo apt-get install p7zip-rar p7zip-full unace unrar zip unzip sharutils rar uudeview mpack arj cabextract file-roller
sudo apt-get install libavcodec-extra
2014-06-03 16:28:22
Functions: install sudo

Install the unrestricted version of libavcodec . It will keep away from any issues or missing codecs in video editors or transcoders. Install unrestricted version of libavcodec by the command.

sudo kill -9 $( ps -e | grep Xorg | awk '{ print $1 }' )
2014-06-01 22:43:32
Functions: awk grep kill ps sudo

There are times when a X Window server hangs. When this happens, you can log in on a terminal and kill the Xorg process (i.e. the X Server). This one line command will do the trick.

sudo efibootmgr --bootnext `efibootmgr | sed -n "s/^Boot\([0-9]\{4\}\)\* Windows Boot Manager$/\1/p"` && reboot
2014-05-31 11:51:52
User: moneytoo
Functions: sed sudo

Quickly reboot directly to Windows (or any other operating system) without the need to enter BIOS/UEFI or boot loader (if any). It's valid for one boot only, no persistent changes to boot priorities.

sudo ntpdate serverip
export NEWUSER=newuser; mkdir /home/$NEWUSER; useradd -d /home/$NEWUSER -s /bin/bash -G sudo $NEWUSER; passwd $NEWUSER
sudo add-apt-repository ppa:PPA_TO_ADD
2014-04-24 20:02:39
User: KlfJoat
Functions: sudo

There is no longer a need to add PGP keys for Ubuntu Launchpad PPA's.

The add-apt-repository command creates a new file for the PPA in /etc/sources.list.d/ then adds the PPA's keys to the apt keyring automatically. No muss, no fuss.

sudo /sbin/route add -host -interface ppp0
2014-04-13 00:17:53
User: jifilis
Functions: sudo
Tags: unix VPN route

In this example, is the host that should be routed via the VPN and "ppp0" is the name of the VPN network interface (ifconfig shows you the list of network interfaces). Can be a IP or domain name.