Directory Operation Create Directory
To create a directory using the mkdir command
$HOME/TestFolder
Switch directories
Switch directories using the CD command
$HOME/TestFolder
Use CD: /Command switch to the previous level directory
Cd.. /
Move Directory
To move a directory using the MV command
$HOME/testfolder/var/tmp
Delete Directory
To delete a directory using the RM-RF command
Rm-rf/var/tmp/testfolder
View the files in the directory
Use the LS command to view all files and folders under the directory
Ls/etc
/etc directory default is the *nix system's software configuration file storage location
File Operations Create files
Create a file using the Touch command
Touch ~/testfile
To execute the ls
command, you can see the newly created Testfile file
LS ~
Copying files
Copying files using the CP command
CP ~/testfile ~/testnewfile
deleting files
Use RM command to delete file, enter to y
confirm Delete
CP ~/testfile ~/testnewfile
View File Contents
Use the cat command to view the contents of the. bash_history file
Cat ~/.bash_history
filtration, piping and redirect filtering
Filter out the records contained in root
the/etc/passwd file
grep ' Root '/etc/passwd
Recursively filter out records contained in the/var/log/directory linux
Grep-r ' Linux '/var/log/
Pipeline
In short, the role of the pipeline in Linux is to input the output of the previous command as the next command, concatenating the commands in series like a pipe, and the pipe operator is |
For example, we can combine the cat and grep two commands with a pipeline
cat/etc/passwd | grep ' Root '
Filter out the directories contained in/etc directory ssh
(excluding subdirectories)
ls/etc | grep ' ssh '
redirect
You can use > or < to redirect the output of a command to a file
Echo ' Hello world ' > ~/test.txt
Operations Common Command Ping command
Send 4 ping packets to cloud.tencent.com to check for connectivity
Ping-c 4 cloud.tencent.com
Netstat command
The netstat command is used to display various network related information, such as network connection, routing table, interface status, etc.
List all TCP ports in the listening state
-lt
View all port information, including PID and process name
Netstat-tulpn
PS command
Filter to get the SSH process information in the current system
Ps-aux | grep ' ssh '
Getting Started with Linux basics