Linux Commands Cheat Sheet
Simplify learning with our cheat sheets! From coding to study tips, find quick references for instant understanding. Your shortcut to expertise starts here.
DashboardLinux Commands Cheat Sheet
Linux commands that every developer should know, along with a brief description and an example of each command:
Command | Explanation | example |
---|---|---|
ls |
Lists the contents of a directory. | ls will list the contents of the current directory. ls /usr/local will list the contents of the /usr/local directory. |
pwd |
Prints the current working directory. | pwd will print the full path of the current working directory. |
cd |
Changes the current working directory. | cd /usr/local will change the current working directory to /usr/local . |
mkdir |
Creates a new directory. | mkdir mydir will create a new directory called mydir . |
mv |
Moves a file or directory. | mv file.txt /usr/local/ will move the file file.txt to the /usr/local directory. |
cp |
Copies a file or directory. | cp file.txt /usr/local/ will copy the file file.txt to the /usr/local directory. |
rm |
Removes a file or directory. | rm file.txt will remove the file file.txt , while rm -r mydir will remove the directory mydir and all of its contents. |
touch |
Creates a new empty file. | touch file.txt will create a new empty file called file.txt . |
ln |
Creates a link to a file or directory. | ln -s /usr/local/file.txt file.txt will create a symbolic link to /usr/local/file.txt called file.txt in the current directory. |
cat |
Displays the contents of a file. | cat file.txt will display the contents of the file file.txt in the terminal. |
clear |
Clears the terminal screen. | clear will clear the contents of the terminal screen. |
echo |
Prints a message to the terminal. | echo "Hello, world!" will print the message "Hello, world!" to the terminal. |
less |
Views a file with pagination. | less file.txt will allow you to view the contents of file.txt one page at a time. |
man |
Displays the manual page for a command. | man ls will display the manual page for the ls command, which describes its usage and options. |
uname |
Displays information about the current system. | uname -a will display all information about the current system, including the kernel version and machine hardware name. |
whoami |
Displays the current user. | whoami will display the username of the current user. |
tar |
Archives and compresses files and directories. | tar -czf archive.tar.gz directory/ will create a compressed archive called archive.tar.gz from the contents of the directory directory. |
grep |
Searches for a pattern in a file. | grep "error" log.txt will search the file log.txt for the pattern "error" and print any lines that match. |
head |
Displays the first few lines of a file. | head -n 10 file.txt will display the first 10 lines of file.txt . |
tail |
Displays the last few lines of a file. | tail -n 10 file.txt will display the last 10 lines of file.txt . |
diff |
Compares the differences between two files. | diff file1.txt file2.txt will compare the contents of file1.txt and file2.txt and print the differences between them. |
cmp |
Compares the contents of two files byte by byte. | cmp file1.txt file2.txt will compare the contents of file1.txt and file2.txt byte by byte and report any differences. |
comm |
Compares the contents of two sorted files line by line. | comm file1.txt file2.txt will compare the contents of file1.txt and file2.txt , which should both be sorted, and print the lines that are unique to each file. |
sort |
Sorts the lines of a file. | sort file.txt will sort the lines of file.txt alphabetically. |
export |
Exports a shell variable. | export VARNAME="value" will create a shell variable called VARNAME with the value "value" . |
zip |
Compresses files into a ZIP archive. | zip archive.zip file1.txt file2.txt will create a ZIP archive called archive.zip containing the files file1.txt and file2.txt . |
unzip |
Extracts files from a ZIP archive. | unzip archive.zip will extract the contents of the archive.zip ZIP archive. |
ssh |
Connects to a remote server using the SSH protocol. | ssh user@example.com will connect to the server at example.com as the user user . |
service |
Controls system services. | service apache2 start will start the Apache web server. |
ps |
Displays information about running processes. | ps aux will display a list of all running processes and their resource usage. |
kill |
Sends a signal to a process to terminate it. | kill 12345 will send the signal to terminate the process with the process ID 12345 . |
killall |
Terminates all processes with a specified name | killall firefox will terminate all processes with the name firefox . |
df |
Displays information about available disk space on mounted filesystems. | df -h will display the available disk space in a human-readable format (e.g., in gigabytes or megabytes). |
mount |
Mounts a filesystem. | mount /dev/sda1 /mnt/mydisk will mount the partition /dev/sda1 at the mount point /mnt/mydisk . |
chmod |
Changes the permissions of a file or directory. | chmod 755 file.txt will give read, write, and execute permissions to the owner and read and execute permissions to everyone else for the file file.txt . |
chown |
Changes the ownership of a file or directory. | chown user:group file.txt will change the owner of file.txt to user and the group ownership to group . |
ifconfig |
Configures network interface parameters. | ifconfig eth0 up will enable the network interface eth0 . |
traceroute |
Traces the path of packets to a destination. | traceroute example.com will trace the path of packets from the current system to the destination example.com . |
wget |
Downloads a file from the internet. | wget https://example.com/file.zip will download the file file.zip from https://example.com . |
ufw |
A frontend for managing a firewall. | ufw allow ssh will allow incoming connections to the SSH service. |
iptables |
A firewall management tool for Linux. | iptables -A INPUT -p tcp --dport 80 -j ACCEPT will allow incoming connections to TCP port 80 (the default port for HTTP). |
apt |
A package manager for Debian-based systems. | apt update will update the list of available packages. |
sudo |
Allows a user to run a command with the privileges of the superuser (root). | sudo apt update will update the list of available packages with root privileges. |
cal |
Displays a calendar. | cal will display the current month’s calendar. |
alias |
Creates an alias for a command. | alias ll='ls -alF' will create an alias ll that runs the command ls -alF . |
dd |
Copies data from one location to another. | dd if=/dev/sda of=disk.img will create an image file called disk.img of the contents of the device /dev/sda . |
whereis |
Shows the locations of a command. | whereis ls will show the locations of the ls command on the system. |
whatis |
Shows a short description of a command. | whatis ls will show a short description of the ls command. |
top |
Displays information about running processes. | top will display a list of running processes and their resource usage in real-time. |
passwd |
Changes the password for a user. | passwd user1 will prompt you to enter and confirm a new password for the user user1 . |
Reference
More details about a specific command can be found by following the link below:
- Bash URL:
https://linux.die.net/man/1/change_command_name