0% found this document useful (0 votes)
5 views9 pages

Linux Commands End to End

This document is a comprehensive cheat sheet for Linux commands, organized into categories such as Basic Commands, User Management, File Management, and more. Each command is listed with its description and an example of usage. It serves as a quick reference guide for users to efficiently navigate and utilize Linux command line functionalities.

Uploaded by

rjeevabharathi7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Linux Commands End to End

This document is a comprehensive cheat sheet for Linux commands, organized into categories such as Basic Commands, User Management, File Management, and more. Each command is listed with its description and an example of usage. It serves as a quick reference guide for users to efficiently navigate and utilize Linux command line functionalities.

Uploaded by

rjeevabharathi7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Linux Commands Cheat Sheet

1. Basic Commands:
Command Description Example
ls List contents in the directory ls -l
cd Change the current working directory cd /home/user
pwd Prints current working directory pwd
cp Copy files or directories cp file.txt backup.txt
mv Move or rename files or directories mv oldname.txt newname.txt
rm Remove files or directories rm file.txt
mkdir Create a new directory mkdir new_folder
rmdir Remove empty directories rmdir empty_folder
rm -rf Force removes a directory rm -rf directory_name
touch Create an empty file or update timestamp touch newfile.txt
clear Clear the terminal screen clear

2. User Management:
Command Description Example (sudo for elevated
priviliges)
useradd Add a new user sudo useradd testusr
groupadd Create a new user group sudo groupadd testgrp
adduser Interactive script to add a new user sudo adduser testusr
passwd Change a user's password passwd testusr
usermod Modify a user account sudo usermod -aG sudo
testusr
deluser Delete a user sudo deluser testusr
userdel Delete a user, home directory and mail spool sudo userdel -r testusr
groupdel Delete an existing user group sudo groupdel testgrp
groups Show groups of a user groups testusrgrp
usermod -aG Add user to a group sudo usermod -aG sudo
testusrgrp
whoami Show current logged-in user whoami
chage Change user account aging information sudo chage -l testusr
who Show who is logged on who
w Show who is logged in and what they’re w
doing
id Show user ID (UID), group ID (GID), and id testusr
groups

3. File and Directory Management:


Command Description Example
find Search for files in a directory hierarchy find /home/testusr -name "*.txt"
locate Find files by name locate notes.txt
tree Display directories in a tree-like format tree directory_name
stat Display detailed info about a file stat file.txt
basename Extract filename from a path basename /home/testusr/file.txt
dirname Extract directory from a path dirname /home/testusr/file.txt
rsync Remote file and directory rsync -avz source/ destination
synchronization rsync -avz -e ssh source/
user@remote:/destination/

4. File Permission & Ownership:


Command Description Example
chmod Change file permissions for User, Group, chmod 755 script.sh
and Others using numeric values: read
(4), write (2), execute (1).
chown Change file owner sudo chown testusr:testusr file.txt
chgrp Change group ownership sudo chgrp testgrp file.txt
umask Set default permissions for new files umask 022
5. Process Management:
Command Description Example
ps Display currently running processes ps aux
systemctl Control the systemd system and service systemctl start service_name
manager systemctl stop service_name
systemctl restart service_name
systemctl enable service_name
systemctl disable service_name
systemctl status service_name
top Show real-time process activity top
kill Terminate a process by PID kill -9 [PID]
kill all Terminate processes by name kill all firefox
htop Interactive process viewer htop
jobs List background jobs jobs
bg Resume a job in the background bg %1
fg Bring a background job to the foreground fg %1
shutdown Shut down the system shutdown -h now
reboot Reboot the system sudo reboot
poweroff Power off the system poweroff
init Change the runlevel init 0 – shutdown
init 6 – reboot

6. Package Management:
Command Description Example
apt Debian package manager tool apt update
apt-get APT package handling utility apt-get install package_name
apt-get update
apt-get upgrade
apt-get remove
yum Red Hat package manager tool yum install package_name
yum update
yum upgrade
yum remove
7. Network Commands:
Command Description Example
ping Test connectivity to a host ping google.com
ifconfig Configure network interfaces ifconfig eth0
(deprecated)
ip Show/manipulate routing, devices, ip a
interfaces
netstat Display network connections netstat -tuln
(deprecated)
traceroute Trace the route packets take to a traceroute google.com
network host
nslookup Query Internet name servers nslookup example.com
interactively
dig DNS lookup utility dig example.com
ss Display socket statistics ss -tuln
curl Transfer data from or to a server curl http://example.com
wget Download files from the internet wget http://example.com/file.zip
scp Securely copy files between hosts scp file.txt testusr@host:/tmp/
ssh Secure shell access to remote machines ssh [email protected]
ftp File Transfer Protocol client ftp ftp.example.com
nc Network utility for reading and writing nc -l -p 844
from network connections

