Sitemap
ChiragMaini

ChiragMaini

Linux Commands

2 min readOct 20, 2026

--

useradd chirag.maini
cat /etc/passwd # Stores general account information
passwd chirag.maini
cat /etc/shadow # Stores encrypted password hashes and password expiration policies
userdel chirag.maini
su - chirag.maini
groupadd devops
cat /etc/group
usermod -aG devops chirag # -a: Stands for append. It ensures the user is added to devops without being removed from any other secondary groups and -G: Specifies the target group
ls #list all fine (current location)
cd <folder_name> # cd tmp
cd ..
pwd
mkdir <folder_name> # mkdir test
rmdir <folder_name> # rmdir test
touch test.txt
rm test.txt
rm -r <directory> # rm -r test
cp <file1> <file2> # cp test1 test2 -> creates a copy of test1 file with name test2
mv <old_file> <new_file> # mv test1 test2 -> changes the file name from test1 to test2
echo "hello" > file.txt # writes text to a file
echo "hello" >> file.txt # appends text to a file
chmod +x script.sh # Existing permissions are preserve and Execute bit is added
chown user1 temp.txt
chown user1:devops temp.txt
ps #Lists processes running in your current terminal session.
ps aux #Lists all running processes across all users.
ps -u username # View processes for a specific user
ps aux | nl #count the number of processes
ps aux | wc -l #wc stands for word count
ps -ef # Lists all processes in standard Unix format.
ps -ef | nl #in ps aux we can see CPU and Memory utilization while in ps -ef we can't
kill <PID> # to kill a process
# running these command is itself considered as a process
pkill processname # Terminate a process by name
kill -9 <PID> # used to kill a process forcefully
kill -STOP <PID> # temporarily stop a process
kill -CONT <PID> # resume a process
renice -n 10 -p <PID> # renice is a command to priortize and depriortize a process
# -n 10 means setting the priority as 10
# priority ranges from -19 to 20
# Lower the value higher would be the priority
systemctl list-units --type=service # used to list all the services running
systemctl stop <service_name> # stop a service
systemctl start <service_name> # start a service
nice -n 15 ./backup.sh
# 1. Start a long task in foreground
tar -czf archive.tar.gz /var/log

# 2. Press Ctrl+Z to pause it
# Output: [1]+ Stopped tar -czf archive.tar.gz /var/log

# 3. Resume it in the background
bg

# 4. Check status of background jobs
jobs

# 5. Bring job #1 back to the foreground
fg %1

top
htop
vmstat # reports the system performance
free -m # used and free memory
free -h
nproc # gives number of cpu present in the machine
df -h
du -h # used for folder level disk utilization

--

--