Linux命令大全(三)

信息显示类命令

uname命令

可显示电脑以及操作系统的相关信息

例: uname

SYNOPSIS
       uname [OPTION]...
[root@localhost home]# uname
Linux

hostname命令

查看当前的主机名

例: hostname

[root@localhost home]# hostname
localhost.localdomain

dmesg命令

查看开机信息

例: dmesg

uptime命令

查看时间、负载、运行时间

例: uptime

-h,--help 显示版主信息并退出

-p,--pretty 简洁格式显示运行时间

-s,--since 系统启动时间

-v,--version 输出版本信息并退出
[root@localhost home]# uptime
 12:11:43 up  4:45,  2 users,  load average: 0.00, 0.01, 0.04
 
[root@localhost home]# uptime -p
up 4 hours, 47 minutes
[root@localhost home]#

stat命令

查看文件时间类型

例: stat a.txt

[root@localhost home]# stat a.txt
  文件:"a.txt"
  大小:29              块:8          IO 块:4096   普通文件
设备:fd00h/64768d      Inode:33646771    硬链接:1
权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
环境:unconfined_u:object_r:home_root_t:s0
最近访问:2021-06-09 11:38:24.377850693 +0800
最近更改:2021-06-09 10:37:27.000000000 +0800
最近改动:2021-06-09 12:00:32.746801859 +0800
创建时间:-

du、df、free命令

查看空间

例: df -h

du: 显示每个文件和目录的磁盘使用空间~~~文件的大小
-h  以K  M  G为单位显示

df: 显示磁盘分区上可以使用的磁盘空间
-h  以K  M  G为单位显示

free:  可以显示Linux系统中空闲的、已用的物理内存
-b  以Byte为单位显示内存使用情况。 

-k  以KB为单位显示内存使用情况。 

-m  以MB为单位显示内存使用情况。

-g   以GB为单位显示内存使用情况。 
[root@localhost home]# du -h
0       ./a/b/c/b/c/d
0       ./a/b/c/b/c
0       ./a/b/c/b
0       ./a/b/c
0       ./a/b
0       ./a
8.0K    .

[root@localhost home]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 475M     0  475M    0% /dev
tmpfs                    487M     0  487M    0% /dev/shm
tmpfs                    487M  7.7M  479M    2% /run
tmpfs                    487M     0  487M    0% /sys/fs/cgroup
/dev/mapper/centos-root   17G  3.6G   14G   22% /
/dev/sda1               1014M  136M  879M   14% /boot
tmpfs                     98M     0   98M    0% /run/user/0

[root@localhost home]# free -h
              total        used        free      shared  buff/cache   available
Mem:           972M        188M        561M        7.6M        222M        602M
Swap:          2.0G          0B        2.0G
[root@localhost home]#

top命令

经常用来监控linux的系统状况,比如cpu、内存的使用

例: top

SYNOPSIS
       top -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols]

       The traditional switches `-' and whitespace are optional.
top - 12:27:03 up  5:01,  2 users,  load average: 0.00, 0.01, 0.05
Tasks: 102 total,   1 running, 101 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   995748 total,   574008 free,   193944 used,   227796 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   616744 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
  9194 root      20   0  161900   2224   1548 R  0.3  0.2   0:00.02 top
     1 root      20   0  127960   6540   4116 S  0.0  0.7   0:02.16 systemd
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd
     4 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.11 ksoftirqd/0
     7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
     8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
………………等等

date命令

显示和设置系统日期和时间

例: date

%Y表示年,%m表示月,%d表示日,%H表示小时,%M表示分钟,%S表示秒,
[root@localhost home]# date
20210609日 星期三 12:31:14 CST

cal命令

日历,非常友善

例: cal

[root@localhost home]# cal
      六月 2021
日 一 二 三 四 五 六
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

[root@localhost home]#

————————————————————————————————————————

文件查找和搜索

find命令

文件树中查找文件,并做相应的处理

例: find ./ -user root

find [查找目录] [查找规则] [查找完后的操作]

-name :根据文件名进行查找,区分大小写精确查找
* 通配任意的字符,可以是任何东西。
 根据文件所有者查找文件:-user


还有更多姿势等待大家挖掘哈。比如按照字节大小,按照用户,按照目录,按照权限等等
[root@localhost ~]# find /home -name a.txt
/home/a.txt

[root@localhost ~]# find /home -name *.txt
/home/a/b/1.txt
/home/a/1.txt

[root@localhost ~]# find /home -user root
/home
/home/a
/home/a/b
/home/a/b/c
/home/a/b/c/b
/home/a/b/c/b/c
/home/a/b/c/b/c/d
/home/a/b/1.txt
/home/a/b/2.txt
/home/a/b/3.txt
/home/a/1.txt
/home/a/2.txt
/home/a/3.txt
/home/b.txt
/home/a.txt

[root@localhost ~]# find /home -user root -name *.txt
/home/a/b/1.txt
/home/a/1.txt
[root@localhost ~]#

which命令

查看可执行文件的位置

例: which ls

SYNOPSIS
       which [options] [--] programname [...]
[root@localhost ~]# which ls
alias ls='ls --color=auto'
        /usr/bin/ls

全部由centos7环境执行命令

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

征__程

多动手,避免老年痴呆,活跃身心

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值