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
-
Systemdmanages 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 with sudo privilege
sudo su - tim
# Root user indication
"#"
# Standard user indication
"$"
Groups & Ownership
==================================
# Before you shoud be in root user
==================================
# Create Group
groupadd devops
# Add User into Group- (Adding user:tim into group:devops)
usermod -aG devops tim
# Remove user tim from group devops
deluser tim devops
# To see how manu group user belong to
id tim
# Change ownership of dir
# change owenership of dir to nexus:nexus(user:group) -R recursive
chown -R nexus:nexus <dir-name>
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
Services
# Re-read all service configuration files from /etc/systemd/system/
sudo systemctl daemon-reload
# Registers your service to start automatically at boot time
sudo systemctl enable myservice
# Starts your service right now
sudo systemctl start myservice
# Check status of your service
sudo systemctl status myservice
Top comments (0)