All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Grep all non-ascii character in file
It will highlight non-ascii character in a file. those character can cause problem for some application parsing ascii file.

Escape forward slashes in a variable
For example $ path="/etc/apt/sources.list"; echo ${path//'/'/'\/'} will print $ \/etc\/apt\/sources.list

Edit the /etc/sudoers config file the right way.
'visudo' is installed by default on most Unix-like systems. If not installed, you can get it from the 'sudo' package. 'visudo' will use the text editor found in your $EDITOR variable, whether it's vi, vim, emacs, nano or gedit. After making changes to the /etc/sudoers file, visudo will check for syntax errors, and notify you of them. This is better than 'vi /etc/sudoers', because of this capability. Rule #1 of system administration- if there is a tool that exists for editing config files, use the tool.

Given process ID print its environment variables
Same as previous but compatible with BSD/IPSO

Restart command if it dies.
works well in crontab.

Prevent non-root users from logging in
Also with optional message: $ echo "no login for you" > /etc/nologin (This doesn't affect your current X session - you're already logged in!)

Go to the Nth line of file [text editor]
This is not printing, real editing using the text editor.

Yet Another Rename (bash function)
Implementation of `rename` for systems on which I don't have access to it.

Check if network cable is plugged in and working correctly
with 'mii-tool -w eth0' you can watch the interface for changes of the link status

See system users


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: