Essential Concepts
| command | useful flags |
|---|---|
| ls | -lG |
| df | |
| top | -d1 |
| lpr | |
| last | |
| curl | -o url file |
| whois | |
| clear | |
| wc | -l |
| cd | ~fred |
| pwd | |
| printenv | |
| type | wc cd ll |
| which | |
| alias | |
| sort | |
| date | |
| set | history |
| tmux | |
| sleep | |
| man | |
| info | |
| exit | |
| less |
Shell Job Control
| command | useful flags |
|---|---|
| jobs | & |
| ^Z | suspend |
| fg | %1 |
| bg | |
| disown |
File Commands
Basic File Operations
| command | description |
|---|---|
| ls | list files in a directory |
| cp | copy a file |
| mv | move (rename) a file |
| rm | remove (delete) a file |
| ln | create links (alternative names) to a file |
Directory Operations
| command | description |
|---|---|
| cd | change your current directory |
| pwd | print the name of your current directory |
| basename | print the final part of a file path, usually the filename |
| dirname | print a file path without its final part |
| mkdir | create (make) a directory |
| rmdir | delete (remove) an empty directory |
| rm -r | delete a nonempty directory and its contents |
Viewing Files
| command | description |
|---|---|
| cat | view files in their entirety |
| less | view text files one page at a time |
| nl | view text files with their lines numbered |
| head | view the first lines of a text file |
| tail | view the last lines of a text file |
| strings | display text that’s embedded in a binary file |
| od | view data in octal (base 8) or other formats |
Creating and Editing Files
| command | description |
|---|---|
| nano | a simple text editor found in virtually all Linux distros |
| emacs | a powerful text editor from the Free Software Foundation |
| vim | a powerful text editor based on Unix vi |
Properties of Files
| command | description |
|---|---|
| stat | display attributes of files and directories |
| wc | count bytes, words, and lines in a file |
| du | measure disk usage of files and directories |
| file | identify (guess) the type of a file |
| mimetype | identify (guess) the MIME type of a file |
| touch | change timestamps of files and directories |
| chown | change owner of files and directories |
| chgrp | change group ownership of files and directories |
| chmod | change protection mode of files and directories |
| umask | set a default mode for new files and directories |
| lsattr | list extended attributes of files and directories |
| chattr | change extended attributes of files and directories |
Locating Files
| command | description |
|---|---|
| find | locate files in a directory hierarchy |
| xargs | turn a list of files into a list of commands (and much more) |
| locate | create an index of files, and search the index for a string |
| which | locate executables in your search path (command) |
| type | locate executables in your search path (bash built-in) |
| whereis | locate executables, documentation, and source files |
Manipulating Text in Files
| command | description |
|---|---|
| grep | find lines in a file that match a regular expression |
| cut | extract columns from a file |
| paste | append text from multiple files in columns |
| column | organise text into columns |
| tr | translate characters into other characters |
| expand | convert from tabs to spaces |
| unexpand | convert from spaces to tabs |
| sort | sort lines of text by various criteria |
| uniq | locate identical lines in a file |
| tac | reverse a file line by line |
| shuf | randomly shuffle the lines of a file (permutation) |
| tee | write to a file and print on standard output, simultaneously |
| awk | pattern scanning and text processing language |
| sed | stream editor for filtering and transforming text |
| m4 | macro processor for text substitution |
Compressing, Packing, Encrypting
| command | description |
|---|---|
| tar | package multiple files into a single file |
| gzip | compress files with GNU Zip |
| gunzip | uncompress GNU Zip files |
| bzip2 | compress files in BZip format |
| bunzip2 | uncompress BZip files |
| bzcat | uncompress BZip data to standard output |
| compress | compress files with traditional Unix compression |
| uncompress | uncompress files with traditional Unix compression |
| zcat | uncompress to standard output (gzip or compress) |
| zip | package and compress files in Windows Zip format |
| unzip | uncompress and unpack Windows Zip files |
| 7z | package and compress/uncompress 7-Zip files |
| munpack | extract MIME data to files |
| mpack | convert a file to MIME format |
| gpg | encrypt a file with the GNU Privacy Guard (GnuPG) |
Comparing Files
| command | description |
|---|---|
| diff | line-by-line comparison of two files or directories |
| comm | line-by-line comparison of two sorted files |
| cmp | byte-by-byte comparison of two files |
| shasum | compute checksums of the given files |
| md5sum | compute checksums of the given files (insecure) |
Converting Files to other formats
| command | description |
|---|---|
| pandoc | convert from one markup language to another |
| hxselect | extract information from an HTML file |
| jq | extract information from a JSON file |
| xmllint | validate and extract information from an XML file |
| csvtool | extract information from a comma-separated values (CSV) file |
| split | split up a file simply into multiple files |
| csplit | split up a file into multiple files using complex criteria |
PDF and Postscript File Handling
| command | description |
|---|---|
| pdftotext | extract text from PDF files |
| ps2ascii | extract text from PostScript or PDF files |
| pdfseparate | extract individual pages from a PDF file |
| pdftk | split, join, rotate, and otherwise manipulate PDF files |
| pdf2ps, pdf2pdf | convert between PDF and PostScript file formats |
| ocrmypdf | perform optical character recognition (OCR) on a PDF |
Spellchecking
| command | description |
|---|---|
| look | look up the spelling of a word quickly |
| aspell | interactive spelling checker |
| spell | batch spelling checker |
System Administration Basics
Viewing Processes
| command | description |
|---|---|
| ps | list processes |
| pgrep | list the IDs of processes that match a regular expression |
| uptime | view the system load |
| w | list active processes for all users |
| top | monitor resource-intensive processes interactively |
| free | display free memory |
Controlling Processes
| command | description |
|---|---|
| kill | terminate a process (or send it a signal) |
| pkill | terminate processes by name (or send them a signal) |
| timeout | kill a command that runs for too long |
| nice | invoke a program at a particular priority |
| renice | change a process’s priority as it runs |
| nohup | run a process that continues after you log out |
| flock | ensure that only one instance of a command runs at a time |
Scheduling Jobs
| command | description |
|---|---|
| sleep | wait a set number of seconds, doing nothing |
| watch | run a command at set intervals |
| at | schedule a job for a single, future time |
| crontab | schedule jobs for many future times |
Logins, Logouts, and Shutdowns
| command | description |
|---|---|
| systemctl | control the state of your machine and its services |
| shutdown | shut down your local machine |
| reboot | reboot your local machine |
Users and Their Environment
| command | description |
|---|---|
| logname | print your login name |
| whoami | print your current, effective username |
| id | print the user ID and group membership of a user |
| who | list logged-in users, long output |
| users | list logged-in users, short output |
| tty | print your terminal device name |
| last | determine when someone last logged in |
| printenv | print your environment |
User Account Management
| command | description |
|---|---|
| useradd | create an account |
| userdel | delete an account |
| usermod | modify an account |
| passwd | change a password |
| chsh | change a user’s shell |
Group Management
| command | description |
|---|---|
| groups | print the group membership of a user |
| groupadd | create a group |
| newgrp | use a new group membership immediately |
| groupdel | delete a group |
| groupmod | modify a group |
Installing Software Packages
| command | description |
|---|---|
| dnf | standard package manager for RPM files |
| yum | older package manager for RPM files |
| rpm | manipulate RPM packages locally |
| apt | standard package manager for DEB files |
| aptitude | alternative package manager for DEB files |
| dpkg | manipulate DEB packages locally |
| emerge | portable package manager for Gentoo Linux |
| pacman | package manager for Arch Linux |
| zypper | package manager for openSUSE Linux |
| flatpak | container-based package manager |
| snap | container-based package manager |
Installing Software From Source
| command | description |
|---|---|
| configure | prepare to build software manually with make |
| make | build software from source code |
Filesystem Maintenance
Using Disks and Filesystems
| command | description |
|---|---|
| df | display available space on mounted filesystems |
| lsblk | list disks and other block devices |
| mount | make a disk partition accessible |
| umount | unmount a disk partition (make it inaccessible) |
| fsck | check a disk partition for errors |
Creating and Modifying Filesystems
| command | description |
|---|---|
| mkfs | format (create a filesystem on) a disk partition |
| resize2fs | grow or shrink a disk partition |
| e2label | change the volume label on a disk partition |
Logical Volumes for Flexible Storage
| command | description |
|---|---|
| pvcreate | create a physical volume |
| pvdisplay | view details of physical volumes |
| pvremove | delete a physical volume |
| pvs | view other details of physical volumes |
| vgcreate | create a volume group |
| vgdisplay | view details of volume groups |
| vgextend | add physical volumes to a volume group |
| vgreduce | remove physical volumes from a volume group |
| vgremove | delete a volume group |
| lvcreate | create a logical volume |
| lvdisplay | view details of logical volumes |
| lvresize | resize a logical volume |
| lvremove | delete a logical volume |
Backups and Remote Storage
| command | description |
|---|---|
| rsync | efficiently copy a set of files, even across a network |
| rclone | sync files with various cloud providers |
| dd | low-level copying of data |
| growisofs | burn a DVD or blu-ray disc |
Networking Commands
Host Information
| command | description |
|---|---|
| uname | print basic system information |
| hostname | print the system’s hostname |
| ip | set and display network interface information |
Host Location
| command | description |
|---|---|
| host | look up hostnames, IP addresses, and DNS info |
| whois | look up the registrants of internet domains |
| ping | check if a remote host is reachable |
| traceroute | view the network path to a remote host |
Network Connections
| command | description |
|---|---|
| ssh | log into a remote host, or run commands on it |
| scp | copy files between two hosts |
| sftp | interactively copy files between two hosts |
| netcat | create arbitrary network connections |
Email in Daily Use
| command | description |
|---|---|
| mutt | text-based mail-client |
| minimal text-based mail client | |
| mailq | view the outgoing mail queue on your system |
Web Browsing
| command | description |
|---|---|
| lynx | text-only web browser |
| curl | access online content from the command line |
| wget | download web pages and files |
Getting Stuff Done
Screen Output
| command | description |
|---|---|
| echo | print simple text on standard output |
| printf | print formatted text on standard output |
| yes | print repeated text on standard output |
| seq | print a sequence of numbers on standard output |
| clear | clear the screen or window |
Copy and Paste
| command | description |
|---|---|
| xclip | copy and paste between the shell and the clipboard |
| xsel | manipulate the clipboard from the shell |
Math and Calculations
| command | description |
|---|---|
| expr | do simple math on the command line |
| bc | text-based calculator |
| dc | text-based RPN calculator |
Dates and Times
| command | description |
|---|---|
| cal | print a calendar |
| date | print or set the date and time |
Version Control
| command | description |
|---|---|
| git | perform version control using Git |
| svn | perform version control using subversion |
Containers
| command | description |
|---|---|
| docker | package and run applications in containers |
Displaying and Processing Images
| command | description |
|---|---|
| display | display a graphics file |
| convert | convert files from one graphical format into another |
| mogrify | modify a graphics file |
| montage | combine graphics files |
Audio and Video
| command | description |
|---|---|
| mediainfo | print details about a multimedia file |
| cdparanoia | rip audio from CDs to WAV files |
| lame | convert from WAV to MP3 |
| id3info | view id3 tags in an MP3 file |
| id3tag | edit id3 tags in an MP3 file |
| ogginfo | view information about an OGG file |
| metaflac | view and edit information about a FLAC file |
| sox | convert between audio file formats |
| mplayer | play a video or audio file |
| ffmpeg | convert between video and / or audio file formats |