Commands by rsimpson (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

Sort IP addresses
Sort IP address by order

Print a monthly calendar with today's date highlighted
The cal command is handy, but sometimes you want to quickly see today's date highlighted. That's why I came up with this quick command. Much like but cleaner and more succinct.

Swap a file or dir with quick resotre
This lets you replace a file or directory and quickly revert if something goes wrong. For example, the current version of a website's files are in public_html. Put a new version of the site in public_html~ and execute the command. The names are swapped. If anything goes wrong, execute it again (up arrow or !!).

Find files with root setuids settings

AWS Route53 hosted zone export
Frustrated with the manual domain migration process AWS has, I unsuccessfully tried to install cli53, route53-transfer. I instead wrote this oneliner to ease the export (which is not supported via the AWS console ATM). The output can be easily pasted into the "Import Hosted Zone" dialog in Route53. SOA/NS records are excluded since they cannot be automatically imported.

find file/dir by excluding some unwanted dirs and filesystems
Consider using this cmd when: 1. You are planning to traverse a big directory. 2. There is a subdir you don't want find to decend to. (entirely ignore) 3. You don't want find to decend to any mounted filesystems under this dir. * The -xdev flag tells find do not go to other filesystems. * -path ./junk_dir -prune is the pattern to ignore ./junk_dir entirely. * The rest is the typical search and print. To ignore multiple subdirs, you can just iterate the pattern, e.g. find . -path ./junk1 -prune -o -path ./junk2 -prune ... If you do want to include other filesystems, then remove -xdev flag. If you want to search files, then change -type d to -type f.

A DESTRUCTIVE command to render a drive unbootable
Overwrites the boot sector. Since this doesn't overwrite any data, you can usually recover by re-creating the partition table exactly the same as before you zeroed it. This can also help sometimes if you install a new drive in a Windows machine which can't read it.

Verify if ntpd is working properly
Used to verify if Network Time Protocol daemon is working properly.

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)

Umount only the NFS related to 'string'
Sometimes, you have a lot of NFS in the server and you can't or shouldn't use umount -a. Whis this command, you only umount the fs related to the 'string'

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: