Command Line Cheat Sheet

In CLI

Command line, also known as the terminal or shell, is a powerful tool for interacting with a computer’s operating system. It allows users to execute commands and perform tasks without the need for a graphical user interface (GUI). While it may seem intimidating at first, learning how to use the command line can greatly increase productivity and efficiency.

One of the main advantages of the command line is its speed. With just a few keystrokes, users can perform complex tasks that would take much longer to accomplish using a GUI. Additionally, the command line provides access to a wide range of tools and utilities that are not available through a graphical interface.

Another benefit of the command line is its flexibility. Users can customize their environment and create scripts to automate repetitive tasks. This can save time and reduce the risk of errors.

To get started with the command line, users need to open a terminal window. This can be done by searching for “terminal” in the operating system’s search bar or by using a keyboard shortcut. Once the terminal is open, users can begin entering commands.

Some basic commands include “ls” to list the contents of a directory, “cd” to change directories, and “mkdir” to create a new directory. Users can also use the “man” command to access the manual pages for a specific command and learn more about its usage.

Overall, the command line is a powerful tool that can greatly enhance a user’s productivity and efficiency. While it may take some time to learn, the benefits are well worth the effort.

Cheat Sheet

This cheat sheet provides a comprehensive list of command line commands and their descriptions.

Navigation

CommandDescription
cdChange directory
lsList files and directories
pwdPrint working directory
mkdirMake directory
rmdirRemove directory
touchCreate a new file
cpCopy files or directories
mvMove or rename files or directories
rmRemove files or directories
catConcatenate and display files
moreDisplay output one screen at a time
lessDisplay output one screen at a time, with more features
headDisplay the first few lines of a file
tailDisplay the last few lines of a file
grepSearch for a pattern in a file
findSearch for files and directories
locateFind files and directories by name
whichFind the location of a command

File Management

CommandDescription
chmodChange file permissions
chownChange file ownership
chgrpChange file group
tarCreate or extract a tar archive
gzipCompress or decompress files
gunzipDecompress a gzip file
zipCreate or extract a zip archive
unzipExtract files from a zip archive
ddCopy and convert files
dfDisplay disk usage
duDisplay disk usage of files and directories
lnCreate a link to a file or directory
statDisplay file or file system status
fileDetermine file type
wcCount lines, words, and characters in a file
sortSort lines in a file
uniqRemove duplicate lines from a file
cutExtract columns from a file
pasteMerge lines from multiple files
diffCompare files line by line
patchApply a patch to a file

System Information

CommandDescription
unameDisplay system information
whoamiDisplay current user
whoDisplay logged in users
wDisplay logged in users and their processes
psDisplay running processes
topDisplay system resource usage
freeDisplay memory usage
dfDisplay disk usage
duDisplay disk usage of files and directories
ifconfigDisplay network interface configuration
netstatDisplay network connections
pingTest network connectivity
tracerouteTrace network path to a host
nslookupLook up IP address for a domain name
digLook up DNS information
routeDisplay or modify network routing table

User Management

CommandDescription
useraddAdd a new user
userdelDelete a user
usermodModify a user
passwdChange user password
suSwitch user
sudoExecute a command as another user
chshChange user shell
chfnChange user information
fingerDisplay user information
whoDisplay logged in users
wDisplay logged in users and their processes

Process Management

CommandDescription
psDisplay running processes
topDisplay system resource usage
killSend a signal to a process
killallKill processes by name
niceSet process priority
reniceChange process priority
bgRun a process in the background
fgBring a process to the foreground
jobsDisplay background jobs
nohupRun a command that continues after logout
screenRun a command in a virtual terminal

Miscellaneous

CommandDescription
echoDisplay a message
dateDisplay or set the system date and time
calDisplay a calendar
bcCommand line calculator
historyDisplay command history
aliasCreate a command alias
exportSet environment variables
sourceExecute commands from a file
sleepPause for a specified time
watchExecute a command repeatedly
teeRedirect output to a file and stdout
scriptRecord a terminal session
clearClear the terminal screen
resetReset the terminal
manDisplay manual pages
aproposSearch for a command by keyword
infoDisplay info pages
whereisFind the location of a command
whatisDisplay a brief description of a command
whichFind the location of a command

Conclusion

This cheat sheet provides a comprehensive list of command line commands and their descriptions. Use it as a reference to help you navigate and manage your system more efficiently.

Reference: