Linux Cheat Sheet

Linux Cheat Sheet
Written by Viral DesaiJune 7, 2020
18 min read
Linux Administration
17 VIEWS 4 LIKES 3 DISLIKES
4 LIKES 3 DISLIKES 17 VIEWS
Viral Desai

Linux Administrator

A commonly used Linux Commands

uname -a :-                    Display Linux system information
uname -r                       Display running kernel information
uptime                         Display load average and how long system has been running
hostname                       Display system hostname
hostname -i                    Display IP address of the hostname
last reboot                    Shows system reboot history
last                           Shows last logged in users
w                              Display currently logged in users
whoami                         Display who you are logged in as
dmesg                          Display bootup messages
cat /proc/cpuinfo              Display more information about CPU.
free -m                        Display free and used memory in the system
dmidecode                      Display hardware information from the bios
id                             Display active user information
groupadd "admin"               To create new group called admin
useradd                        To create new user
userdel                        Delete user
userdel -r                     Delete user with its home directory
usermod                        Used for changing / modifying user information
su - username                  Switch to user
su                             Switch to root
echo                           Print message
fdisk -l                       shows list of partitions
poweroff                       shutdown system
ls -l                          List of files and directories
ls -la                         List of all files including hidden files.
pwd                            Shows current path
mkdir "directory name"         Create a new directory
rm                             Removes a file
rm -f                          Forcefully removes a file
rm -r directory name           Removes a directory
rm -rf directory name          Removes directory recursively and forcefully
cp file1 file2                 Copy content of file1 to file2
cp -r dir1 dir2                Copies directory recursively to dir2. It creates dir2
mv file1 file2                 Rename2 file1 to file2
touch file name                Creates a new empty file
cat > file name                Creates a file with content
more file name                 Output the contents of file
head file name                 Display first 10 lines of file
tail file name                 Display last 10 lines of file
wc                             Prints the number of bytes, words and lines in a file
ps                             Display currently active proccess
ps aux | grep telnet           Searches for the process id for telnet
top                            Display all running processes
kill pid                       Terminate process for given pid ( process id )
kill -9 pid                    Forcefully terminate process for given pid
chmod                          Change file permission
chmod 755 /data                Set rwx permission to owner and r_x to group and others
chown ownername filename       Change ownership of file and group
chown viral file.txt           Change ownership to viral for file.txt
chown owner user:owner group   Change owner and group owner of file 
file name 
chown viral:wikiance file.txt  Change owner to viral and group owner to wikiance 
                               ( Same way apply for directory also )
ifconfig                       Display IP Addresses of all networks
ping                           To check connectivity to Server / host
hostname -i                    Display IP Address of the host
netstat -ntlp                  Display all active listening ports
nslookup                       Used to check DNS records
wget                           Download files from Internet
tar -cf home.tar  home         Created archive file "home.tar" from file "home"
tar -xf files.tar              Extract archive file "files.tar"
gzip file                      Compression a files with .gz extension
grep 'pattern' files           Search for a given pattern in files
grep -r pattern directory      Search recursively for a pattern in a given directory
locate file                    Find all instances of the file
Linux
17 VIEWS 4 LIKES 3 DISLIKES
4 LIKES 3 DISLIKES 17 VIEWS
Was this blog helpful?
Comments are disabled for this post by author

3 Comments

Abimbola Okusada

date display the system date and time

Mohasin Momin

@Viral Desai - Thank you for sharing this information. Nice Blog!

Erik Lian

Helpful Blog

Viral Desai
Linux Administrator
1 Blog Posts
0 Discussion Threads
Trending Categories
93
Software12
DevOps34
Frontend Development13
Backend Development13
Server Administration13
Linux Administration12
Data Center14
Sentry11
Terraform15
Ansible9
Docker13
Penetration Testing12
Kubernetes12
NGINX8
JenkinsX10
Jenkins18
SSL6
Ethical-Hacking10
Python8
NodeJs9
RedHat8
Github11
AngularJs15
Google Cloud Platform (GCP)6
SonarQube9
Amazon Web Service (AWS)2
VMware17
Blockchain6
Snipe-IT7