8. Disk Management:
Command Description Example
df Show disk space usage df -h
du Show directory space usage du -sh /home/testusr
fdisk Partition table manipulator sudo fdisk /dev/sda
mount Mount a filesystem mount /dev/sdb1 /mnt
umount Unmount a filesystem umount /mnt
fstab File system table (configuration file for /etc/fstab
mounting file systems)
lsblk List block devices lsblk
blkid Display block device attributes blkid
parted Manipulate disk partitions sudo parted /dev/sda
mkfs Create a file system on a device or sudo mkfs.ext4 /dev/sdb1
partition
fsck Check and repair a Linux file system sudo fsck /dev/sdb1

9. System Monitoring & Performance:


Command Description Example
top Real-time system monitoring top
htop Interactive system monitor htop
vmstat Report virtual memory stats vmstat 1
iostat CPU and I/O statistics iostat
free Show memory usage free -h
time Measure program running time time
uptime Show how long the system has been running uptime
uname Print system information uname -a
hostname Show or set the system's hostname hostname
dmesg Display boot and system messages dmesg
lscpu Display CPU architecture info lscpu

10. Security & Permissions:


Command Description Example
sudo Execute a command as root user sudo apt install nginx
su Switch to another user su - testusr
visudo Edit the sudoers file safely sudo visudo
sudoers Manage sudo access for users sudo visudo -f /etc/sudoers
gpasswd Administer group password gpasswd -a testusr testgrp
ufw Simple firewall utility sudo ufw enable
sudo ufw status
sudo ufw allow [port]
sudo ufw deny [port/service]
iptables Configure packet filtering rules sudo iptables -L

11. Help and Documentation:


Command Description Example
man Display manual pages man ls
info Display command info in GNU format info coreutils
--help Show usage/help for a command ls --help
whatis Brief description of a command whatis grep
apropos Search the manual pages apropos copy

12. Text Processing:


Command Description Example
cat Conc cat file.txt
atenate and display files
less View file content one screen at a time less file.txt
more Basic pager to view file content more file.txt
head Show beginning lines of a file head file.txt
tail Show ending lines of a file tail file.txt
grep Search text using patterns grep 'hello' file.txt
vi or vim Advanced text editors vi script.sh

sed Stream editor for filtering and transforming text sed 's/old/new/g' file.txt
awk Pattern scanning and processing language awk '{print $1}' file.txt
cut Remove sections from each line of a file cut -d ':' -f1 /etc/passwd
sort Sort lines of text sort names.txt
uniq Filter duplicate lines uniq sorted.txt
tr Translate or delete characters tr 'a-z' 'A-Z' < file.txt
wc By default, wc prints the number of lines, words wc file.txt
and bytes in each file.
13. Compression & Archiving
Command Description Example
tar Used to create or extract archive files, tar -cvzf archive.tar file.txt
Common flags include -c (create), -x tar -xvzf archive.tar.gz
(extract), -v (verbose), -z (gzip
compression), and -f (specify archive
file).
gzip Compress files gzip file.txt
gunzip Decompress .gz files gunzip file.txt.gz
bzip2 Compress files using bzip2 bzip2 file.txt
zip Compress files into a zip archive zip archive.zip file.txt
unzip Extract files from a zip archive unzip archive.zip

14. Scheduling & Automation


Command Description Example
cron Daemon to execute scheduled (Runs automatically in the
commands background)
crontab Manage cron jobs crontab -e
at Schedule a one-time job echo 'shutdown now' | at 10:00
batch Run commands when system load is echo './script.sh' | batch
low
sleep Delay for a specified time sleep 10s

15. System Monitoring:

Command Description Example


top Real-time system monitoring top
htop Interactive system monitor htop
vmstat Report virtual memory stats vmstat 1
iostat CPU and I/O statistics iostat
free Show memory usage free -h
uptime Shows how long the system has been uptime
running
lscpu Display information about the CPU lscpu
architecture
lsusb List USB devices lsusb
lspci List PCI devices lspci
lshw List hardware configuration sudo lshw
dmesg Boot and system messages dmesg | less
journalctl View logs collected by systemd journal journalctl -xe
watch Execute a command periodically, showing watch -n 1 free
output in real-time

16. Shell & Scripting:


Command Description Example
bash GNU Bourne Again SHell bash script.sh
sh Basic shell interpreter sh script.sh
source Run a script in the current source ~/.bashrc
shell
./ Shortcut for 'source' ./script.sh
export Set environment variables export PATH=$PATH:/home/testusr/bin
alias Create command shortcuts alias ll='ls -la'
read Read user input read name
echo Display a line of text echo 'Hello, testusr!'

You might also like