Commands by thechile (3)

  • bit of a contrived example and playing to my OCD but nice for quick scripted output of listening ports which is sorted by port, ip address and protocol. Show Sample Output

    sudo netstat -plntu --inet | sort -t: -k2,2n | sort --stable -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | sort -s -t" " -k1,1
    thechile · 2013-08-13 09:21:26 0
  • ..not guaranteed to always be accurate but fun to see how old you Linux installation is based on the root partitions file system creation date. Show Sample Output

    sudo tune2fs -l $(df -h / |(read; awk '{print $1; exit}')) | grep -i created
    thechile · 2013-08-08 15:18:09 5
  • 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. Show Sample Output

    mount | column -t
    thechile · 2009-03-20 14:18:56 8

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

Compare two directory trees.

Search big files with long lines
This is a handy way to circumvent the "Maximum line length of 2048 exceeded" grep error. Once you have run the above command (or put it in your .bashrc), files can be searched using: $ lgrep search-string /file/to/search

Using numsum to sum a column of numbers.
numsum is part of of the num-utils package, which is available in some Linux distros and can also be downloaded at It contains about 10 different programs for dealing with numbers from the command line. Obviously you can do a lot of things that the num-utils programs do in awk, sed, bash, perl scripts, but num-utils are there so that you don't have to remember the syntax for more complex operations and can just think: compute the sum, average, boundary numbers, etc.

cleanup /tmp directory
Cleans all files in /tmp that have been accessed at least 2 days ago.

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

Get all IPs via ifconfig
works on Linux and Solaris. I think it will work on nearly all *nix-es

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Shows how many percents of all avaliable packages are installed in your gentoo system

Get Lorum Ipsum random text from
This will generate 3 paragraphs with random text. Change the 3 to any number.

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"

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: