Comprehensive Guide to Basic Linux Commands

This article compiles the most commonly used basic commands in the Linux system, covering file operations, user management, system monitoring, and network management, suitable for beginners to learn.📂 File and Directory Management1. Display directory contents

ls -al

Description: Displays all files in the current directory, including hidden files.2. Show current path

pwd

Description: Outputs the current directory.3. Change directory

cd /etc

Description: Enters the /etc directory.4. Create directory

mkdir mydir

Description: Creates a directory named mydir.5. Delete directory

rm -r mydir

Description: Recursively deletes the directory mydir.6. Copy file

cp file1.txt file2.txt

Description: Copies file1.txt to file2.txt.7. Move/Rename file

mv old.txt new.txt

Description: Renames old.txt to new.txt.8. View file contents

cat filename.txt less filename.txt head -n 10 filename.txt tail -f logfile.log

Description: cat displays directly; less paginates; head shows the first 10 lines; tail -f tracks logs in real-time.👤 User and Permission Management1. View current user

whoami

2. Add new user

sudo adduser username

3. Change password

passwd username

4. View currently logged-in users

w

5. Permission management

chmod 755 file.sh chown user:group file.txt

Description: chmod modifies permissions; chown changes file ownership.⚙️ System Management1. Display system information

uname -a lsb_release -a

2. View current time

date

3. Check disk space

df -h

4. Check memory usage

free -h

5. Process management

ps aux top htop kill -9 1234

Description: ps aux shows processes; top/htop monitors in real-time; kill -9 terminates a process.🌐 Network Management1. View IP address

ifconfig ip addr

2. Test network connection

ping www.baidu.com

3. Check port usage

netstat -tuln ps s -tulnp

4. Download file

wget https://example.com/file.zip curl -O https://example.com/file.zip

📦 Package Management (using Ubuntu as an example)1. Update software sources

sudo apt update

2. Upgrade installed software

sudo apt upgrade

3. Install new software

sudo apt install nginx

4. Remove software

sudo apt remove nginx

Leave a Comment