Linux | Red Hat Certified | IT Technology | Operations Engineer
👇 Join our technical exchange QQ group with the note 【Public Account】 for faster approval
Linux Course Notes
Directory Structure
/:Root directory, the only top-level directory
Path example: /home/itheima/a.txt indicates the a.txt file in the home/itheima folder under the root directory
Basic Commands
ls: List files
ls [options] [directory]# Options:# -l Display in list format# -h Human-readable file size (requires -l)# -a Show hidden files (files starting with `.`)
pwd: Display current working directory
pwd
cd: Change directory
cd [target directory]# If no argument is provided, switch to the user's HOME directory# Special path symbols:# ~ represents HOME directory (e.g., cd ~)# . represents the current directory# .. represents the parent directory
File Operations
mkdir: Create a folder
mkdir [-p] directory path# -p: Automatically create parent directories (preceding paths)
touch: Create a file
touch file path
cat: View file content
cat file path
more: View file in pages
more file path# Space to page down, q to exit
Copying and Moving
cp: Copy files/folders
cp [-r] source path target path# -r: Copy folder (recursively)
mv: Move/Rename
mv source path target path# If the target path does not exist, it performs a rename
Deleting and Searching
rm: Delete files/folders
rm [-rf] file or directory# -r: Delete folder# -f: Force delete (no confirmation prompt)
Warning: rm -rf / will delete all system files! Use with caution!
find: Search for files by name
find starting path -name "file name"# Supports wildcards, e.g., *test matches files ending with test
grep: Filter keywords
grep [-n] "keyword" file path# -n: Display line numbers of matching lines
Pipes and Statistics
Pipe symbol |
command1 | command2# Example: cat a.txt | grep "hello"
wc: Count file information
wc [-clmw] file path# -c: Byte count# -l: Line count# -w: Word count
Permission Management
chmod: Change permissions
chmod [-R] permission value file/directory# Permission value example: 755 (rwxr-xr-x)# -R: Recursively change all files in the directory
chown: Change owner
chown [-R] user:group file/directory# Example: chown root:root file.txt
Users and User Groups
Create User/Group
# Requires root permissionuseradd usernamegroupadd groupname
Delete User/Group
userdel [-r] username # -r deletes HOME directorygroupdel groupname
Network and Processes
ifconfig: View IP
ifconfig
ping: Test network connectivity
ping [-c count] IP or domain name# Example: ping -c 3 baidu.com
ps: View processes
ps -ef | grep process name
kill: Terminate process
kill [-9] process ID# -9: Force terminate
Environment Variables
Temporary Setting
export variable name=value
Permanent Setting
-
User level: Edit ~/.bashrc
-
Global level: Edit /etc/profile
View Environment Variables
echo $PATH
Compression and Decompression
tar: Compress/Decompress
# Compress: tar -zcvf archive name.tar.gz file1 file2# Decompress: tar -zxvf archive name.tar.gz [-C target directory]
zip/unzip
# Compress: zip [-r] archive name.zip file or directory# Decompress: unzip archive name.zip [-d target directory]
Other Commands
date: Display date
date "+%Y-%m-%d %H:%M:%S" # Formatted output
wget/curl: Download files
wget file URLcurl -O file URL
top: Real-time monitor system status
top# Shortcuts: M (sort by memory), P (sort by CPU)
For more command help, you can use command –help or man command to view.
For course inquiries, add: HCIE666CCIE
↓ Or scan the QR code below ↓
What technical points and content would you like to see?
You can leave a message below to let us know!