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:
I know how hard it is to find an old command running through all the files because you couldn't remember for your life what it was. Heres the solution!! Grep the history for it. depending on how old the command you can head or tail or if you wanted to search all because you cannot think how long ago it was then miss out the middle part of the command. This is a very easy and effective way to find that command you are looking for.
just an alternative to setting the size, this allows you to scroll up and see your previous commands in a given session but when you logout the history is not saved. That's the only advantage to doing it this way..
just use a space to prevent commands from being recorded in bash's history on most systems
this one works on user crontab
set how many commands to keep in history
Default is 500
Saved in /home/$USER/.bash_history
Add this to /home/$USER/.bashrc
hide your ass, buddy.
simple and easy backup your history with timestamp
This makes your commandlinefu.com's favorites appear as most recent commands in your history.
Only from a remote machine:
Only access to the server will be logged, but not the command.
The same way, you can run any command without loggin it to history.
ssh user@localhost will be registered in the history as well, and it's not usable.
Sometimes easier to just hit these keys to access previous / next commands in history instead of moving your hands all the way to the cursor keys
This command disable sending of start/stop characters.
It's useful when you want to use incremental reverse history search forward shortcut (Ctrl+s).
To enable again, type:
"What it actually shows is going to be dependent on the commands you've previously entered.
When you do this, bash looks for the last command that you entered that contains the substring "ls", in my case that was "lsof ...". If the command that bash finds is what you're looking for, just hit Enter to execute it. You can also edit the command to suit your current needs before executing it (use the left and right arrow keys to move through it).
If you're looking for a different command, hit Ctrl+R again to find a matching command further back in the command history. You can also continue to type a longer substring to refine the search, since searching is incremental.
Note that the substring you enter is searched for throughout the command, not just at the beginning of the command." - http://www.linuxjournal.com/content/using-bash-history-more-efficiently
If you are installing some new package. You can first go through the step by step install and then take the commands that you ran from history to create shell script which can used to install the package on other machines say test or production.
!$ will be expanded to the last argument on the previous command. There are also positionnal parameters like !:1, !:2...
By default bash history of a shell is appended (appended on Ubuntu by default: Look for 'shopt -s histappend' in ~/.bashrc) to history file only after that shell exits.
Although after having written to the history file, other running shells do *not* inherit
that history - only newly launched shells do.
This pair of commands alleviate that.
Takes effect immediately.
Bash history commands are those that begin with the character !
(eg. the most popular 'sudo !!' Explained here => http://www.commandlinefu.com/commands/view/13).
By default bash immediately executes the history command.
Setting this shell option will make bash first allow you to verify/edit an
history command before executing it.
To set this option permanently, put this command in ~/.profile or ~/.bashrc file.
To unset this option issue following command.
shopt -u histverify
Put a space in front of your command on the command line and it will not be logged as part of your command line history.
You can find a command's history event number via the `history` command.
You can also put the history event number in your prompt: \! for bash, or %h for zsh.
Finally, I would like to point out that by "number", I mean POSITIVE INTEGER. Not, say, a letter, such as 'm'. Examples:
This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key.
Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg...
Uses history to get the last n+1 commands (since this command will appear as the most recent), then strips out the line number and this command using sed, and appends the commands to a file.
Unsetting HISTFILE avoid getting current session history list saved.