Linux Prompt Cheatsheet: 45 Commands that Every Technologist Should Know
3 min readThe Linux command line (often referred to as shell, terminal, console, prompt) is a text interface to your computer running one of the Linux operating systems.
Navigating the command line might seem like a maze at first glance, but it's really the key to unleashing the true power of your Linux system. This cheat sheet we've put together isn't just a list of commands; think of it as your handy guide through the wilderness of system management and troubleshooting, a companion for both beginners itching to explore and experts needing a quick reference.
We are compiling a fairly comprehensive list that covers various categories, including file management, system monitoring, network commands, and others, to serve as a foundational reference for you. This cheat sheet aims to provide a balanced mixture of commands - from the most commonly used to those that are crucial for specific troubleshooting and system management tasks.
File Management
ls
: Lists files and directories within the current directory.cd <directory>
: Changes the current directory to the specified one.pwd
: Displays the current directory path.cp <source> <destination>
: Copies files or directories.mv <source> <destination>
: Moves files or directories, also used for renaming.rm <file>
: Deletes a file. Use -r for directories.mkdir <directory>
: Creates a new directory.rmdir <directory>
: Deletes an empty directory.find
: Searches for files and directories.touch <file>
: Creates a new file or updates the timestamp of an existing file.
System Monitoring and Management
top
: Displays an interactive list of running processes.ps
: Shows a snapshot of current processes.free
: Shows memory usage.df
: Displays disk space usage for file systems.du
: Shows the disk usage of files and directories.htop
: An interactive process viewer (more detailed than top).
Network Commands
ping <host>
: Checks connectivity to a host.ifconfig
: Displays or configures network interfaces. (ip a in newer systems)netstat
: Displays network connections, routing tables, and interface statistics.ss
: Another utility to investigate sockets.wget <URL>
: Downloads files from the internet.curl <URL>
: Transfers data from or to a server.
File Permissions
chmod <permissions> <file>
: Changes the file's mode.chown <user>:<group> <file>
: Changes the file owner and group.umask
: Sets the default permission for new files and directories.
Text Processing
grep <pattern> <files>
: Searches for a pattern in files.sed
: Stream editor for filtering and transforming text.awk
: An entire programming language designed for text processing.
Archive and Compression
tar
: Creates and extracts tar archives.gzip <file>
: Compresses or decompresses files.zip
,unzip
: Compress and decompress zip files.
Package Management (Debian/Ubuntu)
apt-get update
: Updates the package list.apt-get upgrade
: Upgrades all upgradable packages.apt-get install <package>
: Installs a new package.apt-get remove <package>
: Removes a package.
Package Management (RHEL/CentOS/Fedora)
yum check-update
: Checks for available package updates.yum update
: Updates all upgradable packages.yum install <package>
: Installs a new package.yum remove <package>
: Removes a package.
General
echo text
: Displays a line of text.which <command>
: Shows the full path of (shell) commands.man <command>
: Displays the manual page for the command.
This cheat sheet covers essential commands but is by no means exhaustive. Each command comes with a plethora of options and nuances, best explored through their manual pages (man command
).
And remember, the true power of Linux lies in combining these commands using pipes (|
) and redirections (>
, <
) to perform complex tasks efficiently.