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:
This comes in handy if you have daemons/programs that have potential issues and stop/disappear, etc., can be run in cron to ensure that a program remains up no matter what. Be advised though, if a program did core out, you'd likely want to know why (gdb) so use with caution on production machines.
Requires: signing-party (on Debian).
Note: you need a working MTA on your machine.
Opens a new shell as root. Useful if you want to run a lot of commands as superuser without needing to sudo each of them.
This command would be useful when it is desirable to list only the directories.
ls -d .*/
ls -d /path/to/top/directory/.*/
ls -ld */
This is the solution to the common mistake made by sudo newbies, since
sudo echo "foo bar" >> /path/to/some/file
does NOT add to the file as root.
sudo echo "foo bar" > /path/to/some/file
should be replaced by
echo "foo bar" | sudo tee /path/to/some/file
And you can add a >/dev/null in the end if you're not interested in the tee stdout :
echo "foo bar" | sudo tee -a /path/to/some/file >/dev/null
This is a command you see mentioned alot by Gentoo monkeys.
They say to use it after every update of GCC, any library you might use and glibc.
They argue that compiling and recompiling everything like this will optimize the system alot more because you are recompiling the entire system (gcc, glibc etc) with nativly compiled versions of themselves. Same goes for all libraries etc.
I doubt the difference in working speed is really worth the hours and hours you end up having your computer compile the same stuff again and again though.
On Debian systems, choose which command provides java. Works for all alternatives listed in /etc/alternatives.
First you need to instal aircrack-ng
Use this command if you need to put your wireless card into monitor mode.
interface = wlan0 || wifi0 || ath0 et ceatera...
channel = 6, 11, 10, 9 et ceatera
This is a little bash script that will take all files following the *gz pattern in the directory and apply the tar -zxvf command to them.
Have you ever had to scp a file to your work machine in order to copy its contents to a mail? xclip can help you with that. It copies its stdin to the X11 buffer, so all you have to do is middle-click to paste the content of that looong file :)
This is useful when you want to copy a file and also force a user, a group and a mode for that file.
Note: if you want to move that file instead of copying it, you can use
install -o user -g group -m 755 /path/to/file /path/to/dir/ && rm -f /path/to/file
which will remove the file only if the install command went fine.
Where < target > may be a single IP, a hostname or a subnet
-sS TCP SYN scanning (also known as half-open, or stealth scanning)
-P0 option allows you to switch off ICMP pings.
-sV option enables version detection
-O flag attempt to identify the remote operating system
-A option enables both OS fingerprinting and version detection
-v use -v twice for more verbosity.
nmap -sS -P0 -A -v < target >
I use this all the time for taking manual backups of stuff i want to keep but not important enough to backup regularly.
You can convert a FAT or FAT32 volume to an NTFS volume without formatting the drive, though it is still a good idea to back up your data before you convert.
This is a useful command that gives the hostname and the IP Address of your machine, on many OS. Tested on Linux and Solaris.
host command here is followed by `hostname`. Note the ` in the command is a back quote (or grave accent or back tic that usually shares the space with the ~ key). No other options are specified. See sample output.
This command lets you view the cam on remote machine whilst connected via ssh. Note: must connect to remote machine with ssh -Y.
Nice for ie6 for linux
This command deletes all files in all subfolders if their name or path contains "deleteme".
To dry-run the command without actually deleting files run:
find . | grep deleteme | while read line; do echo rm $line; done
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
I know there are a lot of random password generators out there, but I wanted something that put out something besides hex. Set count equal to the number of bytes you want.
Dashboard is OS X utility application. When you hit F12, Dashboard springs forward, dimming the background, some people have claimed memory or performance problems. In my case, I just don't use it, there may be other reasons you?d rather not have Dashboard available.
Change YES to NO to restore the previous functionality.