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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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 will view the console and assumes the screen is 80 characters wide.
Use /dev/vcs2 for the next virtual console.. etc.
Adds the stdout (standard output) to the beginning of logfile.txt. Change "command" to whatever command you like, such as 'ls' or 'date', etc. It does this by adding the output to a temporary file, then adding the previous contents of logfile.txt to the temp file, then copying the new contents back to the logfile.txt and removing the temp file.
Searches /var/log/secure for smtp connections then lists these by number of connections made and hosts.
Searches the /var/log/secure log file for Failed and/or invalid user log in attempts.
Good old cat & output redirection. Using this method you can combine all kinds of things - even mpeg files. My video camera makes a series of .mpeg files that are broken into 4gb chunks. Using this command I can easily join them together. Even better, combined with the cp command the files can be copied and joined in one step.
Generate the iso from the disk, easily.
same as "dd if=/dev/cdrom of=~/mydisk.iso"
xclip -o > /tmp/spell.tmp # Copy clipboard contents to a temp file
aspell check /tmp/spell.tmp # Run aspell on that file
cat /tmp/spell.tmp | xclip # Copy the results back to the clipboard, so that you can paste the corrected text
I'm not sure xclip is installed in most distributions. If not, you can install x11-apps package
Useful to detect number of tabs in an empty line, DOS newline (carriage return + newline).
A tool that can help you understand why your parsing is not working.
Be aware of using the --password argument as it will appear your password in plain text on the screen. You may use -p argument instead, it will prompt you to enter you password in hidden mode.
Displays the duplicated lines in a file and their occuring frequency.
Displays all information about your battery. for just capacity, try replacing cat with
grep -F capacity:
Battery number might be BAT0 instead of BAT1. Just run
cd /proc/acpi/battery; ls
and find out what folder is in that directory and replace that name with BAT1
Takes a input file (count.txt) that looks like:
1
2
3
4
5
It will add/sum the first column of numbers.
This command lets you see and scroll through all of the strings that are stored in the RAM at any given time. Press space bar to scroll through to see more pages (or use the arrow keys etc).
Sometimes if you don't save that file that you were working on or want to get back something you closed it can be found floating around in here!
The awk command only shows lines that are longer than 20 characters (to avoid seeing lots of junk that probably isn't "human readable").
If you want to dump the whole thing to a file replace the final '| less' with '> memorydump'. This is great for searching through many times (and with the added bonus that it doesn't overwrite any memory...).
Here's a neat example to show up conversations that were had in pidgin (will probably work after it has been closed)...
sudo cat /proc/kcore | strings | grep '([0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\})'
(depending on sudo settings it might be best to run
sudo su
first to get to a # prompt)
using `cat` under *NIX - just because you help manage M$ Windoze
*doesn't* mean you should have to resort to using it!
You can also make custom win32 installers with the 7zip "extras" package:
cat /path/to/7zSD.sfx /path/to/config.txt /path/to/archive > setup.exe
This command is much quicker than the alternative of "sort | uniq -c | sort -n".
You can use multiple field separators by separating them with | (=or).
This may be helpful when you want to split a string by two separators for example.
#echo "one=two three" | awk -F "=| " {'print $1, $3'}
one three