Commands by inkel (3)

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

clone directory structure
dir1 and all its subdirs and subdirs of subdirs ... but *no files* will be copied to dir2 (not even symbolic links of files will be made). To preserve ownerships & permissions: $ cp -Rps dir1 dir2 Yes, you can do it with $ rsync -a --include '*/' --exclude '*' /path/to/source /path/to/dest too, but I didn't test if this can handle attributes correctly (experiment rsync command yourself with --dry-run switch to avoid harming your file system) You must be in the parent directory of dir1 while executing this command (place dir2 where you will), else soft links of files in dir2 will be made. I couldn't find how to avoid this "limitation" (yet). Playing with recursive unlink command loop maybe? PS. Bash will complain, but the job will be done.

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.)

Join lines
Even shorter. Stolen from comment posted by eightmillion.

Get length of current playlist in xmms2

Send an email from the terminal when job finishes
Might as well include the status code it exited with so you know right away if it failed or not.

list files recursively by size

Checks throughput between two nodes
This will show the throughput between two nodes. Thanks to szboardstretcher, who posted it here:

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 mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Remove any RPMs matching a pattern
This should be an option to rpm, but isn't. I wind up using it a lot because I always forget the full name of the packages I want to delete.

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: