Essential Linux Commands- 2


Shortcuts:
Reverse Search
Ctrl + R
then type the command you want to search then Tab
Commands:
Info of Command
# brief description of command
whatis cat
Real time process info
# Real time process
top
# Wrapper: Graphical Process
htop
# System stat for performance check
vmstat
# Amount of CPU available
nproc
List Process & Hierarchy
# List Process not a Real time
ps
# Detail all process list
ps aux
# No of process(Line No)
ps aux | ln
# Only shows no lines
ps aux | wc -l
# kill process
kill <PID>
# Force process delete
kill -9 <PID>
# Thread dumnp
kill -3 <PID>
# Stop process
kill -STOP <PID>
# Resume Stop process
kill -CONT <PID>
# Prioritize Process (-n [1-20], lower no means high prioritize)
renice -n 10 -p <PID>
# Process Hierarchy
pstree -p
# Port used by Process
lsof -i :8085
Inspect Network Connection
# Get active ports in Use
netstat -tuln
# Network Interface Info
ifconfig
# Network Troubleshoot (Can WireShark tool)
# enX0: Network Interface
sudo tcpdump -i enX0 port 80
# Test Connectivity
ping google.com
# Tarce the path packet to reach destination
traceroute google.com
Disk Space, Size & Memory
# Check Disk Space
df -h
# Size of dir or file
# opt: directory
du -sh opt
# Memory (RAM)
free -h
# List Blob(All type of formats- Raw state) attach to Instance
lsblk
# Format the Blob Storage to linux supperted file system (ext4)
mkfs -t ext4 /dev/xvdf
# Mount it in order to use
mount /dev/xvdf mnt/demo-volume/
Services
Systemd
manages services
# Logs of Services
journalctl
# Particular Service
journalctl -u nginx
# Logs of services from Last Boot
journalctl -b
Logs Filter
# Last 10 line of logs
tail -n 10 /var/log/auth.log
# First 10 line of logs
head -n 10 /var/log/auth.log
Alias
alias detail_list='ls -la'
# Want to persist the Alias, add in '~/.bashrc'
Symbolic Link
Soft Link (Like Windows Shortcuts)- It can be broken
# ln: link # -s: flag for soft link # myfile: file you want to crate soft link # slink: name of soft link file created ln -s myfile slink
Hard Link (Actual Copy)- Doesnβt break the other one
# ln: link # myfile: file you want to crate soft link # hlink: name of hard link file created ln myfile hlink
Users
# Full setup of User
adduser tim
# Just Add user
useradd tim
# Delete user
userdel tim
# Login into User
sudo su - tim
Groups
# Create Group
groupadd devops
# Add User into Group- (Adding user:tim into group:devops)
usermod -aG devops tim
SSH Server
# ssh server config- sshd
ls /etc/ssh/sshd_config.d/<50-cloud-init.conf>
File Management
# Overwriting the existing content
echo "Hello" > file.txt
# Appending the content
echo "Hello" >> file.txt
Refer Linux Journey
Subscribe to my newsletter
Read articles from KALPESH MOHANTA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

KALPESH MOHANTA
KALPESH MOHANTA
π Hi there! Welcome to my DevOps adventure! π I'm Kalpesh, a DevOps Engineer, and I'm thrilled to share my journey in the dynamic world of DevOps and Cloud Technologies. π π§ Tech Arsenal: CI/CD Automation: Streamlining workflows for seamless deployments. Containers & Orchestration: Docker & Kubernetes. Cloud Platforms: Azure, AWS. Version Control: Git. Configuration Management: YAML, Linux commands. π My Journey: I've had the privilege to work on diverse projects, including a notable deployment for PepsiCo. My expertise spans CI/CD automation, containerization, cloud services, and scripting to enhance system performance and reliability. π‘ Why Follow Me? Join me as I delve into: Cutting-edge DevOps practices. Automation techniques. Cloud innovations. Tips & tricks for aspiring DevOps professionals. π€ Connect & Collaborate: Let's build, learn, and innovate together. Whether you're a fellow tech enthusiast, a professional looking to share insights, or someone eager to learn, let's connect and grow in this vibrant community. π’ Follow my LinkedIn & Hashnode blog for insights, tutorials, and updates. Together, we'll embrace the ever-evolving DevOps landscape!