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

remove ^M characters from file using sed
removing ^M characters from file with sed

Create a persistent connection to a machine
Create a persistent SSH connection to the host in the background. Combine this with settings in your ~/.ssh/config: Host host ControlPath ~/.ssh/master-%r@%h:%p ControlMaster no All the SSH connections to the machine will then go through the persisten SSH socket. This is very useful if you are using SSH to synchronize files (using rsync/sftp/cvs/svn) on a regular basis because it won't create a new socket each time to open an ssh connection.

easily strace all your apache processes
Will open strace on all apache process, on systems using sbin/apache (debian) or sbin/httpd (redhat), and will follow threads newly created.

repeat a command every one second
Short method of "while x=0; do foo ; sleep 1 ; done"

1+2-3+4-5+6-7 Series

Show the command line for a PID, converting nulls to spaces and a newline

get ip of all running docker containers
pretty self explanitory

bash function to check for something every 5 seconds
checkfor: have the shell check anything you're waiting for. 'while : ; do' is an infinite loop '$*' executes the command passed in 'sleep 5' - change for your tastes, sleep for 5 seconds bash, ksh, likely sh, maybe zsh Ctrl-c to break the loop

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Mount a temporary ram partition
Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast. Be aware that anything saved in this partition will be gone after your computer is turned off.


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: