Basic command line instructions

Unified instructions for Windows and Linux systems

lsList file information

ls [option] [path]

option: can be -l, -a, -h; can be mixed, such as la, lh (h needs to be used together with l)
path: relative path

Windows system
ls -l home
Linux system
ls -lh bin
cdSwitch directory

cd [path]

path: relative path or absolute path

. ~
Current directory Parent directory Work list

PS: Use on Linux /, use on Windows system\

Windows system

Use relative paths

cd .\home
Linux system

Use absolute paths. The root directory of the Linux system is ""

cd /home/bin
mkdirCreate folder

mkdir [option] [name]

option: optional option, -p
name: relative path or absolute path including file name

option meaning
-p Create folders according to the set directory
Windows system
mkdir .\new dirctory
Linux system
mkdir /home/bin/
touchCreate folder

touch [name]

path: the path of the file

Windows system
touch test.txt
Linux system
touch test.txt
catView file contents

cat [path]
path: relative path or absolute path of the file name

Windows system
cat test.txt
Linux system
cat test.txt
moreView file contents

more [path]
path: relative path or absolute path of the file name
PS: Unlike cat, more supports page turning, press space to turn page, and press q to exit

Windows system
more test.txt
Linux system
more test.txt
cpCopy a folder or file

cp [option] [param1] [param2]

option: optional option, -r
param1: target file
param2: new file

option meaning
-r Copy a folder, indicating recursion
Windows system
cp test.txt test2.txt
Linux system
cp -r test test2

Move itself === Copy

mv test.txt test2.txt 
rmDelete Files

rm [option] [param1] [param2]…

option: optional option, -r, -f
param1: target file
param2: new file
multiple parameters

option meaning
-r Recursive deletion, used to delete folders
-f force delete
Windows system
rm test.txt
Linux system
rm -r test*

force delete

// 切换管理员
su -root
// 输入密码
******
// 强制删除
rm -rf /*
// 退出返回普通用户
exit

Guess you like

Origin blog.csdn.net/cleverstronge/article/details/130941694
Recommended