Linux common document instructions

Offer arrives, dig friends to pick up! I am participating in the 2022 Spring Recruitment Check-In Event, click to view the event details .

hot key

hot key effect
Under windows/Linux: (fn depends on the keyboard) + Ctrl + insert, under Mac: command + c copy text
Under windows/Linux: (fn depends on the keyboard) + Shift + insert, under Mac: command + v paste text
ctrl + c Send a termination command to the current process (if the command is entered incorrectly, enter a new line directly)
ctrl + u Clear the currently entered command
tab键 Commands and filenames can be completed. If you can't complete it, press the tab key twice to display alternative options

path

Absolute path: The directory path starting from the root directory (/) (the output of the pwd command is an absolute path)

例如: /home/user1/abc.txt
复制代码

relative path: the path from the current path

例如: home/user1/abc.txt
复制代码
instruction path
./ Indicates the current directory, unchanged (a dot)
../ Indicates the upper directory (two dots)
~/ Indicates the home directory (enter the /home/acs directory, which is the user's directory under the home folder)
/ Indicates the root directory (enter the / directory, the topmost directory)
  • If it is a file starting with ., it will be set as a hidden file by default

ls view commands

ls command
ls Display files and folders in the current directory (excluding hidden classes)
ls -a Display files and folders in the current directory (including hidden classes)
ls -l Display detailed information about files and folders in the current directory (excluding hidden classes)
ls -hl User-friendly display the detailed information of files and folders in the current directory (excluding hidden classes) (ls class command +h are both user-friendly)
ls -A Do not display the current directory and the upper directory
ls folder name You can view the file names in the folder without entering the folder
chmod +r ubuntu_20_04.tar Increase file read permission
  • ll == ls -la == ls -al
例如:		ls homework		展示当前目录下的homework下的文件和文件夹(不包含隐藏类)
例如:		ls homework -l 	展示当前目录下的homework下的文件和文件夹的详细信息(含隐藏类)
例如:		ls a.txt -l		展示当前目录下的a.txt下的文件和文件夹的详细信息(含隐藏类)
例如:		ls homework -hl 
例如:		ls a.txt -hl
复制代码

basic instructions

basic instructions
pwd Display the current absolute path
cd back to home directory
cd ~ back to home directory
cd XXX Enter the XXX directory
cd / Return to root directory
cd .. Return to the upper directory
cd - Go back to the previous directory (not the same as cd .. means the directory you were in just now)
cat XXX Show content in file XXX / View content in file
find XXX 查询文件夹结构
history 显示历史指令

cp 复制粘贴重命名

  • cp XXX YYY

将XXX文件复制成YYY,XXX和YYY可以是一个路径

例如:	cp a/tmp.txt b		将tmp.txt文件从文件夹a复制到b中
例如:	cp a/tmp.txt b/tmp2.txt		将tmp.txt文件从文件夹a复制到b中并重命名为tmp2.txt
例如:	cp a b -r			将文件夹a复制到b中,如果文件b没有,就将文件夹a重命名b
复制代码

mv 剪切粘贴重命名

  • mv XXX YYY

将XXX文件重命名成YYY

例如: mv a.txt b.txt		将a.txt文件重命名为b.txt文件
例如:	mv a/tmp.txt b		将tmp.txt文件从文件夹a剪切到b中
例如:	mv a/tmp.txt b/tmp2.txt		将tmp.txt文件从文件夹a剪切到b中并重命名为tmp2.txt
例如:	mv a b 			将文件夹a剪切到b中,如果文件b没有,就将文件夹a重命名b
复制代码

创建

创建指令
touch XXX.YYY 创建文件
mkdir XXX 创建目录XXX
mkdir --help 查询mkdir的指令
mkdir -p 确保目录名称存在,不存在的就建一个
例如 mkdir a			在当前路径下创建文件夹a
或者 mkdir /home/acs/a 
例如 mkdir y\ c		创建y c文件夹(\为转义字符,\ 转译为 )
rm y\ c		删除y c文件夹
mkdir a/b/c -p	创建文件夹a,并嵌套创建b,c文件夹
复制代码

删除

删除指令
rm XXX.YYY 删除普通文件,可以多个删除文件
rm XXX -r 删除文件夹
例如: rm tmp.txt	删除tmp.txt文件
	 rm tmp.txt tmp2.txt	删除tmp.txt tmp2.txt
	 rm *.txt	正则删除
	 rm a/*		删除文件夹a下的所有文件,保留文件夹a
例如: rm a -r		删除文件夹a
	 rm * -r	删除当前文件夹下所有文件和文件夹
	 rm /* -rf	linux系统删除(删除根目录下的所有文件)
	 rm -rf /
	 rm -rf /*
复制代码

Guess you like

Origin juejin.im/post/7074540019762855966