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/
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:
View all files opened by a user in specified directory.
The +D option makes lsof search all sub-directories to complete depth, while ignoring symbolic links.
This will remove all installed kernels on your debian based install, except the one you're currently using.
Emits the device names which will be printed by iostat for an LVM volume; doesn't show the names for the underlying devices when snapshots are being used (the -cow and -real devices in /dev/mapper)
Great for sysadmins! Don't forget to pass the vlan to your port in a manageable switch.
After vconfig, you should use
sudo ifconfig eth0.[VID] up
Now the interface is up, you can use dhclient or ifconfig again to get an ip address.
Find and kill multiple instances of a process with one simple command.
It is safe when there is
This command is useful when there is no need to have a password.
This will reboot as the Grub 2 option.
Run this command as root to get enough stats. It works on AMD and Intel machines, including desktops. If ran on a laptop it'll give you suggestions on extending your battery life.
You'll need to install PowerTOP if you don't have, via 'apt-get install powertop', etc.
To grep the output use: sudo powertop -d | grep ...
The many command suggestions PowerTOP gives you alone will increase your command-line fu!
Change the APP variable's value to whatever you want to install. Depending on how fast your machine is, you'll want to adjust the value 50 to something else. You might also want to play a different game than Gnometris - just make sure it's a GUI game.
This command is designed in order to avoid this error :
* Reloading web server config apache2 httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
This command will return a full list of Error 404 pages in the given access log. The following variables have been given to awk
Hostname ($2), ERROR Code ($9), Missing Item ($7), Referrer ($11)
You can then send this into a file (>> /path/to/file), which you can open with OpenOffice as a CSV
ethtool is used for querying settings of an ethernet device and changing them. In this example I setup 100 Mb/s full duplex on my Linux Box
(Useful when firewalls prevent you from using NTP.)
If you want to check that the spoof worked, type the same command as earlier:
ifconfig en1 | grep ether
Now you will see:
For the wired ethernet port:
sudo ifconfig en0 ether 00:e2:e3:e4:e5:e6
I had problems in Ubuntu while trying to edit /etc/resolv.conf, even with sudo I couldn't make any change. After a 2 minutes search on google I found this command.
Hope someone finds it useful.
It works like chmod, with + and - to denote which attributes are being added and which are being removed.
See other attributes on man pages or on wikipedia http://en.wikipedia.org/wiki/Chattr
Limits the usage of bandwidth by apt-get, in the example the command will use 30Kb/s ;)
It should work for most apt-get actions (install, update, upgrade, dist-upgrade, etc.)
I know this sucks in some way but if someone can improve it please be my guest
It seems to completely void the benefit of having an encrypted folder if you then have a script on your unencrypted hard drive with your password in it. This command will mount a truecrypt file at a given mount point after asking you for the password.
Please install aria2c before you try the above command. On ubuntu the command to install aria2c would be:
sudo aptitude install aria2
Use sed to comment out any up/down bindings in zsh
replace eth0 with your ethernet or wireless network interface.
Comcast is an ISP in the United States that has started hijacking DNS requests as a "service" for its customers. For example, in Firefox, one used to be able to do a quick "I'm Feeling Lucky" Google search by typing a single word into the URL field, assuming the word is not an existing domain when surrounded by www.*.com. Comcast customers never receive the correct NX (non-existent domain) error from DNS. Instead, they are shown a page full of advertising. There is a way to "opt out" from their service, but that requires having the account password and the MAC address of your modem handy. For me, it was easier just to set static DNS servers. But the problem is, which ones to choose? That's what this command answers. It'll show you the three _non-hijacked_ Comcast DNS servers that are the shortest distance away.
Perhaps you don't have Comcast (lucky you!), but hopefully this command can serve as an example of using netselect to find the fastest server from a list. Note that, although this example doesn't show it, netselect will actually perform the uniq and DNS resolution for you.
Requires: netselect, curl, sort, uniq, grep