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

Merge files, joining each line in one line

HTTP Get of a web page via proxy server with login credentials
If you are behind a proxy server and have to authenticate with proxy server to browser web pages then you have to pass proxy server address and its port number along with user credentials to curl to got GET the page using curl. Example : "curl -U srikanth -x 167.85.103.70:8080 http://www.yahoo.com". In case you don't specify the password (as in the above example), curl will prompt to enter the password at the command line.

Restrict the use of dmesg for current user/session
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: $ cat /proc/sys/kernel/dmesg_restrict 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/.

Display the output of a command from the first line until the first instance of a regular expression.
Slightly simpler version of previous sed command that does the same thing. In this case, the output will stop at the command, and the entire command will be terminated as well, instead of proceeding through the whole file.

Most used command

Resume scp of a big file

Watch the progress of 'dd'
Only slightly different than previous commands. The benefit is that your "watch" should die when the dd command has completed. (Of course this would depend on /proc being available)

Rename files in batch

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Rename files to be all in CAPITALS
Simple bash/ksh/sh command to rename all files from lower to upper case. If you want to do other stuff you can change the tr command to a sed or awk... and/or change mv to cp....


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: