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:
This command will disable a guest user logon, this user don't have password to login in the system.
Bash process substitution which curls the website 'hashbang.sh' and executes the shell script embedded in the page.
This is obviously not the most secure way to run something like this, and we will scold you if you try.
The smarter way would be:
Download locally over SSL
> curl https://hashbang.sh >> hashbang.sh
Verify integrty with GPG (If available)
> gpg --recv-keys 0xD2C4C74D8FAA96F5
> gpg --verify hashbang.sh
Inspect source code
> less hashbang.sh
> chmod +x hashbang.sh
Linux offers an interesting option to restrict the use of dmesg. It is available via /proc/sys/kernel/dmesg_restrict.
You can check the status with:
Alternatively you can use sysctl:
sudo sysctl -w kernel.dmesg_restrict=1
To make your change persistent across reboot, edit a fille in /etc/sysctl.d/.
The command creates new session "test", executes 'date' and then start your default shell (to keep the detached session alive). Change 'date' to fit your needs.
screen -r test
will attach the created session.
This lists the number of ogg/mp3/wav/flac files in each subdirectory of the current directory. The output can be sorted by piping it into "sort -n".
A very simple command to toggle Chrome?s default style sheet. It uses the test command to see if the "Custom.css.off" file exists, if so, it will become "Custom.css", and if not, "Custom.css" is moved to "Custom.css.off" Thus, swapping.
This is accomplished with "&&" and "||"
url can be like any one of followings:
If url mismatching, whole url will be returned.
For each directory from the current one, list the counts of files in each of these directories. Change the -maxdepth to drill down further through directories.
Uses find, plutil and xpath.
Note: Some applications don't have proper information. system_profiler might be better to use.
It's a bit slow query.
Due to command length limit, I removed -name "*.app" and CFBundleName.
Avoids the nested 'find' commands but doesn't seem to run any faster than syssyphus's solution.
This version combines the best of the other suggestions and adds these features:
1. It scans a /16 subnet
2. It is very fast by running the ping commands in the background, running them in parallel.
3. Does not use the "-W" option as that's not available in older ping versions (I needed this for OS X 10.5)
Handles spaces in file names and directories. Optionally change directories as well by pipe to tr from dirname.
run it inside a screen session, you send commands to screen itself!
This command explains how to manage some asynchronous PID in a global process.
The command uses 4 processes in a global process. The asynchronous scripts are simulated by a time.sh script
more infos :
On Debian/Ubuntu the pygments script is called pygmentize and can be found in the python-pygments package.
For an overview of all available lexers, formatters, styles and filters use
Here is an example using more options
pygmentize -f 256 -l sh -F whitespace:spaces=True,tabs=True -O style=borland ~/.bashrc | less -R
echo '127.0.0.1 facebook.com' | sudo tee -a /etc/hosts
Do not execute this command if you don't know what you are doing.