Linux cheatsheet
What is Linux?
Linux is the most important operating system in Networking World. Many Network Engineers, Network Administrators and Network Technicians use Linux in different areas of Computer Networking. They use different commands of Linux everyday. But sometimes, some commands can be forgotten. To overcome this issue, I have created a Linux Cheat Sheet for you! In this page, you will find Linux Cheat Sheet Commands.
Is Linux an Operating System?
Because of the fact that there are many versions, “is Linux a Opearing Sytem?” quesiton is very common. The answer is certainly Yes! Linux is an Open source Unix ilke Operating System. It is based on Linux Kernel. This Linux kernel was firstly released by Linus Torvalds at 17 September 1991. There are different distributions of Linux, some of these are:
Centos Red Hat Ubuntu Fedora Debian Suse etc.
All these Linux versions uses the same Linux commands and all the Basic Linux commands are similar in these Operating Systems. Linux find command, Linux delete command, Linux add user, Linuc copy file, Linux password change, Linux unzip etc. All these commands are similar in these versions. So, you can use Linux Cheat Sheet Commands on all these Linux distributions. In other words, you can benefit Linux command line cheat sheet on Red Hat, Ubuntu, Fedora, Debian, Suse etc.
Basic Linux Commands
There are thousands of commands in Linux. But some of these Linux commands are used very often. We can say these Linux commands, Basic Linux commands. So, what are the Linux Basic Commands? These basic commands are the ones, that Network engineers, System Administrators use almost everyday or very often. Some of the jobs used with these commands are given below:
linux remove directory linux delete directory linux delete file Linux password change linux copy directory linux add user to gorup linux add user linux copy file linux list users linux search file etc. linux user list linux traceroute linux create user linux create file linux move file etc.
So, in this Linux Cheat Sheet, you can find all these Basic Linux Commands beside the other important Linux Commands. So, Linux Cheat Sheets Commands will help you both on your daily routine system administration activities and other operational activities.
- uname -a shows Linux system info
- uname -r shows kernel release info
- cat /etc/redhat-release shows installed redhat version
- uptime displays system running/life time
- hostname shows system host name
- hostname -I shows ip addresses of the host
- last reboot displays system reboot history
- date displays current date and time
- cal displays monthly calendar
- mount shows mounted filesystems
File Commands
- ls -l lists files detailly (file type, user, permission etc)
- ls -lh lists files detailly with human readable format
- ls -al lists files detailly with hidden files
- pwd shows present directory
- mkdir directory creates a directory
- rm xyz deletes file xyz
- rm -r /xyz deletes directory /xyz and its contents recursively
- rm -f abc forcefully deletes abc file without confirmation
- rm -rf /xyz forcefully deletes directory /xyz recursively
- cp aaa bbb copies aaa file to bbb file
- cp -r /xxx /yyy copies /xxx directory to /yyy directory
- mv aaa bbb renames or moves file aaa to file bbb
- touch abc creates an empty file named abc
- cat abc used to view file abc
- less abc browse through a text file abc
- head abc displays first 10 lines of file abc
- tail abc displays last 10 lines of file abc
- tail -f abc displays last 10 lines of file abc and follow it as it grows
- tail -F abc outputs last lines of abc as it changes
- file abc gets type of abc
- gpg -c abc encrypts file abc
- gpg abc decrypts file abc
- dir shows files in the current directory
- put abc uploads file ‘abc’ from local to remote device
- get file downloads file ‘abc’ from remote to local device
ls Options
-a display hidden files -R recursive list -r reverse order -t sort by last modified -S sort by file size -l long listing format -1 one file per line -m comma-separated output -Q quoted output
Process Management Commands
- ps displays currently running processes
- ps PID gives the status of a particular process
- pidof gives the process ID of a process
- ps -ef displays all running processes on the system
- ps -ef | grep xyz displays process information for xyz
- top displays and manages the top processes
- htop interactive process viewer (top alternative)
- kill pid kills process with process ID of pid
- pkill xyz kills process with name xyz
- killall abc kills all processes named abc
Program & starts program in the background
- bg lists and resumes stopped jobs in the background
- fg brings the most recent background job to foreground.
- fg x brings job x to the foreground
- nice starts a process with a given priority
- renice changes priority of an already running process
- pstree displays processes in a tree-like diagram
- pmap displays a memory usage map of processes
- lsof lists files opened by running processes
Networking Commands
- arp displays ARP table of the device
- arpwatch displays ethernet activity and Ethernet/ip pairings
- bmon displays bandwidth, captures
- curl used for for file transfer
- dhclient used to analyze clients ip address, subnet mask, gateway, dns server
- dig used for simple DNS lookup
- dstat collects and shows system resources
- ethtool used to check settings of your NIC
- ftp used for for file transfer
- host use dfor DNS lookup
- hping3 used for packet analyze
- ifconfig used to monitor and configure network interfaces
- ip address used to check network interfaces and routing activities
- iptables used for ip packet filtering
- iftop displays current bandwidth usage
- ifup enables interfaces
- ifdown disables interfaces
- iwconfig used to monitor and configure wireless interfaces
- nload used as bandwidth monitoring tool
- nmap used for security audits
- nslookup used also for DNS query
- ip route routing table management
- netstat to check network connections
- route displays and manipulate IP routing table
- ping used to check reachability
- sftp secured file transfer
- ss gives detailed information about the sockets
- ssh used for secure connection
- scp secured file transfer
- tcpdump used for analyzing and capturing
- telnet used for classical unsecure connection
- tshark used for packet analyze
- tshark analyzing and capturing
- traceroute used for path tracking
User information
- w shows who is logged in and what they do
- wget used to download the content of the web servers
- whois checks the whois database and return with IP and Domain info
Help Commands
- command -h / command –help to review all available options of the “command”
- info command to find info documents about the “command”
- whatis command displays a single line description about the”command”
User Information Commands
id shows user&group ids of the current user last shows the last users logged on whoami shows who you are logged in as who shows who is logged into the system w shows who is logged in and what they do
Search Commands
- grep x file searches for x in file
- grep -i case insensitive search
- grep -r recursive search
- grep -v inverted search
- grep -o shows only matched part of the file
- find /dir/ -name aaa* finds files starting with aaa in dir
- find /dir/ -user Gokhan finds files owned by Gokhan in dir
- find /dir/ -mmin 10 finds files modifed less than 10 minutes ago in dir
- find /home -size +500M finds files larger than 500MB in /xyz
- find [/folder/location] -name [x] finds file names starting with character x
- whereis aaa locates the binary, source, and manual page of aaa
- locate abc finds the location of abc quickly
File Transfer Commands
- scp file.txt server:/tmp secure copy file.txt to the /tmp folder on server
- scp server:/var/www/.html /tmp secure copy .html files in /var/www/ directory on server to the local /tmp folder
- scp -r server:/var/www /tmp secure copy all files and directories recursively from server to the current system’s /tmp folder.
- rsync -a /home /backups/ synchronize /home to /backups/
- rsync -avz /home server:/backups/ Synchronize files/directories between the local and remote system with compression enabled
Disk Usage Commands
- df shows file system disk usage
- sfdisk used to manipulate disk partition table with more features
- cfdisk linux partition editor with an interactive user interface
- findmnt lists all mounted file systems
- mount mounts a filesystem
- parted lists and modifies partitions
- parted -l lists the partition details
- lsblk lists all the storage blocks including partitions
- blkid prints the block device partitions and storage media
Install Commands
- yum search keyword compresses abc file using gzip.
- yum install abc installs abc package
- yum info abc displays description and summary info about abc package
- rpm -i abc.rpm installs package from local file named abc.rpm
- yum remove abc Remove/uninstall abc package
- yum list installedl lists all installed packages with yum
- yum search [keyword] finds a package by a related keyword
- yum info [package_name] shows package information and summary
- yum install [package_name.rpm] installs a package using the YUM package manager
- dnf install [package_name.rpm] installs a package using the DNF package manager
- apt-get install [package_name] installs a package using the APT package manager
- rpm -i [package_name.rpm] installs an .rpm package from a local file
- rpm -e [package_name.rpm] removes an .rpm package

