This is a list of useful command line tools which I often use during my day. For every tool I have listed a example with the parameters and the output of the tool.
Example:
$ toolname --option=value --other-option Output of toolname when run on my machine. This might not be identical on your installation.
With apropos you can search all man entries of programs. With this you can find programs which do things related to a keyword like “cdrom” or “file”.
Example:
$ apropos font pamtompfont(1) - see http://netpbm.sourceforge.net/doc/pamtompfont.html ppmdcfont(1) - see http://netpbm.sourceforge.net/doc/ppmdcfont.html ppmddumpfont(1) - see http://netpbm.sourceforge.net/doc/ppmddumpfont.html ppmdmkfont(1) - see http://netpbm.sourceforge.net/doc/ppmdmkfont.html addftinfo(1) - add information to troff font files for use with groff afmtodit(1) - create font files for use with groff -Tps atsutil(8) - font registration system utility font(ntcl) - Create and inspect fonts fontd(8) - Mac OS X system font registration manager fontmover(8) - Mac OS X system font mover fontrestore(8) - Restore the available system fonts to a pristine state, if possible fontworker(8) - Mac OS X system font registration and validation daemon groff_font(5) - format of groff device and font description files hpftodit(1) - create font description files for use with groff -Tlj4 lj4_font(5) - groff fonts for use with devlj4 pfbtops(1) - translate a PostScript font in .pfb format to ASCII tfmtodit(1) - create font files for use with groff -Tdvi
Whois is a command to get the information about domains and their users, like the nameserver or technical contact.
Example:
$ whois robinglauser.ch whois: This information is subject to an Acceptable Use Policy. See http://www.nic.ch/terms/aup.html Domain name: robinglauser.ch Holder of domain name: Robin Glauser Niesenstrasse 26C CH-3600 Thun Switzerland Contractual Language: German Technical contact: cyon GmbH David Burkardt Aeschengraben 6 CH-4051 Basel Switzerland Registrar: cyon GmbH First registration date: 2014-07-23 DNSSEC:N Name servers: derek.ns.cloudflare.com ivy.ns.cloudflare.com
With curl you can create http requests and print the response to the standard output.
Example (Output shortened):
$ curl https://www.robinglauser.ch <!DOCTYPE html><meta charset="utf-8"><title>Robin Glauser | Portfolio</title><meta name="description" content="My portfolio"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" type="image/x-icon" href="../favicon.ico"><link rel="shortcut icon" type="image/x-icon" href="../favicon.ico"><style>*,:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.jumbotron{padding:30px;margin-bottom:30px;background:#2c3e50;color:#fff;text-align:center}img{border:0;vertical-align:middle}.jumbotron{padding-top:48px;padding-bottom:48px}@media screen and (min-width:768px){.jumbotron{padding:48px 0}}body{font-family:"Source Sans Pro",Candara,Arial,sans-serif;....
With the uptime command you can see how long your machine has been running.
Example:
$ uptime 12:46 up 1 day, 9 mins, 3 users, load averages: 1,87 1,86 1,86
Ps is a command to list and filter all processes running on your machine. By default it only lists the processes running in your current shell.
Example without any arguments:
$ ps PID TTY TIME CMD 2091 ttys000 0:00.01 -bash
If you provide the argument -e all processes will be listed.
Example with argument -e (Output shortened):
$ ps -e PID TTY TIME CMD 1 ?? 0:59.60 /sbin/launchd 42 ?? 0:10.80 /usr/libexec/UserEventAgent (System) 43 ?? 0:20.07 /usr/sbin/syslogd 45 ?? 0:11.36 /usr/libexec/kextd 46 ?? 0:19.04 /System/Library/Frameworks/CoreServices.framework/Vers 50 ?? 0:00.46 /System/Library/CoreServices/appleeventsd --server 51 ?? 0:06.37 /usr/libexec/configd 52 ?? 0:02.25 /System/Library/CoreServices/powerd.bundle/powerd ...
With ln you can create symbolic and hard links between files or directories. The difference between the two is that symbolic links work over multiple partitions and has its own Inode. A hard link instead points to the same Inode as the referenced file.
Just remember to first provide the file or directory which already exists and then the new file for the link. In most cases a symbolic link is what you want.
Example for creating a symbolic link:
$ ln -s existing_file linked_file
Example for creating a hard link:
$ ln existing_file linked_file
Ping is one of the more simple commands in this list. It will “ping” the host you’ve provided as the first argument by sending (ICMP) echo request packets to it.
The command will run until you stop it with the key-combination (Ctrl+C). It the displays a statistic about how many packets were lost and how long it took for the packets for the round-trip.
Example:
$ ping google.com PING google.com (193.135.3.99): 56 data bytes 64 bytes from 193.135.3.99: icmp_seq=0 ttl=58 time=7.591 ms 64 bytes from 193.135.3.99: icmp_seq=1 ttl=58 time=7.867 ms 64 bytes from 193.135.3.99: icmp_seq=2 ttl=58 time=7.879 ms 64 bytes from 193.135.3.99: icmp_seq=3 ttl=58 time=7.569 ms ^C --- google.com ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 7.569/7.726/7.879/0.147 ms
Wget is similar to curl, but instead of printing the response of the web-server it saves it to your hard-drive. It also has options for saving a whole website locally so you can access it without a internet connection.
Example:
$ wget google.com --2015-10-02 13:08:02-- http://google.com/ Resolving google.com (google.com)... 2a00:1450:400a:806::1005, 193.135.3.104, 193.135.3.114, ... Connecting to google.com (google.com)|2a00:1450:400a:806::1005|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://www.google.ch/?gfe_rd=cr&ei=kmUOVp_KLsWX8QeUrKmQAQ [following] --2015-10-02 13:08:02-- http://www.google.ch/?gfe_rd=cr&ei=kmUOVp_KLsWX8QeUrKmQAQ Resolving www.google.ch (www.google.ch)... 2a00:1450:400a:805::101f, 193.134.255.123, 193.134.255.118, ... Connecting to www.google.ch (www.google.ch)|2a00:1450:400a:805::101f|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified
Saving to: ‘index.html’
index.html [ <=> ] 19.29K –.-KB/s in 0s
2015-10-02 13:08:02 (53.1 MB/s) – ‘index.html’ saved [19748]
Example for copying a whole website to your hard-drive:
$ wget --mirror -p --convert-links -P fly/ fly.robinio.ch --2015-10-02 13:10:44-- http://fly.robinio.ch/ Resolving fly.robinio.ch (fly.robinio.ch)... 194.126.200.41 Connecting to fly.robinio.ch (fly.robinio.ch)|194.126.200.41|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified Saving to: 'fly/fly.robinio.ch/index.html' fly.robinio.ch/index.html [ <=> ] 8.87K --.-KB/s in 0.01s Last-modified header missing -- time-stamps turned off. 2015-10-02 13:10:49 (870 KB/s) - 'fly/fly.robinio.ch/index.html' saved [9079] Loading robots.txt; please ignore errors. --2015-10-02 13:10:49-- http://fly.robinio.ch/robots.txt Connecting to fly.robinio.ch (fly.robinio.ch)|194.126.200.41|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 106
Saving to: 'fly/fly.robinio.ch/robots.txt' fly.robinio.ch/robots.txt 100%[===================================================================>] 106 --.-KB/s in 0s ..... FINISHED --2015-10-02 13:10:51-- Total wall clock time: 6.9s Downloaded: 17 files, 878K in 0.4s (2.26 MB/s) Converting fly/fly.robinio.ch/index.html... 13-2 Converting fly/fly.robinio.ch/FAQ... 12-1 Converting fly/fly.robinio.ch/About... 9-1 Converting fly/fly.robinio.ch/css/compiled/main.css... 5-1 Converted 4 files in 0.004 seconds.
With tree you can show the structure of a directory as a ascii-tree.
Example:
$ tree . ├── About ├── FAQ ├── bundles │ └── fly │ ├── assets │ │ ├── ack.png │ │ ├── filezilla.png │ │ ├── firefox.png │ │ └── vim.png │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.eot? │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── img │ │ └── favicon.ico │ └── js │ └── vendor │ └── modernizr-2.6.2-respond-1.1.0.min.js ├── css │ └── compiled │ └── main.css ├── index.html ├── js │ └── compiled │ └── main.js └── robots.txt 11 directories, 17 files
With fallocate you can quickly create dummy files with a given size for testing.
Example:
$ fallocate -l 100M dummy_file
Wc displays the lines, words, and bytes of a given input file.
Example:
$ wc index.html 7 428 19748 index.html
With the finger command you can find out which users are logged in at the moment.
Example:
$ finger Login Name TTY Idle Login Time Office Phone robin Robin Glauser *con 1d Do 12:37 robin Robin Glauser s00 Fr 13:16
Subscribe to get the latest posts sent to your email.