Directory commands
Add catalog
mkdir 【/路径/】目录名
Delete directory
Rmdir 【/路径/】目录名
Change directory
cp:(复制) 原路径 新路径 cp -r 复制文件夹
mv:(移动,重命名) 原路径 新路径
View catalog
-
- 查看当前路径:pwd - 切换到路径:cd - 查看目录内容:ls-a - 展示所有文件(包括隐藏文件) -A(不包括.和..) - -l 展示所有的文件的详细信息 - -R 递归查找所有子内容
mkdir .文件夹 建隐藏文件夹
File command
Create a file
touch 【/路径/】文件名
Delete Files
rm 【-r、 i、 f】【/路径/】文件名
Change file
同改变目录 cp/mv
View Files
ls
vi
document content
View file content
cat 文件名
head 【-n】文件名
tail 【-n】文件名
vi editor
mode
View mode, press a, A, i, I, o, O, insert to enter the edit mode, press:, / to enter the last line mode
Edit mode: press esc to enter view mode
Last line mode: press esc or delete the last line of code to return to view mode
hot key
- Quick positioning: first line gg, last line shift+G, nth line ngg
- Enter edit mode:
- Insert after the cursor: a
- Insert before the cursor: i
- Insert at the end of the line: A
- Insert at the beginning of the line: I
- Insert in the next line: o
- Insert in the previous line: O
- Copy: n (line) yy
- Delete/cut: n (line) dd
- Paste: n (line) p
- Undo the last time: u
- Replace: r: replace the character where the cursor is R: continue to replace until esc
Last line mode
-
Exit: q
-
Save:: w Save and exit:: wq or: x
-
Mandatory:!
-
Display line number: set nu Not display: set nonu
-
Search string: search down:/search string up:? String
Continue to find the next one: n Continue to find the previous one: N
-
Replacement string: s/string to be searched/string after replacement/g
Batch comment: %s/^/#/g
Uncomment in bulk: %s/#//g
User Management
-
User's home directory: ~
-
Create user:
useradd 用户名
-
change Password:
passwd 用户名
-
Switch user:
su 用户名
-
delete users:
userdel 用户名
authority management
-
Default permissions of the folder: drwxr-xr-x 755
-
Default permissions of the file: -rw-r–r--644
1. First mark file type: d is directory,-is file, l is soft link
2. The last 9 digits are divided into 3 parts: they represent the user's own authority, the user's group members, and the permissions of other group members (rwx: read, write, execute)
3.chmod 777 -R test -R can recursively assign weights
-
Change the ownership of a file/folder to chown
chown user name: group name file name changes the file’s attribution user to the corresponding user name, and the attribution group to the corresponding attribution group
Host name and host list
- The default host name is localhost.localhostDomain
- Two ways to modify the host name:
- hostnamectl set-hostname new hostname
- vi /etc/hostname in it, change the hostname to the new hostname (requires restart to take effect)
- Host list
- vi /etc/hosts add: host IP address host name
- ssh username@hostname/IP address: can link to the corresponding host
- Add mutual trust (each machine must do the following operations on other machines)
- ssh-keygen generates secret key
- Copy to the key verification file: cat .ssh/id_rsa.pub> .ssh/authorized_keys
- Transfer to the machine that needs mutual trust: ssh-copy-id -i .ssh/id_rsa.pub -p22 user@hostname
Process management
- View all processes ps -ef / ps -aux
- View an application ps -ef | grep application
- Kill process kill process pid, if you need to force kill -9 pid
Software Installation
1. Unzip the tar:
- Packing: tar -zcvf Packed name The directory before packing
- Unpack: tar -zxvf needs to be unpacked [-C needs to be unzipped to the directory]
- Compression: gzip
- Unzip: gunzip
2. Unzip the zip
- Yum install -y zip/unzip
unzip -d -o file directory file name
3. Install Yum online
4. Package installation rpm
5. Container installation docker
Remote transmission
scp file path target host:/target path