Commands

Essential Concepts

commanduseful flags
ls-lG
df
top-d1
lpr
last
curl-o url file
whois
clear
wc-l
cd~fred
pwd
printenv
typewc cd ll
which
alias
sort
date
sethistory
tmux
sleep
man
info
exit
less

Shell Job Control

commanduseful flags
jobs&
^Zsuspend
fg%1
bg
disown

File Commands

Basic File Operations

commanddescription
lslist files in a directory
cpcopy a file
mvmove (rename) a file
rmremove (delete) a file
lncreate links (alternative names) to a file

Directory Operations

commanddescription
cdchange your current directory
pwdprint the name of your current directory
basenameprint the final part of a file path, usually the filename
dirnameprint a file path without its final part
mkdircreate (make) a directory
rmdirdelete (remove) an empty directory
rm -rdelete a nonempty directory and its contents

Viewing Files

commanddescription
catview files in their entirety
lessview text files one page at a time
nlview text files with their lines numbered
headview the first lines of a text file
tailview the last lines of a text file
stringsdisplay text that’s embedded in a binary file
odview data in octal (base 8) or other formats

Creating and Editing Files

commanddescription
nanoa simple text editor found in virtually all Linux distros
emacsa powerful text editor from the Free Software Foundation
vima powerful text editor based on Unix vi

Properties of Files

commanddescription
statdisplay attributes of files and directories
wccount bytes, words, and lines in a file
dumeasure disk usage of files and directories
fileidentify (guess) the type of a file
mimetypeidentify (guess) the MIME type of a file
touchchange timestamps of files and directories
chownchange owner of files and directories
chgrpchange group ownership of files and directories
chmodchange protection mode of files and directories
umaskset a default mode for new files and directories
lsattrlist extended attributes of files and directories
chattrchange extended attributes of files and directories

Locating Files

commanddescription
findlocate files in a directory hierarchy
xargsturn a list of files into a list of commands (and much more)
locatecreate an index of files, and search the index for a string
whichlocate executables in your search path (command)
typelocate executables in your search path (bash built-in)
whereislocate executables, documentation, and source files

Manipulating Text in Files

commanddescription
grepfind lines in a file that match a regular expression
cutextract columns from a file
pasteappend text from multiple files in columns
columnorganise text into columns
trtranslate characters into other characters
expandconvert from tabs to spaces
unexpandconvert from spaces to tabs
sortsort lines of text by various criteria
uniqlocate identical lines in a file
tacreverse a file line by line
shufrandomly shuffle the lines of a file (permutation)
teewrite to a file and print on standard output, simultaneously
awkpattern scanning and text processing language
sedstream editor for filtering and transforming text
m4macro processor for text substitution

Compressing, Packing, Encrypting

commanddescription
tarpackage multiple files into a single file
gzipcompress files with GNU Zip
gunzipuncompress GNU Zip files
bzip2compress files in BZip format
bunzip2uncompress BZip files
bzcatuncompress BZip data to standard output
compresscompress files with traditional Unix compression
uncompressuncompress files with traditional Unix compression
zcatuncompress to standard output (gzip or compress)
zippackage and compress files in Windows Zip format
unzipuncompress and unpack Windows Zip files
7zpackage and compress/uncompress 7-Zip files
munpackextract MIME data to files
mpackconvert a file to MIME format
gpgencrypt a file with the GNU Privacy Guard (GnuPG)

Comparing Files

commanddescription
diffline-by-line comparison of two files or directories
commline-by-line comparison of two sorted files
cmpbyte-by-byte comparison of two files
shasumcompute checksums of the given files
md5sumcompute checksums of the given files (insecure)

Converting Files to other formats

commanddescription
pandocconvert from one markup language to another
hxselectextract information from an HTML file
jqextract information from a JSON file
xmllintvalidate and extract information from an XML file
csvtoolextract information from a comma-separated values (CSV) file
splitsplit up a file simply into multiple files
csplitsplit up a file into multiple files using complex criteria

PDF and Postscript File Handling

commanddescription
pdftotextextract text from PDF files
ps2asciiextract text from PostScript or PDF files
pdfseparateextract individual pages from a PDF file
pdftksplit, join, rotate, and otherwise manipulate PDF files
pdf2ps, pdf2pdfconvert between PDF and PostScript file formats
ocrmypdfperform optical character recognition (OCR) on a PDF

Spellchecking

commanddescription
looklook up the spelling of a word quickly
aspellinteractive spelling checker
spellbatch spelling checker

System Administration Basics

Viewing Processes

commanddescription
pslist processes
pgreplist the IDs of processes that match a regular expression
uptimeview the system load
wlist active processes for all users
topmonitor resource-intensive processes interactively
freedisplay free memory

Controlling Processes

commanddescription
killterminate a process (or send it a signal)
pkillterminate processes by name (or send them a signal)
timeoutkill a command that runs for too long
niceinvoke a program at a particular priority
renicechange a process’s priority as it runs
nohuprun a process that continues after you log out
flockensure that only one instance of a command runs at a time

Scheduling Jobs

commanddescription
sleepwait a set number of seconds, doing nothing
watchrun a command at set intervals
atschedule a job for a single, future time
crontabschedule jobs for many future times

Logins, Logouts, and Shutdowns

commanddescription
systemctlcontrol the state of your machine and its services
shutdownshut down your local machine
rebootreboot your local machine

Users and Their Environment

commanddescription
lognameprint your login name
whoamiprint your current, effective username
idprint the user ID and group membership of a user
wholist logged-in users, long output
userslist logged-in users, short output
ttyprint your terminal device name
lastdetermine when someone last logged in
printenvprint your environment

User Account Management

commanddescription
useraddcreate an account
userdeldelete an account
usermodmodify an account
passwdchange a password
chshchange a user’s shell

Group Management

commanddescription
groupsprint the group membership of a user
groupaddcreate a group
newgrpuse a new group membership immediately
groupdeldelete a group
groupmodmodify a group

Installing Software Packages

commanddescription
dnfstandard package manager for RPM files
yumolder package manager for RPM files
rpmmanipulate RPM packages locally
aptstandard package manager for DEB files
aptitudealternative package manager for DEB files
dpkgmanipulate DEB packages locally
emergeportable package manager for Gentoo Linux
pacmanpackage manager for Arch Linux
zypperpackage manager for openSUSE Linux
flatpakcontainer-based package manager
snapcontainer-based package manager

Installing Software From Source

commanddescription
configureprepare to build software manually with make
makebuild software from source code

Filesystem Maintenance

Using Disks and Filesystems

commanddescription
dfdisplay available space on mounted filesystems
lsblklist disks and other block devices
mountmake a disk partition accessible
umountunmount a disk partition (make it inaccessible)
fsckcheck a disk partition for errors

Creating and Modifying Filesystems

commanddescription
mkfsformat (create a filesystem on) a disk partition
resize2fsgrow or shrink a disk partition
e2labelchange the volume label on a disk partition

Logical Volumes for Flexible Storage

commanddescription
pvcreatecreate a physical volume
pvdisplayview details of physical volumes
pvremovedelete a physical volume
pvsview other details of physical volumes
vgcreatecreate a volume group
vgdisplayview details of volume groups
vgextendadd physical volumes to a volume group
vgreduceremove physical volumes from a volume group
vgremovedelete a volume group
lvcreatecreate a logical volume
lvdisplayview details of logical volumes
lvresizeresize a logical volume
lvremovedelete a logical volume

Backups and Remote Storage

commanddescription
rsyncefficiently copy a set of files, even across a network
rclonesync files with various cloud providers
ddlow-level copying of data
growisofsburn a DVD or blu-ray disc

Networking Commands

Host Information

commanddescription
unameprint basic system information
hostnameprint the system’s hostname
ipset and display network interface information

Host Location

commanddescription
hostlook up hostnames, IP addresses, and DNS info
whoislook up the registrants of internet domains
pingcheck if a remote host is reachable
tracerouteview the network path to a remote host

Network Connections

commanddescription
sshlog into a remote host, or run commands on it
scpcopy files between two hosts
sftpinteractively copy files between two hosts
netcatcreate arbitrary network connections

Email in Daily Use

commanddescription
mutttext-based mail-client
mailminimal text-based mail client
mailqview the outgoing mail queue on your system

Web Browsing

commanddescription
lynxtext-only web browser
curlaccess online content from the command line
wgetdownload web pages and files

Getting Stuff Done

Screen Output

commanddescription
echoprint simple text on standard output
printfprint formatted text on standard output
yesprint repeated text on standard output
seqprint a sequence of numbers on standard output
clearclear the screen or window

Copy and Paste

commanddescription
xclipcopy and paste between the shell and the clipboard
xselmanipulate the clipboard from the shell

Math and Calculations

commanddescription
exprdo simple math on the command line
bctext-based calculator
dctext-based RPN calculator

Dates and Times

commanddescription
calprint a calendar
dateprint or set the date and time

Version Control

commanddescription
gitperform version control using Git
svnperform version control using subversion

Containers

commanddescription
dockerpackage and run applications in containers

Displaying and Processing Images

commanddescription
displaydisplay a graphics file
convertconvert files from one graphical format into another
mogrifymodify a graphics file
montagecombine graphics files

Audio and Video

commanddescription
mediainfoprint details about a multimedia file
cdparanoiarip audio from CDs to WAV files
lameconvert from WAV to MP3
id3infoview id3 tags in an MP3 file
id3tagedit id3 tags in an MP3 file
ogginfoview information about an OGG file
metaflacview and edit information about a FLAC file
soxconvert between audio file formats
mplayerplay a video or audio file
ffmpegconvert between video and / or audio file formats

References

(Daniel J. Barrett, 2024)