Enter command line mode (close graphical interface)
init 5
Enter the graphical interface
pwd
View the current path (/root is the home directory)
touch a.c
Create ac file
rm a.c
Delete ac file/directory
rm a.c -rf
Force deletion of ac files/directories
mkdir abc
Create abc directory
cp 文件名.后缀 /tmp 新文件
Copy files to the tmp directory
cd /tmp
Switch to the tmp directory ( cd /switch to the root directory)
mv a.c b.c
Modify file name
cat 文件/目录
View file/directory
vi(vim) 文件
Edit file (:q to exit, :wq to save and exit)
2. Explanation of files in the root directory
Directory (file)
Explanation
bin / sbin
application
boot
Organizational directory related to system booting and system
dev
Equipment name
etc
Files related to configuration
home
User's home directory
lib / lib64
Repository files
root
Super Administrator Home Directory
run
Files related to program operation
tmp
Temporary data
usr
Installer
where
Variable length file (log)
3. Common commands for text editors
command
effect
cp 文件 /路径 新文件
Copy the file to that location and name it
vi / vim 文件
Edit file
cat 文件/目录
View file/directory
Commonly used commands under ESC not editable:
command
effect
/查找的字符
Find characters
n
Look down
N
Look up
i
Switch mode
del两下
Delete the current cursor line
yy
Copy current line
d
Paste the current line
x
Delete the character under the cursor
:ser number/nonumber
The line number of the text is listed/closed
:行号
Cursor to line number
:%s/旧/新
Replace old characters with new
:w
Write
:q
drop out
:wq
Save and exit
:q!
Force exit (do not save)
D
Switch to tail
gg
First line
u
restore
4. Commands related to users, groups, and permissions
user:
command
effect
useradd xxx
Add xxx user
vipw
View users (Z switches to the end)
userdel xxx
Delete xxx user
group:
command
effect
groupadd xxx
Add xxx group
vigr
View group (Z switches to the end)
group xxx
Delete group xxx
User and group interaction:
command
effect
gpasswd -a 用户名 xxx
Add user to xxx group
groups 用户名
Check which group the user is in
whoami
View current users
su - xxx
Switch to xxx user
exit
Exit the current user (only those who have actively switched)
id xxx
View the xxx user ID (the smaller the id, the greater the authority)
Permissions:
command
effect
chmod 777 xxx
The permission to modify xxx is the highest permission 777 (4 readable, 2 writable, 1 executable. 6 read and write, 3 writable and executable, 5 readable and executable)
chmod 764 文件名
Give file permissions 764 (7 gives users all permissions, 6 permissions for their group, only 4 permissions)
ll
View detailed information (r is readable; w is writable; x is executable; )[Note: -re-r—wx means that you have 1.rw permission, group 2 has r permission; 3 other users have wx permission]
chown root a.c
Change the ac file belongs to the root user
chgrp 组名 文件名
Change the group name the file belongs to
chown abc.ccnp a.c -RF
At the same time change the user and group names to which ac belongs (-RF mandatory)