su [options] username switch user
- Switch together represent an environment variable
-c command only once without switching users
pwd show current location
pwd -L flight path display (default)
pwd -P physical path
cd [directory] into the folder
/Root directory
../Parent directory
~ Home directory
./Current directory
- the last open directory
ls [options] [directory] lists the current directory
-a All files
-l details
-R recursively
-r reverse order
-t modification time ordering
ll equivalent to ls -l
mkdir [options] directory name to create a directory
-p create recursive
mkdir -p nvsheng / {yanglan, yangmi}
mkdir fengjie yanglan
touch the file name to create the file
Create a file, or file update time
touch file1 file2
cp [options] source directory target directory to copy files
-r recursive
-p save the file attributes (time constant source file)
mv source directory target directory to move files or change the name
rm [options] file / directory delete files
-r recursive
-f Force
ll-i node can be deleted after I get garbled file
cat [option] filename displays the entire contents of the file
-A display all content
-n Display line numbers
more filename page display file contents
Space Next
Enter the next line
q quit
head [options] file name display a few lines before the file
-n Specifies the number of lines
-f dynamic display
ctrl + c to exit
tail [options] filename few lines of the display file
-n Specifies the number of lines
-f dynamic display
ctrl + c to exit
ln link
Soft connection soft shortcut ln -s source directory name is now connected
Ln hard link hard not commonly used now connected source directory name
man [command / profile] help help
type command to view the internal command or external command
ctrl + c to stop
ctrl + z background
ctrl + l clear screen (corresponding Clear)
ctrl + k to clear the entire command
ctrl + w to clear a word of command
find [Search Path] [matching condition] File Search
-name precise queries by name
-iname query by name, ignoring case
-name "**** ???" (regular expressions, pay attention to prevent the escape double quotes)
-size by size query (in a block as a unit, 1kb = 2block)
= Ignored
Less than -
Greater than +
-type Find by type
f Binary
l soft links
d directory
c-character file
grep [options] "search string" filename Find File
-c number of matches
-n Display line numbers match
-i ignore case
-v Invert Selection grep -v "^ #" / etc / initlb
which displays the directory system command
whereis display system commands more comprehensive
gzip file name
.gz suffix can only compress files and does not retain the source file
-d specified file decompression
bzip2
.bz2 suffix can only compress files, default is to remove the source file
-k keep the original file
zip
.zip suffix
zip compression zip a.zip a
-r compressed folder must add -r
uzip decompression
tar [-zcvf] filename compressed file or directory
z gzip format
c create a compressed file
x decompression
v Process
f filename
shutdown [options] time off
shutdown -h
-r Chongqing
mode of vim
Command Mode
Insert mode iao esc
Edit mode: Enter into the command to enter edit mode
a cursor added
End of the line A
i before the cursor inserted
I first row
o cursor row is inserted
O cursor insert a new line
: Set nu set the line number
: Set nonu cancel the line number
: G last line
: Gg first line
: NG to n-th line
: Wq save and exit
:! Q to exit without saving
x delete character under the cursor
dd Delete Row
yy Copy the line
/ String search backward
? string search forward