The directory structure of windows and the directory structure of Linux
Tab键
completion key
mkdir
Create a directory
mkdir -- make directory mkdir -p /zgc/test Parameters: -p create multiple directories at once
touch command
touch #Create a file, modify the timestamp of the file touch /data/files/ zgc.txt #Create a file zgc.txt in the directory /data/files/ #Create multiple files in different directories touch /tem/test.txt /mnt/test.txt
ls command
View directory information
ls -- list ls - l Parameters: -l show details Note: ll is equivalent to ls -l
cd command
cd ---- change directory # Switch/enter the specified directory cd /application/conf/data
Replenish:
absolute path: from root
Relative path: the position relative to a certain path (next door Pharaoh)
pwd command
pwd ---- print working directory # navigate/display current location
vi instruction
vi /data/filename.txt #Edit the file filename.txt #Press i to enter the editing mode #Press Esc to exit the editing mode # :wq(writ quit) Save and exit # : q! Force quit without saving # vi/vim shortcut key yy #copy p #paste ( you can add a number in front , paste it several times when the number is) dd # delete/cut dG #delete the cursor position to the last line u #undo # Batch operations in vi # Press ctrl + v to enter batch editing mode # Up and down keys to select (arrow keys) # d delete : set nu # Display line number : set nonu # Cancel display line number
cat command
cat # Display/View file content cat /data/zgc.txt #View file zgc.txt
move the cursor
G #reach the last line of the file gg #reach the first line of the file
cp command
#Copy files cp /data/zgc.txt /tmp/ #Copy the files in the data directory to the tmp directory
man command
man #Query the help of the command man + command name #Query the help information of the command
mv command
mv # is used to rename a file or directory, or move a file from one directory to another, or move a group of files to a target directory
mv /data/ /root/ #move data to the root directory
Note: The results of mv and cp are different, mv seems to have "moved" the file, and the number of files has not increased. While cp copies files, the number of files increases.
# Do not use files as much as possible mv to /tmp directory
rm command
rm data.txt #Delete the data file (pay attention to the corresponding directory) rm -r data.txt #Recursively delete the directory rm -f #Forced deletion does not prompt rm -rf #Recursive deletion + forced deletion ( !!! Try not to take it lightly try)
find command
find /root/ -type f -name " *.txt " #Find files ending in .txt - type f (file) d (dir) - name "xxx"
In find, combined with the pipe character to find
find /root/ -type f -name " *.txt " |xargs ls -l #Find files and display file details find /root/ -type f -name " *.txt " |xargs rm -f #Find files , and delete the file
special symbols
grep filter
# grep (global search regular expression(RE) and print out the line, comprehensive search for regular expression and print out the line) It can use regular expression to search text, and print out the matching line. #Output all lines except -v option: grep -v " match_pattern " /data/test.txt
head command
tail command
alisa alias
Crowbar Usage \
sed command
sed generates the specified line
replace the contents of the file
Common shortcut keys
Create a compressed package in Linux