1. systemctl
systemctl start xxx.service # 启动服务,.service可省略
systemctl stop xxx.service # 停止服务
systemctl restart xxx.service # 重启服务
systemctl enable xxx.service # 开机启动服务
systemctl disable xxx.service # 开机不启动服务
常用系统服务
network # 网卡
firewalld # 防火墙
3. 显示IP地址
ip addr show
4. 重启服务器
reboot
5. touch命令
touch -a #修改atime和ctime
touch -r file1 file2 #file2的atime和mtime改为file1一样但ctime不变
6. atime、mtime、ctime的改变
atime:读取、修改文件内容时改变
mtime:修改文件内容时改变
ctime:修改文件内容和属性时改变(文件属性包括所有者、权限、时间等)
7. cat
追加内容到文件
cat >> $file << eof
my name is kof
hahah
eof
8. chmod
数字与权限对照表
|0 | - | 无权限 |
|1 | x | 执行
|2 | w | 写
|3 | w+x | 写+执行
|4 | r | 读
|5 | r+x | 读+执行
|6 | r+w | 读+写
|7 | r+w+x | 读+写+执行
9 vi/vim
使用命令添加注释
使用名命令格式: :起始行号,结束行号s/^/注释符/g(注意冒号)。
取消注释:
使用名命令格式:起始行号,结束行号s/^注释符//g(注意冒号)。
例子:
1、在 10 - 20 行添加 // 注释
:10,20s#^#//#g 注:输入/用#分隔
</