Commands



CommandDescription
File Commands













Basic File Operations





lslist
cpcopy
mvmove
Directory Operations





cdchange directory
pwdprint working directory

Essential Concepts

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

Shell Job Control

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 directiories

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
uniqlocal 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
awk
sed
m4

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 secondns, 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

Networking Commands

Getting Stuff Done