Part 3 - Summary of Common Linux Commands (Ubuntu)
Linux is the foundational OS for Ops, Dev, Cloud, Containers, Automation, and AI engineering. This article summarizes common commands for Ubuntu users for daily operations, system management, and troubleshooting.
Introduction
Linux is the foundational operating system for Operations, Development, Cloud Computing, Containers, Automation, and AI engineering practices. For users using Ubuntu, mastering common commands is essential for daily operations, system management, and troubleshooting;
This article organizes a summary of common and practical Linux commands, suitable as a reference for daily learning and queries
Commands
Directory and File Operations
View current directory
pwd
View files in directory
ls
View detailed information
ls -l
Show hidden files
ls -la
Change directory
cd /etc
cd ..
cd ~
Create directory
mkdir test
mkdir -p /data/test/logs
Create empty file
touch test.txt
Copy file
cp a.txt b.txt
Copy directory
cp -r dir1 dir2
Move/Rename file
mv old.txt new.txt
mv file.txt /tmp/
Delete file
rm file.txt
Delete directory
rm -r testdir
Force delete
rm -rf testdir
File Viewing Commands
View file content
cat file.txt
View with pagination
less file.txt
View first 10 lines
head file.txt
View first 20 lines
head -n 20 file.txt
View last 10 lines
tail file.txt
View logs in real-time
tail -f /var/log/syslog
File Search and Find
Find file
find / -name nginx.conf
Find txt files in current directory
find . -name "*.txt"
Find directory
find /data -type d -name logs
Find command path
which python3
which docker
Search keyword in file
grep "error" app.log
Case-insensitive search
grep -i "error" app.log
Show line numbers
grep -n "error" app.log
Recursive search directory
grep -rn "listen" /etc/nginx/
User and Permission Management
View current user
whoami
View logged in users
who
Switch user
su - root
Execute command with sudo
sudo apt update
Change file permissions
chmod 644 file.txt
chmod 755 script.sh
Change file owner
chown user:user file.txt
Recursively change directory permissions
chmod -R 755 /data/test
Recursively change owner
chown -R ubuntu:ubuntu /data/test
System Information View
View system version
cat /etc/os-release
View kernel version
uname -r
View hostname
hostname
View CPU info
lscpu
View memory info
free -h
View disk usage
df -h
View directory size
du -sh /data
View block devices
lsblk
Process Management
View current processes
ps -ef
Find specific process
ps -ef | grep nginx
View processes dynamically
top
More friendly process view tool
htop
Kill process
kill 1234
Force kill process
kill -9 1234
Kill process by name
pkill nginx
Network Related Commands
View IP address
ip a
View routing table
ip route
Test network connectivity
ping 8.8.8.8
Test domain resolution
ping www.baidu.com
View port listening
ss -tunlp
View specific port
ss -tunlp | grep 80
View network connections
netstat -tunlp
Test port connectivity
telnet 192.168.1.10 22
Test HTTP service with curl
curl http://127.0.0.1
curl -I http://127.0.0.1
Download file
wget https://example.com/file.tar.gz
Package Management (Ubuntu)
Update software source
sudo apt update
Upgrade packages
sudo apt upgrade -y
Install software
sudo apt install nginx -y
Uninstall software
sudo apt remove nginx -y
Uninstall completely
sudo apt purge nginx -y
Auto clean unused packages
sudo apt autoremove -y
Search package
apt search docker
Service Management (systemd)
View service status
systemctl status nginx
Start service
sudo systemctl start nginx
Stop service
sudo systemctl stop nginx
Restart service
sudo systemctl restart nginx
Reload configuration
sudo systemctl reload nginx
Set auto-start on boot
sudo systemctl enable nginx
Disable auto-start on boot
sudo systemctl disable nginx
View boot logs
journalctl -b
View specific service logs
journalctl -u nginx -f
Compression and Decompression
Pack as tar
tar -cvf archive.tar test/
Unpack tar
tar -xvf archive.tar
Pack and compress as tar.gz
tar -zcvf archive.tar.gz test/
Unpack tar.gz
tar -zxvf archive.tar.gz
Compress zip
zip -r test.zip test/
Unpack zip
unzip test.zip
Disk and Mount
View disk partitions
fdisk -l
View filesystem usage
df -h
Mount disk
mount /dev/sdb1 /mnt
Unmount disk
umount /mnt
View UUID
blkid
Editor Related
Edit file with vim
vim test.txt
Edit file with nano
nano test.txt
User Management
Create user
sudo useradd -m testuser
Set password
sudo passwd testuser
Delete user
sudo userdel -r testuser
View user info
id testuser
SSH Remote Connection
Remote login
ssh user@192.168.1.100
Connect with specific port
ssh -p 2222 user@192.168.1.100
Copy file to remote server
scp file.txt user@192.168.1.100:/tmp/
Copy file from remote server to local
scp user@192.168.1.100:/tmp/file.txt ./
Common Log Paths (Ubuntu)
System log
/var/log/syslog
Auth log
/var/log/auth.log
Kernel log
/var/log/kern.log
DPKG install log
/var/log/dpkg.log
View log example
tail -f /var/log/syslog
tail -f /var/log/auth.log
Common Combo Commands
Find who occupies a port
ss -tunlp | grep 8080
Find a specific process
ps -ef | grep python
View large files/directories
du -sh * | sort -hr
View recently modified files
ls -lt
Run program in background
nohup python3 app.py > app.log 2>&1 &
View background jobs
jobs
Linux Learning Suggestions
For Ubuntu beginners, there is no need to memorize all commands at once. It is more important to understand several core directions:
How to operate files and directories
How to manage services
How to view processes
How to troubleshoot network
How to view logs
How to install software
How to handle permissions
As long as you master these high-frequency commands, whether you are doing Linux Ops, Docker, Kubernetes, or AI development and service deployment later, it will be much easier