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 exports all lines of input file as environment variables, assuming each line is like these:
OH=YEAH
FU=UUUU
Use it as bash-script.
The first positional parameter specifies the fixed length of the numerical index.
Further params specify the files to manipulate.
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..
This is a useful command to backup an sd card with relative total size for piping to pv with a progressbar
set how many commands to keep in history
Default is 500
Saved in /home/$USER/.bash_history
Add this to /home/$USER/.bashrc
HISTFILESIZE=1000000000
HISTSIZE=1000000
Not always does Xorg run on :0. For times like those, this script allows you to find out which it is.
This will check if a user is logged in using ssh and will log out the user automatically after the specified time in seconds without data retrieval on the server side.
Will work with bash and zsh so put it into your sourced shell file on the server side.
Be aware that users can change this themselves as it's just a envoronment variable.
You can put this into your shell sourced file like .bashrc or .zshrc to have a different mysql prompt.
See http://dev.mysql.com/doc/refman/5.1/de/mysql-commands.html for more informations.
Beware that currently with mysql 5.5 the seconds are buggy and won't be displayed if you put this into a .cnf file. With the enironment variable this will work.
# s = combine multiple lines of whitespace into 1
# x4 = set the tabstop to 4 instead of 8
# F = Exit if the output fits on 1 screen. This is similar to git diff
# R = Raw control chars. This allows you to pipe colordiff straight to less. ie: alias sdi="svn diff | colordiff | less"
# S = Chop off long lines
# X = Dont send termcap init and deinit scrings to the terminal
On systems where your home directory is shared across different machines, your bash history will be global, rather than being a separate history per machine. This setting in your .bashrc file will ensure that each machine has its own history file.
(This may be specific to bash only.) This transforms the current working directory to all uppercase characters and replaces forward slashes with backslashes, prepending the string with "C:" and appending a single ">". It serves no practical purpose, but may serve as a great practical joke if you can insert it to some victim's .bashrc :-)
usage: dng BRE [selection]
default selection is the last match
DNS is ok, but although domainnames may be easier to remember than IP numbers, it still requires typing them out. This can be error-prone. Even more so than typing IPv4 numbers, depending on the domainname, its length and complexity.
Adds a function that runs every time the prompt is rendered. The function grabs the CWD from PWD and issues a command to tmux to change the current window
when working with many machines in a computer lab need to know the IP addr is very large, this is a simplistic solution to make things easier
I was surprised to find that with RedHat bash, I could not find any comment lines (begining with #) in my bash shell history. Surprised because in Mageia Linux this works. It turns out that RedHat's bash will keep comment lines if in my .bashrc, I define:
export HISTIGNORE=' cd "`*: PROMPT_COMMAND=?*?'
Why have comment lines in shell history? It's a handy and convenient way to make proto-commands (to be completed later) and for storing brief text data that is searchable in shell history.
This will affect all invocations of grep, even when it is called from inside a script.
Is there somebody that uses Windows a lot that keeps messing up your Linux machine? Press Ctrl+Alt+F1-F6 and run this command after logging into a text shell!
Thanks to the authors of:
awk '!x[$0]++' <file>
and the author of:
joinargs() { (local IFS="$1"; shift && echo "$*") }
and others, we can have a fast Linux or android.
IMPORTANT if you find a priority order problem in PATH you can push a path directory to the front without duplication as follows:
PATH=/bin:$PATH
then ...
Check duplication with:
echo $PATH|tr : '\n'|sort|uniq -d
Finally do a very neat line by line list of $PATH:
echo "${PATH//:/$'\n'}
The speed up is very noticeable for android, and builds on Linux Ubantu are much faster with make and scripts.
I will update the command on request. Timothy from SONY