LINUX命令补充

获取命令帮助

方式一:利用–help选项

[root@localhost ~]# useradd  --help

方式二:利用man帮助

[root@localhost ~]# man  useradd

支持上下键滚动,支持 / 进行查找,按q进行退出

[root@localhost ~]# man  5  passwd    #数字5表示是帮助信息的类型
                                      #数字5表示配置文件的帮助信息

历史命令

管理/调用曾经执行过的命令
history:查看历史命令列表
history -c:清空历史命令
!n:执行命令历史中的第n条命令
!str:执行最近一次以str开头的历史命令

[root@localhost ~]# vim  /etc/profile         #修改此文件内容,重启系统生效
HISTSIZE=1000  				                  #默认记录1000条
[root@localhost ~]#  history                  #查看历史命令列表
[root@localhost ~]#  history -c               #清空历史命令
[root@localhost ~]#  history 
[root@localhost ~]# cat  /etc/redhat-release 
[root@localhost ~]# ls  /root/
[root@localhost ~]# history
[root@localhost ~]# !cat      #执行历史命令中,最近一条以cat开头的命令

du统计目录的占用空间

	-s:只统计每个参数所占用的总空间大小
	-h:提供易读容量单位(K、M等) 
[root@localhost ~]# du  -sh   /etc
[root@localhost ~]# du  -sh   /boot/
[root@localhost ~]# du  -sh   /
[root@localhost ~]# du  -sh   /root

date,查看/调整系统日期时间

–	date  +%F、date  +%R
–	date  +"%Y-%m-%d   %H:%M:%S"
–	date  -s  "yyyy-mm-dd   HH:MM:SS" 
[root@localhost ~]# date
[root@localhost ~]# date  +%Y     #显示年
[root@localhost ~]# date  +%m     #显示月
[root@localhost ~]# date  +%d     #显示日
[root@localhost ~]# date  +%F     #显示年-月-日
[root@localhost ~]# date  +%H     #显示时
[root@localhost ~]# date  +%M     #显示分
[root@localhost ~]# date  +%S     #显示秒
[root@localhost ~]# date  +%R     #显示 时:分
[root@localhost ~]# date
[root@localhost ~]# date  -s   "2008-10-1  12:10:01"
[root@localhost ~]# date
[root@localhost ~]# date  -s   "2020-9-8   12:22"
2020年 09月 08日 星期三 12:22:00 CST
[root@localhost ~]# date

制作连接文件(快捷方式)

格式:ln   -s    /路径/源数据     /路径/快捷方式名字    #软连接
[root@localhost ~]# ln  -s   /etc/hosts     /ho
[root@localhost ~]# ls  /
[root@localhost ~]# ls  -l   /ho      #查看快捷方式详细信息
[root@localhost ~]# cat   /ho
[root@localhost ~]# cat   /etc/hosts

[root@localhost ~]# ls /etc/sysconfig/network-scripts/
[root@localhost ~]# ln -s   /etc/sysconfig/network-scripts/       /ns
[root@localhost ~]# ls  /
[root@localhost ~]# ls   /ns
[root@localhost ~]# mkdir   /ns/shukehebeita
[root@localhost ~]# ls   /ns
[root@localhost ~]# ls  /etc/sysconfig/network-scripts/

软连接:

1.可以针对目录制作快捷方式
2.可以跨越分区
3.源数据的消失,快捷方式失效

格式:ln      /路径/源数据     /路径/快捷方式名字      #硬链接 

硬链接:

1.不可以针对目录制作快捷方式
2.不可以跨越分区
3.源数据的消失,快捷方式仍然有效
[root@localhost ~]# echo 123456 > /opt/dc.txt
[root@localhost ~]# ln -s  /opt/dc.txt    /opt/tc.txt   #软连接
[root@localhost ~]# ls   /opt/

[root@localhost ~]# ln  /opt/dc.txt    /opt/tc.txt    #硬链接
[root@localhost ~]# ls  /opt/
  
[root@localhost ~]# rm  -rf  /opt/dc.txt
[root@localhost ~]# ls  /opt/
[root@localhost ~]# cat  /opt/tc.txt   #硬链接仍然有效

zip归档及压缩(跨平台的格式)

归档+压缩操作

格式:zip  [-r]  备份文件.zip   被归档的文档... 
[root@localhost ~]# zip  -r   /root/test.zip    /home/   /etc/passwd
[root@localhost ~]# ls   /root/

释放归档+解压操作

格式:unzip  备份文件.zip   [-d 目标文件夹]
[root@localhost ~]# mkdir  /test
[root@localhost ~]# unzip   /root/test.zip    -d   /test
[root@localhost ~]# ls  /test
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值