Currently Empty: 0.00 €
Linux Cheat Sheet
Discover essential Linux commands to enhance your networking skills. Perfect for both beginners and pros, start exploring now!
Linux Cheat Sheet Commands
Network engineers and system administrators frequently rely on these essential Linux commands for their daily tasks and critical operations.
To assist you, we’ve created a comprehensive Linux Cheat Sheet for your network or system management tasks. No more searching the internet for Linux commands—everything you need is right here. This cheat sheet will help you perform configuration tasks efficiently, much like other resources such as SONiC or ONiE Cheat Sheets.
System Information Commands
Ls Options
- uname -a
- uname -r
- cat /etc/redhat-release
- uptime
- hostname
- hosntame -I
- last reboot
- date
- cal
- mount
Shows Linux system info
Shows kernel release info
Shows installed redhat version
Displays system running/life time
Shows system host name
Shows ip addresses of the host
Displays system reboot history
Displays current date and time
Displays monthly calendar
Shows mounted filesystems
- -a
- -R
- -r
- -t
- -S
- -I
- -1
- -m
- -Q
Display hidden files
Recursive list
Reverse order
Sort by last modified
Sort by file size
Long listing format
One file per line
Comma-separated output
Quoted output
Command Lists & Pipes
IO Redirection
- cmd1 ; cmd2
- cmd1 && cmd2
- cmd1 || cmd2
- cmd&
- cmd1 | cmd2
- cmd1 |& cmd2
Run cmd1 then cmd2
Run cmd2 if cmd1 is successful
Run cmd2 if cmd1 is not successful
Run cmd in a subshell
Stdout of cmd1 to cmd2
Stderr of cmd1 to cmd2
- cmd< file
- cmd1 <(cmd2)
- cmd> file
- cmd> /dev/null
- cmd>> file
- cmd 2> file
- cmd 1>&2
- cmd 2>&1
- cmd&> file
Input of cmd from file
Output of cmd2 as file input to cmd1
Standard output (stdout) of cmd to file
Discard stdout of cad
Append stdout to file
Error output (stderr) of cmd to file
Stdout to the same place as stderr
Stderr to the same place as stdout
Every output of cmd to file
File Operations
Search Files
- touch file1
- cat file1 file2
- less file1
- file file1
- cp file1 file2
- mv file1 file2
- rm file1
- head file1
- tail -F file1
shows Linux system info
shows kernel release info
shows installed redhat version
displays system running/life time
shows system host name
shows ip addresses of the host
displays system reboot history
displays current date and time
displays monthly calendar
shows mounted filesystems
- grep pattern files
- grep -i pattern files
- grep -r pattern dir
- grep -v pattern files
- grep -o pattern files
- find /dir/ -name name*
- find /dir/ -user name
- find /dir/ -mmin num
- find /home -size +500M
- whereis command
- locate file: x
Search for pattern in files
Case-insensitive search
Recursive search in dir
Inverted search
Show matched part of the file only
Find files starting with name in dir
Find files owned by name in dir
Find files mofdified less than num
Find files larger than 500MB in /home
Locate the binary and source
Find the location of file quickly
Bash Shortcuts
Process Management
- CTRL-c
- CTRL-z
- CTRL-a
- CTRL-e
- CTRL-u
- CTRL-k
- CTRL-r
- !!
- !abc
- !abc:p
- !$
- ALT-.
- !*
- ^abc^123
Stop current command
Sleep program
Go to the start of the line
Go to the end of the line
Cut from the start of the line
Cut to the end of the line
Search history
Repeat the last command
Run the last command starting with “abc”
Print the last command starting with “abc”
Last argument of the previous command
Last argument of the previous command
All arguments of the previous command
Run the previous command, replacing “abc” with “123”
- ps
- top
- kill pid:
- pkill name:
- killall name
- program &
- bg
- fg
- fg x
- nice
- renice
- pstree
- pmap
- lsof
Show snapshot of processes
Show real-time processes
Kill the process with ID pid
Kill processes with the name name
Kill all processes with names
Start program in the background
List and resume stopped background jobs
Bring the most recent background job
Bring job x to the foreground
Start a process with a given priority
Change the priority of an running process
Display processes in a tree-like diagram
Display a memory usage process map
List files opened by running processes
Help Commands
Hardware Information Commands
- command -h or command --help
- info command
- whatis command
- man UNIXCOMMAND
- apropos
Review all available options of command
Find info documents about the command
Display a single-line command description
View the detailed man page of command
Search man pages for available commands
- dmesg
- cat /proc/cpuinfo
- cat /proc/meminfo
- lspci -tv
- lsusb -tv
- dmidecode
- hdparm -i /dev/sda
- hdparm -tT /dev/sda
- badblocks -s /dev/sda
Display messages in the kernel ring buffer
Display CPU information
Display memory information
Display PCI devices
Display USB devices
Display DMI/SMBIOS information
Display information about disk sda
Perform a read speed test on disk sda
Test for unreadable blocks on disk sda
Networking Commands
Networking Commands
- arp
- rpwatch
- bmon
- curl
- dhclient
- dig
- dstat
- ethtool
- ftp
- host
- hping3
- ifconfig
- ip address
- iptables
- iftop
- ifup
- ifdown
- iwconfig
Display the ARP table of the device
Display Ethernet activity and Ethernet/IP
Display bandwidth captures
Used for file transfer
Analyze clients’ IP address, gateway, DNS
Used for simple DNS lookup
Collect and show system resources
Check settings of your NIC
Used for file transfer
Used for DNS lookup
Used for packet analysis
Monitor and configure network interface
Check network interfaces and routing
Used for IP packet filtering
Display current bandwidth usage
Enable interfaces
Disable interfaces
Monitor and configure wireless interfaces
- nload
- nmap
- nslookup
- ip route
- netstat
- route
- ping
- sftp
- ss
- ssh
- scp
- tcpdump
- telnet
- tshark
- traceroute
- w
- wget
- whois
Used as a bandwidth monitoring tool
Used for security audits
Used for DNS queries
Routing table management
Check network connections
Display and manipulate IP routing table
Check reachability
Secure file transfer
Give detailed information about sockets
Used for secure connections
Secure file transfer
Used for analyzing and capturing
Used for classical unsecured connections
Used for packet analysis and capturing
Used for path tracking
Show who is logged in and what they do
Used to download content from servers
Check the WHOIS database and return IP and domain info
File Management
User Management
- mkdir dir1
- rmdir dir1
- rm -r dir1
- ln -s file1 link1
- chown user:group file1
- chmod 755 file1
- df -h
- du -sh dir1
- stat file1
Create a new directory dir1
Remove an empty directory dir1
Remove a directory dir1
Create a symbolic link link1 to file1
Change the owner and group of file1
Change permissions of file1 to 755
Display disk space usage
Display the size of directory dir1
Display detailed information about file1
- adduser username
- deluser username
- passwd username
- usermod -aG groupname username
- id username
- groups username
- whoami
Add a new user with username
Remove a user with username
Change the password for username
Add username to groupname
Display user ID and group ID for username
Display group memberships for username
Display the current logged-in username
Package Management
Disk Management
- apt-get update
- apt-get upgrade
- apt-get install package
- apt-get remove package
- apt-get purge package
- apt-get autoremove
- dpkg -i package.deb
- dpkg -r package
Update the package lists
Upgrade all installed packages
Install a new package
Remove an installed package
Remove a package and its configuration
Remove automatically all packages
Install a package from a .deb file
Remove an installed package
- fdisk -l
- mkfs -t ext4 /dev/sda1
- mount /dev/sda1 /mnt
- umount /mnt
- fsck /dev/sda1
- parted /dev/sda
- dd if=/dev/sda of=/dev/sdb
- lsblk
List disk partitions
Create an ext4 filesystem on /dev/sda1
Mount /dev/sda1 to /mnt
Unmount the filesystem mounted at /mnt
Check and repair the filesystem on sda1
Partition a disk using GNU Parted
Clone disk /dev/sda to /dev/sdb
List information about all available block devices
SSH and Remote Management
System Monitoring
- ssh user@hostname
- scp file1 user@hostname:/path
- rsync -avz file1 user@hostname:/path
- ssh-keygen
- screen
- tmux
- vncserver
- ssh-copy-id user@hostname
Connect to hostname as user
Copy file1 to /path on hostname
Synchronize file1 to /path on hostname
Generate SSH key pairs
Start a screen session
Start a tmux session
Start a VNC server session
Copy SSH key to hostname for password-less login
- htop
- free -h
- iostat
- vmstat
- sar
- mpstat
- nmon
- uptime
Interactive process viewer
Display free and used memory
Report CPU and I/O statistics
Report virtual memory statistics
Collect and report system activity info.
Report CPU usage
Performance monitoring tool
Display the system uptime
File Compression and Archiving
Text Processing
- tar -cvf archive.tar dir1
- tar -xvf archive.tar
- tar -czvf archive.tar.gz dir1
- tar -xzvf archive.tar.gz
- gzip file
- gunzip file.gz
- zip archive.zip file1 file2
- unzip archive.zip
Create a tarball of dir1
Extract a tarball
Create a gzipped tarball of dir1
Extract a gzipped tarball
Compress file
Decompress file.gz
Create a zip archive of file1 and file2
Extract a zip archive
- awk '{print $1}' file
- sed 's/old/new/g' file
- cut -d' ' -f1 file
- sort file
- uniq file
- tr 'a-z' 'A-Z' < file
- wc -l file
- split -l 1000 file
Print the first column of each line in file
Replace all occurrences of old with new
Cut the first field from each line in file
Sort the contents of file
Remove duplicate lines from file
Translate lowercase to uppercase in file
Count the number of lines in file
Split file into chunks of 1000 lines each
What is Linux?
Linux is an open-source operating system kernel that serves as the foundation for various distributions, enabling users to manage hardware resources and run applications. Known for its stability and security, Linux is widely used in servers, desktops, and embedded systems around the world. Its flexibility and customization options make it a popular choice among developers and tech enthusiasts.
Is Linux an Operating System?
Yes, Linux is an operating system, specifically a Unix-like OS renowned for its robustness, flexibility, and security. It was developed by Linus Torvalds in 1991 and is built on the Linux kernel, which supports a wide variety of hardware platforms. Linux is open-source, meaning its source code is freely available for anyone to view, modify, and distribute. This open-source nature has fostered a vast community of developers who contribute to its continuous improvement, resulting in numerous Linux distributions (distros). Popular distros include Red Hat, Ubuntu, Fedora, Debian, and SUSE, each catering to different user needs and preferences.
For instance: Ubuntu is known for its user-friendly interface and is popular among desktop users and beginners, while Red Hat is widely used in enterprise environments for its stability and support. Fedora serves as a testing ground for new features that eventually make their way into Red Hat. Debian is valued for its stability and extensive software repositories, and SUSE is known for its excellent enterprise solutions and robust administrative tools. Linux powers a significant portion of the internet’s infrastructure, including servers, supercomputers, and cloud environments. It is also prevalent in embedded systems, such as routers and smart devices, and has a growing presence on desktops. Its versatility, reliability, and cost-effectiveness make Linux a preferred choice for both personal and enterprise-level applications.
GNS3 Knowledge Base
Discover a wealth of information and expert tips in our GNS3 Knowledge Base, your go-to resource for mastering network simulations. Whether you need detailed tutorials, expert tips, or troubleshooting advice, our Knowledge Base has everything to enhance your skills and solve any challenges. Dive in now to enhance your skills and troubleshoot any challenges with ease!
Basic Linux Commands
Basic Linux commands are fundamental for anyone using the Linux operating system, whether for personal use, development, or system administration. These commands allow users to interact with the system, perform tasks, and manage files efficiently. Here are 17 examples of basic Linux commands:
- Remove a directory:
rmdir directory_name
- Delete a directory:
rm -r directory_name
- Delete a file:
rm file_name
- Change a password:
passwd username
- Unzip files:
unzip file.zip
- Copy a directory:
cp -r source_directory destination_directory
- Add a user to a group:
usermod -aG group_name username
- Add a user:
adduser username
- Copy a file:
cp source_file destination_file
- List users:
cut -d: -f1 /etc/passwd
- Search for a file:
find /path/to/search -name file_name
- List user accounts:
cat /etc/passwd
- Perform a traceroute:
traceroute hostname
- Use grep to search within files:
grep 'search_term' file_name
- Create a user:
useradd username
- Create a file:
touch file_name
- Move a file:
mv source_file destination_file
Understanding these basic commands is crucial for effectively managing and navigating a Linux system. They form the foundation for more advanced operations and scripts, making daily tasks more streamlined and efficient. By mastering these commands, users can enhance their productivity and proficiency in using Linux.
Free Cheat Sheets
Click here to access free cheat sheets for networking and system administration
Download essential guides for SONiC, ONIE, Linux, networking protocols, and subnetting to enhance your technical skills
Share the Knowledge: Spread the Word About Our Linux Cheat Sheet!
If you find this page helpful for your networking knowledge and skills, please consider sharing it with your friends, colleagues, and social media followers. Your support helps us create more valuable resources and enhance our courses.
You can share this page on your social media accounts like Facebook, LinkedIn, Twitter, and any related networking and programming forums or blogs. By sharing, you assist other networking enthusiasts in their learning journey, making their work easier and more efficient. So, if you’d like to help others, kindly share this page.
For more in-depth networking knowledge, visit our route2open courses.
Tux, the Linux mascot, is an image created by Larry Ewing <lewing@isc.tamu.edu> and The GIMP. The image is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.