Commands by samc (1)

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

Batch convert files to utf-8
taken from http://blog.ofirpicazo.com/linux/batch-convert-files-to-utf-8/

check open ports without netstat or lsof

Serial console to a Vmware VM
Create a serial console with "socket (named pipe)" of "/tmp/socket", "from:server, to:virtual machine" in vmware player, etc.. gui. Run the above command after you have booted the guest OS (which should also be configured for serial console).

prevent accidents and test your command with echo
if you're using wildcards * or ? in your command, and if you're deleting, moving multiple files, it's always safe to see how those wildcards will expand. if you put "echo" in front of your command, the expanded form of your command will be printed. It's better safe than sorry.

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Set name of windows in tmux/byobu to hostnames of servers you're connected to
*I run this with byobu as as a custom status bar entry that runs every 10 seconds by putting it in a script here: $ .byobu/bin/10_update_windows There's no output to stdout, so nothing is displayed on the status bar. *Presumes that #{pane_title} is set to the hostname or prompt containing the host name. In my case, it's in this format: $ $USER@$HOSTNAME:$PWD The sed commands may need to be modified if your pane_title is different. *If you want to strip out a common part of a hostname, add the following before '| uniq' $ -e 's/[COMMON PART]//' I use that to strip out the domain of the servers I connect to, leaving the subdomain.

calculate md5 sums for every file in a directory tree
an alternative

Rapidly invoke an editor to write a long, complex, or tricky command

Insert a line at the top of a text file without sed or awk or bash loops
Just use '-' to use STDIN as an additional input to 'cat'

Delete recursively only empty folders on present dir


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: