Linux的好用命令

1、dd命令

用户生成指定大小的测试文件

[root@localhost ~]# dd if=/dev/zero of=11.txt bs=2M count=3
3+0 records in
3+0 records out
6291456 bytes (6.3 MB) copied, 0.0301223 s, 209 MB/s

 2、find命令

查找指定大小的文件

[root@localhost ~]# find ./ -size 2M -type f

搜索0~5M的文件,不包含5M

[root@localhost ~]# find ./ -size -5M -type f

搜索大于100M的文件

[root@localhost ~]# find / -size +100M -type f

3、tree命令

安装命令

[root@localhost ~]# yum install tree -y

以树状形式显示文件目录

[root@localhost ~]# tree
.
├── 2.txt
├── 6.txt
└── anaconda-ks.cfg
[root@localhost ~]# tree
.
├── 2.txt
├── 6.txt
└── anaconda-ks.cfg

4、crontab命令

查看计划任务

[root@localhost ~]# crontab -l

编辑计划任务

[root@localhost ~]# crontab -e

 

 

 每天的16点把etc目录打包

* 16 * * * /usr/bin/tar -zcf /tmp/etc.tar.gz /etc/

给任务加上时间

22 16 * * * /usr/bin/tar -zcPf /tmp/etc-$(date +\%Y\%m\%d).tar.gz /etc

5、date时间

[root@localhost ~]# date
Thu Jun 15 03:59:42 EDT 2023

获取年月日

[root@localhost ~]# date +"%F"
2023-06-15

获取时分秒

[root@localhost ~]# date +"%T"
04:01:56

只获取年

[root@localhost ~]# date +"%Y"
2023

只获取月

[root@localhost ~]# date +"%M"
03

只获取日

[root@localhost ~]# date +"%d"
15

其他

[root@localhost ~]# date +"%Y%m%d"
20230615

 6、linux中&和&&,| 和|| 介绍如下

&表示任务在后台执行,如要在后台运行redis-server,则有redis-server &

&&表示前一条命令执行成功后,才执行后一条命令,如 echo  '1'  && echo '2'

|  表示管道,上一条命令的输出,作为下一条命令参数   echo 'yes' | wc -l

||表示上一条命令执行失败后,才执行下一条命令,  cat  nofile || echo 'fail'

 7、查看CPU信息

[root@master01 ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             2
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 58
Model name:            Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
Stepping:              9
CPU MHz:               2594.189
BogoMIPS:              5188.37
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0,1

 

posted @ 2023-06-14 17:51  中仕  阅读(12)  评论(0编辑  收藏  举报