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

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Create a continuous digital clock in Linux terminal
Source: http://www.my-guides.net/en/guides/linux/364-how-to-create-a-continuous-digital-clock-in-linux-terminal

print a file on a single line
Example: you have a package.txt you want to install on a system. Instead of this: cat package.txt package1 package2 package3 You want it to cat out on one line so you can print "yum install package1 package2 package3"

Move cursor to end of line

Create a html of information about you harddisk
www.fir3net.com

Run the last command as root
Same as `sudo !!`. If you do not have permission to be sudo or sudo does not installed on your system, you can use this.

MySQL: Slice out a specific table from the output of mysqldump
Only filters the statement related to a specific table ('departments', in the example), from the output of mysqldump

Resume scp of a big file
It can resume a failed secure copy ( usefull when you transfer big files like db dumps through vpn ) using rsync. It requires rsync installed in both hosts. rsync --partial --progress --rsh=ssh $file_source $user@$host:$destination_file local -> remote or rsync --partial --progress --rsh=ssh $user@$host:$remote_file $destination_file remote -> local

easily find megabyte eating files or directories
sorts the files by integer megabytes, which should be enough to (interactively) find the space wasters. Now you can $ dush for the above output, $ dush -n 3 for only the 3 biggest files and so on. It's always a good idea to have this line in your .profile or .bashrc

Print every Nth line (to a maximum)
Thanks to knoppix5 for the idea :-) Print selected lines from a file or the output of a command. Usage: $ every NTH MAX [FILE] Print every NTH line (from the first MAX lines) of FILE. If FILE is omitted, stdin is used. The command simply passes the input to a sed script: $ sed -n -e "${2}q" -e "0~${1}p" ${3:-/dev/stdin} print no output $ sed -n quit after this many lines (controlled by the second parameter) $ -e "${2}q" print every NTH line (controlled by the first parameter) $ -e "0~${1}p" take input from $3 (if it exists) otherwise use /dev/stdin ${3:-/dev/stdin}


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: