A survey of the standard and high quality programs that feature in most Unix based distributions, with the GNU variants being my favourite. The bash shell is a great way of interfacing and orchestrating these beautifully crafted programs. As a starting point, I’ve listed each program offered by the GNU Core Utilities and util-linux umbrella projects; considered the de facto standard on most distributions.

Quick Reference

General

CommandWhat is does
apropos compressShow commands that relate to a keyword
man -t ascii | ps2pdf - > ascii.pdfMake a PDF of a man page
which commandFull path of command
time commandShow execution time of a given command
time catStart stopwatch, ^d to stop
cat file.txt | xclip -selection clipboardCopy to clipboard
nohup ./script.sh &Keep program running after leaving SSH session (see bash post if input needed)
timeout 20s ./script.shRun script.sh for 20 seconds only
while true; do timeout 30m ./script.sh; doneRestart a program every 30 minutes

System Information

CommandWhat is does
uname -aShow kernel version and system architecture
head -n1 /etc/issueShow name and version of distribution
cat /proc/partitionsShow all partitions registered on the system
grep MemTotal /proc/meminfoShow RAM total seen by the system
grep "model name" /proc/cpuinfoShow CPU(s) info
lspci -tvShow PCI info
lsusb -tvShow USB info
mount | column -tList mounted filesystems on the system (and align output)
grep -F capacity: /proc/acpi/battery/BAT0/infoShow state of cells in laptop battery
dmidecode -q | lessDisplay SMBIOS/DMI information
smartctl -A /dev/sda | grep Power_On_HoursHow long has this disk (system) been powered on in total
hdparm -i /dev/sdaShow info about disk sda
hdparm -tT /dev/sdaDo a read speed test on disk sda
badblocks -s /dev/sdaTest for unreadable blocks on disk sda

Directory Navigation

CommandWhat is does
cd -Go previous directory
cdGo home
(cd dir123 && pwd)Jump into a directory, run a command there, and return to origin
pushd .Put cwd on stack, so you can popd back to it

File Searching

CommandWhat is does
alias l='ls -l --color=auto'Quick listing
ls -lrtList long by date
ls -lSList long by size
ls /usr/bin | pr -T9 -W$COLUMNSPrint in 9 columns to width of terminal
find -name '*.[ch] | xargs grep -E 'foo'Search for ‘foo’ in all .c and .h files in cwd and below
find -type f -print0 | xargs -r0 grep -F 'example'Search all regular files for ’example’
find -maxdepth 1 -type f | xargs grep -F 'example'As above, but don’t recurse
find -maxdepth 1 -type d | while read dir; do echo $dir; echo somecmd; doneWash each result over multiple commands
find -type f ! -perm -444Find files not readable by all
find -type d ! -perm -111Find dirs not accessable by all
find . -size 30cBy file size (30 bytes)
find . -name "*.gz" -deleteDelete all gz files
locate -r 'file[^/]*\.txtSearch cached index for names
look <keyword>Search English dictionary with a given prefix keyword
grep --color reference /usr/share/dict/wordsHighlight occurances of regex against English dictionary
readlink -f file.txtFull path of file
namei -l /bin/bashDrills through directories and links showing permission mask all the way down

Archiving and Compression

CommandWhat is does
gpg -c fileEncrypt file
gpg file.gpgDecrypt file
tar -c dir/ | bzip2 > dir.tar.bz2Make compressed archive of dir
bzip2 -dc dir.tar.bz2 | tar -xExtract archive
tar -c dir/ | gzip | gpg -c | ssh user@remote ‘dd of=dir.tar.gz.gpg’Make encrypted archive of dir on remote machine
find dir/ -name ‘*.txt’ | tar -c –files-from=- | bzip2 > dir_txt.tar.bz2Make archive of subset of dir and below
find dir/ -name ‘*.txt’ | xargs cp -a –target-directory=dir_txt/ –parentsMake copy of subset of dir and below
( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p )Copy (with permissions) copy/ dir to /where/to/ dir
( cd /dir/to/copy && tar -c . ) | ( cd /where/to/ && tar -x -p )Copy (with permissions) contents of copy/ dir to /where/to/
( tar -c /dir/to/copy ) | ssh -C user@remote ‘cd /where/to/ && tar -x -p’Copy (with permissions) copy/ dir to remote:/where/to/ dir
dd bs=1M if=/dev/sda | gzip | ssh user@remote ‘dd of=sda.gz’Backup harddisk to remote machine

Networking

CommandWhat is does
ethtool eth0Show status of ethernet interface eth0
ethtool --change eth0 autoneg off speed 100 duplex fullManually set ethernet interface speed
iw dev wlan0 linkShow link status of wireless interface wlan0
iw dev wlan0 set bitrates legacy-2.4 1Manually set wireless interface speed
iw dev wlan0 scanList wireless networks in range
ip link showList network interfaces
ip link set dev eth0 name wanRename interface eth0 to wan
ip link set dev eth0 upBring interface eth0 up (or down)
ip addr showList addresses for interfaces
ip addr add 1.2.3.4/24 brd + dev eth0Add (or del) ip and mask (255.255.255.0)
ip route showList routing table
ip route add default via 1.2.3.254Set default gateway to 1.2.3.254
ss -tuplList internet services on a system
ss -tupList active connections to/from system
host bencode.netLookup DNS ip address for name or vice versa
hostname -iLookup local ip address (equivalent to host hostname)
whois bencode.netLookup whois info for hostname or ip address
mtr google.comNice trace route

Text Manipulation

CommandWhat is does
sed 's/string1/string2/g'Replace string1 with string2
sed 's/\(.*\)1/\12/g'Modify anystring1 to anystring2
sed '/^ *#/d; /^ *$/d'Remove comments and blank lines
sed ':a; /\\$/N; s/\\\n//; ta'Concatenate lines with trailing \
sed 's/[ \t]*$//'Remove trailing spaces from lines
seq 10 | sed "s/^/ /; s/ *\(.\{7,\}\)/\1/"Right align numbers
seq 10 | sed p | paste - -Duplicate a column
sed -n '1000{p;q}'Print 1000th line
sed -n '10,20p;20q'Print lines 10 to 20
sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q'Extract title from HTML web page
sed -i 42d ~/.ssh/known_hostsDelete a particular line
sort -t. -k1,1n -k2,2n -k3,3n -k4,4nSort IPV4 ip addresses
echo 'Test' | tr '[:lower:]' '[:upper:]'Case conversion
tr -dc '[:print:]' < /dev/urandomFilter non printable characters
tr -s '[:blank:]' '\t' </proc/diskstats | cut -f4cut fields separated by blanks
history | wc -lCount lines
seq 10 | paste -s -d ' 'Concatenate and separate line items to a single line
sort -u file1 file2Union of unsorted files
sort file1 file2 | uniq -dIntersection of unsorted files
sort file1 file1 file2 | uniq -uDifference of unsorted files
sort file1 file2 | uniq -uSymmetric Difference of unsorted files
join -t'\0' -a1 -a2 file1 file2Union of sorted files
join -t'\0' file1 file2Intersection of sorted files
join -t'\0' -v2 file1 file2Difference of sorted files
join -t'\0' -v1 -v2 file1 file2Symmetric Difference of sorted files
shuf file1Randomise lines in a file
comm file1 file2Combine lines from two sorted files

Set Operations

CommandWhat is does
sort -u file1 file2Union of unsorted files
sort file1 file2 | uniq -dIntersection of unsorted files
sort file1 file1 file2 | uniq -uDifference of unsorted files
sort file1 file2 | uniq -uSymmetric Difference of unsorted files
join -t'\0' -a1 -a2 file1 file2Union of sorted files
join -t'\0' file1 file2Intersection of sorted files
join -t'\0' -v2 file1 file2Difference of sorted files
join -t'\0' -v1 -v2 file1 file2Symmetric Difference of sorted files

Windows Networking

CommandWhat is does
smbtreeFind windows machines. See also findsmb
nmblookup -A 1.2.3.4Find the windows (netbios) name associated with ip address
smbclient -L windows_boxList shares on windows machine or samba server
mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/shareMount a windows share
echo 'message' | smbclient -M windows_boxSend popup to windows machine

Monitoring and Debugging

CommandWhat is does
tail -f /var/log/messagesMonitor messages in a log file
strace -c ls >/dev/nullSummarise/profile system calls made by command
strace -f -e open ls >/dev/nullList system calls made by command
strace -f -e trace=write -e write=1,2 ls >/dev/nullMonitor what’s written to stdout and stderr
ltrace -f -e getenv ls >/dev/nullList library calls made by command
lsof -p $$List paths that process id has open
lsof ~List processes that have specified path open
tcpdump not port 22Show network traffic except ssh. See also tcpdump_not_me
ps -e -o pid,args --forestList processes in a hierarchy
ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'List processes by % cpu usage
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNSList processes by mem (KB) usage. See also ps_mem.py
ps -C firefox-bin -L -o pid,tid,pcpu,stateList all threads for a particular process
ps -p 1,$$ -o etime=List elapsed wall time for particular process IDs
watch -n.1 pstree -Uacp $$Display a changing process subtree
last rebootShow system reboot history
free -mShow amount of (remaining) RAM (-m displays in MB)
watch -n.1 'cat /proc/interrupts'Watch changeable data continuously
udevadm monitorMonitor udev events to help configure rules
ulimit -Sv 1000Limit memory usage for following commands to 1MiB
fuser -k 8000/tcpKill the program using port 8000
lsof -p 123,789 -u 1234,abeAll files used by PID 123 or 789, or by user abe or UID 1234
kill -HUP $(lsof -t /home/foo/file)SIGHUP the processes using /home/foo/file
cat /dev/urandom | base64 | pv -lbri2 > /dev/nullMonitor progress of output

Disk Space

CommandWhat is does
ls -lSrShow files by size, biggest last
du -s * | sort -k1,1rn | headShow top disk uses in current dir
du -hs /home/* | sort -k1,1hSort paths by easy to interpret disk usage
df -hShow free space on mounted filesystems
df -iShow free inodes on mounted filesystems
fdisk -lShow disks partitions sizes and types (run as root)
rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1nList all packages by installed size (Bytes) on rpm distros
dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1nList all packages by installed size (KBytes) on deb distros
dd bs=1 seek=2TB if=/dev/null of=ext3.testCreate a large test file (taking no space)
> filetruncate data of file or create an empty file

CD/DVD

CommandWhat is does
gzip < /dev/cdrom > cdrom.iso.gzSave copy of data cdrom
mkisofs -V LABEL -r dir | gzip > cdrom.iso.gzCreate cdrom image from contents of dir
mount -o loop cdrom.iso /mnt/dirMount the cdrom image at /mnt/dir (read only)
wodim dev=/dev/cdrom blank=fastClear a CDRW
gzip -dc cdrom.iso.gz | wodim -tao dev=/dev/cdrom -v -data -Burn cdrom image
cdparanoia -BRip audio tracks from CD to wav files in current dir
wodim -v dev=/dev/sr0 -audio -pad *.wavMake audio CD from all wavs in current dir
oggenc --tracknum=$track track.cdda.wav -o track.oggMake ogg file from wav file
for i in *.mp3; do mpg123 --rate 44100 --stereo --buffer 3072 --resync -w "$(basename $i .mp3).wav" $i; doneDecode mp3 files to 16-bit, stereo, 44.1 kHz waves
for i in *.mp3; do lame --decode $i ``basename $i .mp3``.wav; doneDecode mp3 files to 16-bit, stereo, 44.1 kHz waves
normalize -m *.wavNormalise levels in wavs, mix mode is loud as possible

Locales

CommandWhat is does
printf "%'d\n" 1234Print number with thousands grouping appropriate to locale
BLOCK_SIZE=\'1 ls -lUse locale thousands grouping in ls. See also l
echo "I live in$(locale territory)"Extract info from locale database
LANG=en_IE.utf8 locale int_prefixLookup locale info for specific country. See also ccodes
locale -kc $(locale | sed -n 's/\(LC_.\{4,\}\)=.*/\1/p') | lessList fields available in locale database

Dates and Times

CommandWhat is does
cal -3Display a calendar
cal 9 1752Display a calendar for a particular month year
date -d friWhat date is it this friday
[ $(date -d '12:00 today +1 day' +%d) = '01' ] || exitexit a script unless it’s the last day of the month
date --date='25 Dec' +%AWhat day does xmas fall on, this year
date --date='@2147483647'Convert seconds since the epoch (1970-01-01 UTC) to date
TZ='America/Los_Angeles' dateWhat time is it on west coast of US (use tzselect to find TZ)
date --date='TZ="America/Los_Angeles" 09:00 next Fri'What’s the local time for 9AM next Friday on west coast US

Images

Most of these rely on the imagemagick cli programs.

identify foo.jpg | Show meta including resolution

Finding Documentation

Manual Pages

The infamous manual (man) page documentation system. Man pages are organised by the following sections:

SectionNameDescription
1User commands (Programs)Commands that can be executed by the user from within a shell.
2System callsFunctions which wrap operations performed by the kernel.
3Library callsLibrary functions excluding the system call wrappers (Most of the libc functions).
4Special files (devices)Files found in /dev which allow to access to devices through the kernel.
5File formats and configuration filesVarious human-readable file formats and configuration files.
6GamesGames and funny little programs available on the system.
7Overview, conventions, and miscellaneousVarious topics, conventions and protocols, character set standards, the standard filesystem layout, etc.
8System management commandsCommands like mount(8), many of which only root can execute.

An explicit section can be requested. For the man page relating to the file format of /etc/passwd

man 5 passwd

The -k switch is great for searching across man’s treasure chest of documentation. For example, say you want to set the system time, but have no idea what program to use to achieve this. Use the -k switch to scan documentation for time.

$ man -k time
ac (1)               - print statistics about users connect time
adjtime (3)          - correct the time to synchronize the system clock
adjtimex (2)         - tune kernel clock
after (n)            - Execute a command after a time delay
aio_suspend (3)      - wait for asynchronous I/O operation or timeout
asctime (3)          - transform date and time to broken-down time or ASCII
asctime (3p)         - convert date and time to a string

The lions share of search results seems to come from section 2 and 3 (C kernel and library calls). Focusing on the task at hand, administering the system time, lets filter results to man sections 1 (user commands) and 8 (system management commands).

$ man -k time | grep -Pe '.*\([1,8]\).*'
ac (1)               - print statistics about users connect time
booleans (8)         - Policy booleans enable runtime customization of SELinux policy
ccrewrite (1)        - Rewrite CLR assemblies for runtime code contract verification.
chrt (1)             - manipulate the real-time attributes of a process
date (1)             - print or set the system date and time
dnssec-settime (8)   - Set the key timing metadata for a DNSSEC key
jack_showtime (1)    - The JACK Audio Connection Kit example client

The date program looks perfect.

Appropriate Commands

Basically an equivalent to the man -k switch for searching.

$ apropos clock
adjtime (3)          - correct the time to synchronize the system clock
adjtimex (2)         - tune kernel clock
alarm (2)            - set an alarm clock for delivery of a signal
clock (3)            - determine processor time

whatis

For a very brief overview of a man page matching a keyword.

$ whatis vim
vim (1)              - Vi IMproved, a programmers text editor

GNU Info Entry

A purpose built documentation system from GNU, info features hyperlinks (prefixed with *), aimed at dealing with larger documentation sets than man.

info goes against the grain in terms of keyboard navigation. Its odd. Page up, page down, enter to follow a link, and l to go back,

Some keys for driving info:

  • n next node
  • p previous node
  • u parent node
  • t top node
  • home end pgup pgdn scroll content
  • l go back
  • q quit
  • H keyboard shortcuts cheatsheet

Searching info:

$ info --apropos=tee
"(coreutils)tee invocation" -- tee
"(libc)Control Functions" -- feupdateenv
"(gawk)Tee Program" -- 'tee' utility

And then info gawk tee for example to pull up the third result.

/usr/share/doc Documentation

A gold mine of documents and sample configuration files. Usually for distributions that are not considered core, and don’t offer man or info pages.

RPM bundled documentation

$ rpm -qd tmux
/usr/share/doc/tmux/CHANGES
/usr/share/doc/tmux/FAQ
/usr/share/doc/tmux/TODO
/usr/share/man/man1/tmux.1.gz

Examples

grep

grep prints lines that contain a match for a pattern.

Useful modes:

  • -r or -R for recursive
  • -n show line number
  • -w match the whole word
  • -v invert match (i.e. blacklist)
  • -l just give the file name of matching files
  • -i case insensative
  • -P Perl style regular expressions

Recursively search all files from the current directory, containing Romero, including the line number where they are found:

{% highlight bash %} $ grep -rnw . -e ‘Romero’ Binary file ./datatsudio/.metadata/.plugins/seg0/c530.dat matches ./files/diff/heros_new:4:Romero,John,671028 ./files/heros:7:Romero,John,671028 {% endhighlight %}

The --include and --exclude are very useful for filtering target files, and the amount of work grep needs to do. Exclude *.dat binary files from the above example:

{% highlight bash %} $ grep -rnw . -e ‘Romero’ –exclude ‘*.dat’ ./grep/diff/heros_new:4:Romero,John,671028 ./grep/heros:7:Romero,John,671028 {% endhighlight %}

Perl patterns:

{% highlight bash %} $ echo “2016-10-13” | grep -Pe ‘\d{4}-\d{2}-\d{2}’ 2016-10-13 {% endhighlight %}

Color highlight numeric 0 to 5:

{% highlight bash %} $ echo “2016-10-13” | grep –color ‘[0-5]’ 2016-10-13 {% endhighlight %}

Overall total of how many times an expression matches:

{% highlight bash %} $ grep -rnwo . –include *.bash –include *.sh -e ‘BASH_REMATCH’ | wc -l 12 {% endhighlight %}

cut

Removes portions from each line of input. By default will use standard input, when no FILE specified, or when FILE is -.

Select the first field for the colon delimitered file /etc/passwd.

$ cut -d : -f 1 /etc/passwd
LocalService
NetworkService
Guest
SYSTEM

Hack just the date portion (chars 1-10) off the front of logs, and show the unique dates:

$ cut -c1-10 dircdds.log | grep -Pe '\d{4}-\d{2}-\d{2}' | sort -h | uniq
2016-03-21
2016-03-22
2016-03-24
2016-03-29
2016-04-21

sort

By default will sort in dictionary order.

$ cut -d : -f 3 /etc/passwd | sort
0
1
1000
1001
107
11
113
12

Useful sort modes:

  • -h human numeric (e.g. 2K 3G)
  • -n numeric
  • -r reverse
  • -R random
  • -u unique

tr

For translating (e.g. uppercasing, stripping, truncating, etc) text.

Convert lower case characters to upper.

$ echo "Linus Torvalds" | tr [:lower:] [:upper:]
LINUS TORVALDS

Make all lower case characters o:

$ echo "Linus Torvalds" | tr [:lower:] o
Loooo Tooooooo

Replace the range of characters a to o, with @:

$ echo "Linus Torvalds" | tr a-o @
L@@us T@rv@@@s

wc

Count aggregates of the contents of a file.

By default will show counts of lines, words and bytes.

$ wc pthreads.make
7  29 252 pthreads.make

Useful counts:

  • -l, --lines newlines
  • -w, --words words
  • -c, --bytes bytes
  • -m, --chars characters

Just show the number of lines:

$ wc -l pthreads.make
7  pthreads.make

Pipe support just works:

$ cat 2016-05-01-bash.markdown | wc -l
1100

tar

The rock solid archiving tool that you can always lean on.

Create an archive of all of the /etc directory:

tar -cvf etcy.tar /etc 2> /dev/null
  • -c create mode
  • -v verbose list each file that gets processed
  • -f the tar file being delt with

Same, with compression:

tar -czf etcy.tar.gz /etc 2> /dev/null
  • -z (gzip) or -j (bzip2) compression

Example compression sizes:

 28M etcy.tar
4.4M etcy.tar.bz2
5.6M etcy.tar.gz

Whats in this tarball? -t or --list has answers:

tar -tf etcy.tar
etc/
etc/idmapd.conf
etc/openldap/
etc/openldap/ldap.conf
...

Unpack the entire tar:

tar -xf etcy.tar

Unpack specific things:

tar -xf etcy.tar etc/openldap/ldap.conf

Results in:

.
├── etc
│   └── openldap
│       └── ldap.conf
├── etcy.tar
├── etcy.tar.bz2
└── etcy.tar.gz

rsync

The smart file copier; only transfers blocks that are needed, on the fly compression.

In its simplist form, copy a file locally:

rsync etcy.tar /mnt/sdd5/backups/

Some optional switches:

  • -v verbose
  • -h human friendly (29,242,419 bytes becomes 29.24M)
  • --progress show progress during transfer
  • -z compression

Put a file onto a remote server:

rsync etcy.tar iris.local:/home/ben/
  • -a archive mode for presevation of symlinks, devices, attributes, permissions.
  • -u update mode, skips files that are newer on the target
  • -b backup
  • -e remote shell to use (e.g. -e ssh)
  • --delete remove files/dirs in the destination, that arent in the source

Complete example:

rsync --progress -avhe ssh Fedora* schnerg@192.168.1.111:/raid1/sdd1/Software/Big/Linux/Fedora

Only get diffs, do multiple times for dodgy downloads:

rsync -P rsync://rsync.server.com/path/to/file file

Restrict flow rate:

rsync --bwlimit=1m fromfile tofile

Mirror web site (with compression and encryption):

rsync -az -e ssh --delete ~/public_html/ remote.com:'~/public_html'

Synchronise current dir with remote dir:

rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/

sed

For more, see my post on [sed]({% post_url 2015-09-15-sed %}).

awk

Given a longform (-l) list of files and directories, filter only those starting with “pki” and ending with “.jar”, outputting only the shortname.

$ ls -l | awk 'match($10, /^pki.*\.jar$/) { print $10 }'
pki_jcsi_2.1.2.jar
pki_jcsi_base_2.1.2.jar
pki_jcsi_provider_2.1.2.jar
pki_jcsi_smime_2.1.6.jar

For a deeper survey of awk see my [post]({% post_url 2016-01-17-awk %}).

ssh (Secure Shell)

ssh $USER@$HOST command | Run command on $HOST as $USER ssh -f -Y $USER@$HOSTNAME xeyes| Run GUI command on $HOSTNAME as $USERscp -p -r $USER@$HOST: file dir/| Copy with permissions to $USER’s home directory on $HOSTscp -c arcfour $USER@$LANHOST: bigfile| Use faster crypto for local LANssh -g -L 8080:localhost:80 root@$HOST | Forward connections to $HOSTNAME:8080 out to $HOST:80 ssh -R 1434:imap:143 root@$HOST| Forward connections from $HOST:1434 in to imap:143ssh-copy-id $USER@$HOST | Install public key for $USER@$HOST for password-less log in

wget

Download local browsable verison of a webpage:

(cd dir/ && wget -nd -pHEKk http://www.bencode.net)

Continue downloading a partial download:

wget -c http://www.site.org/large.iso

Download specific types (e.g. png) of files:

wget -r -nd -np -l1 -A '*.png' http://www.slashgot.org

Pipe and process output:

wget -q -O- http://www.slashdot.org | grep 'a href' | head

Update a local copy of a site:

wget --mirror http://www.slashdot.org

Schedule a download in the future:

echo 'wget http://www.lobste.rs' | at 21:00

BFL of Common Programs

An overview of common programs that generally exist on nix based systems.

CommandDescription
addparttell the kernel about the existence of a partition
agettyalternative Linux getty
archprint machine hardware name
awkpattern scanning and processing language
base32base32 encode/decode data and print to standard output
base64base64 encode/decode data and print to standard output
basenamestrip directory and suffix from filenames
blkdiscarddiscard sectors on a device
blkidlocate/print block device attributes
blockdevcall block device ioctls from the command line
caldisplay a calendar
catconcatenate files and print on the standard output
cfdiskdisplay or manipulate a disk partition table
chconchange file SELinux security context
chcpuconfigure CPUs
chfnchange your finger information
chgrpchange group ownership
chmodchange file mode bits
chownchange file owner and group
chrootrun command or interactive shell with special root directory
chrtmanipulate the real-time attributes of a process
chshchange your login shell
cksumchecksum and count the bytes in a file
colfilter reverse line feeds from input
colcrtfilter nroff output for CRT previewing
colrmremove columns from a file
columncolumnate lists
commcompare two sorted files line by line
cpcopy files and directories
csplitsplit a file into sections determined by context lines
ctrlaltdelset the function of the Ctrl-Alt-Del combination
cutremove sections from each line of files
dateprint or set the system date and time
ddconvert and copy a file
delparttell the kernel to forget about a partition
dfreport file system disk space usage
dirlist directory contents
dircolorscolor setup for ls
dirnamestrip last component from file name
dmesgprint or control the kernel ring buffer
duestimate file space usage
echodisplay a line of text
ejecteject removable media
envrun a program in a modified environment
expandconvert tabs to spaces
exprevaluate expressions
factorfactor numbers
fallocatepreallocate or deallocate space to a file
falsedo nothing, unsuccessfully
fdformatlow-level format a floppy disk
fdiskmanipulate disk partition table
findfsfind a filesystem by label or UUID
findmntfind a filesystem
flockmanage locks from shell scripts
fmtsimple optimal text formatter
foldwrap each input line to fit in specified width
fsckcheck and repair a Linux filesystem
fsck.cramfsfsck compressed ROM file system
fsck.minixcheck consistency of Minix filesystem
fsfreezesuspend access to a filesystem (Ext3/4, ReiserFS, JFS, XFS)
fstrimdiscard unused blocks on a mounted filesystem
fuseridentify processes using files or sockets
getoptparse command options (enhanced)
grepprint lines matching a pattern
groupsprint the groups a user is in
headoutput the first part of files
hexdumpdisplay file contents in hexadecimal, decimal, octal, or ascii
hostidprint the numeric identifier for the current host
hostnameshow or set the system’s host name
hwclockread or set the hardware clock (RTC)
idprint real and effective user and group IDs
installcopy files and set attributes
ioniceset or get process I/O scheduling class and priority
ipcmkmake various IPC resources
ipcrmremove certain IPC resources
ipcsshow information on IPC facilities
isosizeoutput the length of an iso9660 filesystem
joinjoin lines of two files on a common field
killterminate a process
killterminate a process
lastshow a listing of last logged in users
ldattachattach a line discipline to a serial line
lineTODO
linkcall the link function to create a link to a file
lnmake links between files
loggerenter messages into the system log
loginbegin session on the system
lognameprint user’s login name
lookdisplay lines beginning with a given string
losetupset up and control loop devices
lslist directory contents
lsblklist block devices
lscpudisplay information about the CPU architecture
lslockslist local system locks
lsloginsdisplay information about known users in the system
lsoflist open files
mcookiegenerate magic cookies for xauth
md5sumcompute and check MD5 message digest
mesgdisplay (or do not display) messages from other users
mkdirmake directories
mkfifomake FIFOs (named pipes)
mkfsbuild a Linux filesystem
mkfs.bfsmake an SCO bfs filesystem
mkfs.cramfsmake compressed ROM file system
mkfs.minixmake a Minix filesystem
mknodmake block or character special files
mkswapset up a Linux swap area
mktempcreate a temporary file or directory
morefile perusal filter for crt viewing
mountmount a filesystem
mountpointsee if a directory or file is a mountpoint
mvmove (rename) files
nameifollow a pathname until a terminal point is found
newgrplog in to a new group
nicerun a program with modified scheduling priority
nlnumber lines of files
nohuprun a command immune to hangups, with output to a non-tty
nologinpolitely refuse a login
nprocprint the number of processing units available
nsenterrun program with namespaces of other processes
numfmtConvert numbers from/to human-readable strings
oddump files in octal and other formats
partxtell the kernel about the presence and numbering of on-disk partitions
pastemerge lines of files
pathchkcheck whether file names are valid or portable
pgis a pager, allows viewing one page at a time
pivot_rootchange the root filesystem
prconvert text files for printing
printenvprint all or part of environment
printfformat and print data
prlimitget and set process resource limits
psreport a snapshot of the current processes
ptxproduce a permuted index of file contents
pwdprint name of current/working directory
rawbind a Linux raw character device
readlinkprint resolved symbolic links or canonical file names
readprofileread kernel profiling information
realpathprint the resolved path
renamerename files
renicealter priority of running processes
resetterminal initialization
resizeparttell the kernel about the new size of a partition
revreverse lines characterwise
rmremove files or directories
rmdirremove empty directories
runconrun command with specified SELinux security context
runuserrun a command with substitute user and group ID
scriptmake typescript of terminal session
scriptreplayplay back typescripts, using timing information
sedstream editor for filtering and transforming text
seqprint a sequence of numbers
setarchchange reported architecture in new program environment and set personality flags
setprivrun a program with different Linux privilege settings
setsidrun a program in a new session
settermset terminal attributes
sfdiskdisplay or manipulate a disk partition table
sha1sumcompute and check SHA1 message digest
sha2message digests
shredoverwrite a file to hide its contents, and optionally delete it
shufgenerate random permutations
sleepdelay for a specified amount of time
sortsort lines of text files
splitsplit a file into pieces
statdisplay file or file system status
stdbufRun COMMAND, with modified buffering operations for its standard streams.
sttychange and print terminal line settings
surun a command with substitute user and group ID
suloginsingle-user login
sumchecksum and count the blocks in a file
swaplabelprint or change the label or UUID of a swap area
swapoffenable/disable devices and files for paging and swapping
swaponenable/disable devices and files for paging and swapping
switch_rootswitch to another filesystem as the root of the mount tree
syncSynchronize cached writes to persistent storage
tacconcatenate and print files in reverse
tailoutput the last part of files
tailffollow the growth of a log file
tasksetset or retrieve a process’s CPU affinity
tcpdumpdump traffic on a network
teeread from standard input and write to standard output and files
testcheck file types and compare values
timeoutrun a command with a time limit
touchchange file timestamps
trtranslate or delete characters
truedo nothing, successfully
truncateshrink or extend the size of a file to the specified size
tsortperform topological sort
ttyprint the file name of the terminal connected to standard input
tunelpset various parameters for the lp (printer) device
uldo underlining
umountunmount file systems
unameprint system information
unexpandconvert spaces to tabs
uniqreport or omit repeated lines
unlinkcall the unlink function to remove the specified file
unsharerun program with some namespaces unshared from parent
uptimeTell how long the system has been running.
usersprint the user names of users currently logged in to the current host
utmpdumpdump UTMP and WTMP files in raw format
uuidgencreate a new UUID value
vdirlist directory contents
vipwedit the password, group, shadow-password or shadow-group file
wShow who is logged on and what they are doing.
wallwrite a message to all users
wcprint newline, word, and byte counts for each file
wdctlshow hardware watchdog status
whereislocate the binary, source, and manual page files for a command
whoshow who is logged on
whoamiprint effective userid
wipefswipe a signature from a device
writewrite to another user
yesoutput a string repeatedly until killed

Resources