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:
Assumes that the files are named as such: 01-Filename.mp3
If your files are named differently, change the number of periods in the sed 's/...\(.*\)/\1' bit to match the numbers of characters you need to cut off the front of the file.
Note: This only writes the titles.
For those files in current folder that would be shown in `ls *ext`, for some extension ext, move/rename that file removing the .ext suffix from the file name.
It uses Bash's parameter substitution, as seen in
http://tldp.org/LDP/abs/html/parameter-substitution.html#PCTPATREF
(for analog use in prefix, see http://tldp.org/LDP/abs/html/parameter-substitution.html#PSOREX2 )
Gets the current system user running a process with the specified pid
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.
This fixes a bug found in the other scripts which fail when a branch has the same name as a file or directory in the current directory.
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
usage: tpb searchterm
example: tpb the matrix trilogy
This searches for torrents from thepiratebay and displays the top results in reverse order,
so the 1st result is at the bottom instead of the top -- which is better for command line users
This is an "argument calculator" funktion. The precision is set to 4 and you can use dot (.) or comma (,) as decimal mark (which is great for german users with a comma on the numpad).
This opens a python command line. You can use math and random and float-division is enabled (without appending .0 to integers). I just don't know how to specify a standard precision.
use python as calculator, press ctrl+d to exit
reminder: when doing factions add atleast one decimal number like so
22.0/7 or 22/7.0
You could avoid xargs and sed in this case (shorter command and less forking): At least bash and zsh have some mighty string modifiers.
I would also suggest using find with exec option to get more flexibility. You may leave out or include "special" file for example.
Unmounts all CIFS-based network drives. Very nice for shutting down network mounts on a Linux laptop just prior to going to sleep.
List usernames & their assigned shell.
If their home directory is in /home and excepting those account that have their login shell set to: noshell, false, nologin
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
Just hold Ctrl-R and start typing a string (e.g. ssh). The shell will search for that string in the command history. Keep pressing Ctrl-R to cycle through all commands matching pattern. This works in other "sub-shells" too, like a python interactive session.
It happens that sometime you remember that you used a special command short time before and you want to check the command again.
WIth this command you can just put the beginning of a command and then bash will look for you and it will print back safely withou executing
Very simple web server listening on port 80 will serve index.html file or whatever file you like pointing your browser at http://your-IP-address/index.html for example.
If your web server is down for maintenance and you'd like to inform your visitors about it, quickly and easily, you just have to put into the index.html file the right HTML code and you are done! Of course you need to be root to run the command using port 80.
This command will give you the same list of files as "find /etc/ -name '*killall' | xargs ls -l".
In a simpler format just do 'ls /etc/**/file'.
It uses shell globbing, so it will also work with other commands, like "cp /etc/**/sshd sshd_backup".
WIDTHL=10 and WIDTHR=60 are setting the widths of the left and the right column/bar. BAR="12345678" etc. is used to create a 80 char long string of "="s. I didn't know any shorter way.
If you want to pipe results into it, wrap the whole thing in ( ... )
I know that printing bar graphs can be done rather easily by other means. Here, I was looking for a Bash only variant.