Comprehensive list of commonly used Linux commands, specific code examples are required
1. Introduction
As a free and open source operating system, Linux has become the platform of choice for many developers and system administrators. Whether in server rental, website building, software development or daily use, familiarity with common Linux commands is essential. This article will introduce some commonly used Linux commands in detail and provide specific code examples.
2. File and directory operations
Create directory (directory name newdir)
mkdir newdir
Delete directory (directory name is olddir)
rmdir olddir
Enter the directory (the directory name is mydir)
cd mydir
Display the current directory
pwd
Display all files and directories in the current directory
ls
Copy files (copy file file1 to directory dir1)
cp file1 dir1
Delete file (delete file file1)
rm file1
Move file (move file file1 to directory dir1)
mv file1 dir1
Find file (find file File whose name contains test)
find / -name "test"
3. File content operation
Display file content (display the content of file file1)
cat file1
Display the first n lines of the file (display the first 10 lines of the file file1)
head -n 10 file1
Display the last n lines of the file (display the last 10 lines of the file file1 Line)
tail -n 10 file1
Find the line containing a certain keyword in the file (find the line containing "hello" in the file file1)
grep "hello" file1
Statistics on the number of lines, words and characters of the file (statistics on the number of lines, words and characters of the file file1)
wc file1
4. System Management
Shutdown
shutdown -h now
Restart
reboot
Check the system version
cat /etc/*-release
Check the system time
date
Check the system load
uptime
5. Network operation
View the IP address (View IP address of network interface eth0)
ifconfig eth0
Test network connection (test connectivity to target host)
ping target.com
Download file (from URL url download file)
wget url
Upload file (upload file file1 to the remote host)
scp file1 remoteuser@remotehost:/path/to/destination
Port monitoring (view all open files in the system Port)
netstat -tuln
6. Permission management
Modify file permissions (modify the owner permissions of file file1 to read and write)
chmod 600 file1
Modify the file owner (change the owner of file file1 to user1)
chown user1 file1
Modify the group to which the file belongs (change the owner of file file1 Group modified to group1)
chgrp group1 file1
View file permissions and owners
ls -l file1
7. Process Management
View all processes
ps -ef
End the process (end the process with process PID 1234)
kill 1234
Run the program in the background (change the program prog1 Put it into the background to run)
prog1 &
Check the CPU and memory usage of the process
top
The above are some commonly used Linux command examples, I hope they can Help you better master the Linux operating system. Of course, Linux is very powerful, and there are many other commands and usages that can be further explored and learned.
The above is the detailed content of Linux common command manual. For more information, please follow other related articles on the PHP Chinese website!