Commands by dennisw (19)

What's this? 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

check open ports without netstat or lsof

Synchronise a file from a remote server
You will be prompted for a password unless you have your public keys set-up.

Wrap text files on the command-line for easy reading
fold wraps text at 80 characters wide, and with the -s flag, only causes wrapping to occur between words rather than through them.

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"

currently mounted filesystems in nice layout
Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.

Test file system performance
You need bonnie++ package for this. More detail than a simple hdparm -t /dev/sda would give you. the -d is the directory where it performs writes/reads for example I use /tmp/scratch with 777 permissions Bonnie++ benchmarks three things: data read and write speed, number of seeks that can be performed per second, and number of file metadata operations that can be performed per second.

doing some floating point math

display systemd log entries for sshd using "no-pager" (a bit like in pre-systemd: grep sshd /var/log/messages)
In pre-systemd systems, something like: "# grep sshd /var/log/messages" would display log events in /var/log/messages containing "sshd". # journalctl -u sshd --no-pager The above command displays similar results for systemd systems. (Note that this needs to be run with root permissions to access the log data.)

Reset hosed terminal,
stty sane resets the tty to basic usable function. The ^J is a newline -- sometimes CR/LF interpretation is broken so use the ^J explicitly.

Change every instance of OLD to NEW in file FILE
Very quick way to change a word in a file. I use it all the time to change variable names in my PHP scripts (sed -i 's/$oldvar/$newvar/g' index.php)

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.


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: