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:
The variable ? contain the last exit status of a command, it can be printed for troubleshooting purpose.
I use this simple command for remove all backup files generated usually by editors like Vim and Emacs.
During this operation :
# mv Joomla_1.5.10-Stable-Full_Package.zip /var/www/joomla/
I invoke /var/www/joomla/ as last command argument. To change in this directory I can use
# cd !$
So I go to
hob:/var/www/joomla#
Assuming that 219,229 and 221 are entries in history, I recall them in a single line for execute multiple commands
219 ifdown wlan0
...
221 ifup wlan0
...
229 iwconfig wlan0 mode Managed
so the result is execution of # ifdown wlan0 ; iwconfig wlan0 mode Managed ; ifup wlan0
tailf same as tail -f follow the flow of a log file, showing it in real time to stdout.
Aureport is a tool for displaying auditd system log. -x options cause to display launched executable on system.
Aureport work with auditd so auditd must be installed an running on a system.
Tested on CentOS / Debian
Simple but useful command, I use this for purge an hard disk entry in Virtualbox registry file (is in ~user/.Virtualbox) that persist if I erase a Virtual Machine, so I need to delete it manually.
Umask is obtained subtracting 7 from each cypher of octal format. I store octal perm format in an array,then for each element of array I subtract 7. The result is the umask.
I use this for connect via sftp to a server listening on a non default ssh port.
ifstat, part of ifstat package, is a tool for displaying bandwidth and other statistics. The -n option avoid to display header periodically, the -t option put a timestamp at the beginning of the line.
Works for me on Debian and CentOS
If histappend options is set in bash, the file .bash_history will not be overwrite and history list is append to it.
Works on CentOS ad OpenBSD too, display time of accounts connection on a system, -p option print individual user's statistics.
Lam is a command available on Bsd (I've tested it on OpenBSD).Is useful for laminate a file line by line. The -f option set the field width ( -f min.max ).
Lndir create from source directory to destination directory a full symlink tree of all contents of source directory, really useful for propagate changes from a directory to another.
Look search for lines in a file that beginning with a given string.
Same as $ grep ^n /etc/passwd
This is useful for remove all packages that are part of a common suite.
I have often file like this
01 - file.file
02 - file.file
03 - file.file
I rename all with this command
for f in * ; do mv -- "$f" "${f/[0-9][0-9] \- /}" ; done
then it looks like this
file.file
file.file
file.file
etc
Nicely display permissions in octal format and filename for a given directory
Execute a command on shell logout,and run it until is finished,then shell is closed.
Suppose that you had change in a directory like /home/user/mycode/code, and now you need to list it, instead of type entire path again, use ls !$ to recall path and list. Useful with many commands, this is only an example. (In this case, same result can be achivied with ls .)