Linux 工作常用命令(二)解释!(图文并茂)

  1.  uptime	查看服务器负载	uptime
    

我们 电脑 或服务器 ,都 会存在可能死机 ,或者是系统反应特别慢 ,这种情况下,有时候需要查系统负载 。

在这里插入图片描述

我们确定了有两个 用户访问系统,产生负载

[root@localhost tmp]# uptime
11:16:46 up 1:31, 2 users, load average: 0.00, 0.01, 0.05

那么我们需要分析,我们系统具体负载多少?

0.00:代表系统1分钟以内产生的负载
0.01:代表5分钟产生的负载
0.05:代表10分钟或者15分钟产生的负载

  1.  who	显示当前用户	
    

[root@localhost tmp]# who
root tty1 2020-07-20 09:46
root pts/0 2020-07-20 10:39 (192.168.92.1)
[root@localhost tmp]#

  1.  yum	以yum的方式安装rpm包自动解决依赖	yum install httpd
    

你就记住,这个是安装的软件包 或者程序

[root@localhost tmp]# yum list httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
httpd.x86_64 2.4.6-40.el7.centos @local_repo
[root@localhost tmp]#

Yum install httpd –y

  1.  rpm	手动安装rpm软件包 自行解决依赖	Rpm -ivh *.rpm
    

[root@localhost Packages]# ls | grep net-tools
net-tools-2.0-0.17.20131004git.el7.x86_64.rpm
[root@localhost Packages]#

[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]# rpm -ivh net-tools-2.0-0.17.20131004git.el7.x86_64.rpm ^C
[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]# ifconfig
-bash: ifconfig: command not found
[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]# route
-bash: route: command not found
[root@localhost Packages]#
[root@localhost Packages]#
[root@localhost Packages]#

[root@localhost Packages]# rpm -ivh net-tools-2.0-0.17.20131004git.el7.x86_64.rpm
Preparing… ################################# [100%]
Updating / installing…
1:net-tools-2.0-0.17.20131004git.el################################# [100%]
[root@localhost Packages]#

[root@localhost Packages]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.92.128 netmask 255.255.255.0 broadcast 192.168.92.255
inet6 fe80::20c:29ff:fefe:832f prefixlen 64 scopeid 0x20
ether 00:0c:29:fe:83:2f txqueuelen 1000 (Ethernet)
RX packets 6028 bytes 560538 (547.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2520 bytes 1371353 (1.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[root@localhost Packages]#

在这里插入图片描述

在这里插入图片描述

其实find命令使用频率特别高,一般查找文件
Find 目录 -name 文件名
[root@localhost ~]# cd /
[root@localhost /]# find /tmp -name test2.txt
/tmp/home/test2.txt
[root@localhost /]# find /tmp -name *.txt
/tmp/home/test2.txt

这种情况有时候,你就是记不住文件名,但你能知道文件一些内容的情况,特别用!
[root@localhost ~]# find /tmp/home/ -type f | xargs grep -n hello
/tmp/home/test2.txt:1:hello world
Binary file /tmp/home/test2.zip matches

[root@localhost /]# cat /etc/passwd | grep root
root❌0:0:root:/root:/bin/bash
operator❌11:0:operator:/root:/sbin/nologin
[root@localhost /]#

pwd这个命令,它的使用场景,比如你进入目录特别长,你记不住了,那么需要查看一下当前你正在工作的目录
[root@localhost /]#
[root@localhost /]# cd /tmp/home/
[root@localhost home]# pwd
/tmp/home
[root@localhost home]#

  1.  cat,tail,head,more	查看文件内容	cat /etc/passwd |awk  -F ':'  '{print $1}'
    

cat /proc/cpuinfo
cat /proc/mounts 系统挂载信息
cat /proc/loadavg 系统负载信息
cat /proc/meminfo 系统内存信息
tail -10 file1 | head -3

查看文件内容命令,特别重要
查看头10行:
[root@localhost log]# head -n 10 boot.log
[ OK ] Started Show Plymouth Boot Screen.
[ OK ] Reached target Paths.
[ OK ] Reached target Basic System.
GG[ OK ] Found device VMware_Virtual_S 3.
Starting File System Check on /dev/disk/by-uuid/17608c95-bf26-4e27-9c9d-8e9db929916b…
[ OK ] Started dracut initqueue hook.
[ OK ] Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems.
[ OK ] Started File System Check on /dev/disk/by-uuid/17608c95-bf26-4e27-9c9d-8e9db929916b.
Mounting /sysroot…
[root@localhost log]#
如果你想最后10行内容:
[root@localhost log]# tail -n 10 boot.log
[ OK ] Started irqbalance daemon.
Starting irqbalance daemon…
[ OK ] Started D-Bus System Message Bus.
Starting D-Bus System Message Bus…
Starting Dump dmesg to /var/log/dmesg…
Starting firewalld - dynamic firewall daemon…
[ OK ] Started System Logging Service.
[ OK ] Started Permit User Sessions.
[ OK ] Reached target Sound Card.
Starting Terminate Plymouth Boot Screen…
[root@localhost log]#

如果你想翻页显示,你们就是用MORE
[root@localhost log]# more boot.log
[ OK ] Started Show Plymouth Boot Screen.
[ OK ] Reached target Paths.
[ OK ] Reached target Basic System.
GG[ OK ] Found device VMware_Virtual_S 3.
Starting File System Check on /dev/disk/by-uuid/17608c95-bf26-4e27-9c9d-8e9db929916b…
[ OK ] Started dracut initqueue hook.
[ OK ] Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems.
[ OK ] Started File System Check on /dev/disk/by-uuid/17608c95-bf26-4e27-9c9d-8e9db929916b.
Mounting /sysroot…
[ OK ] Mounted /sysroot.
[ OK ] Reached target Initrd Root File System.
Starting Reload Configuration from the Real Root…
[ OK ] Started Reload Configuration from the Real Root.
[ OK ] Reached target Initrd File Systems.

  1.  last	显示系统最近登录的账户	last -n 10
    

[root@localhost log]# last -n 10
root pts/0 192.168.92.1 Wed Jul 22 10:05 still logged in
root tty1 Wed Jul 22 09:56 still logged in
reboot system boot 3.10.0-327.el7.x Wed Jul 22 09:56 - 11:04 (01:08)
root pts/0 192.168.92.1 Wed Jul 22 09:36 - crash (00:20)
root tty1 Wed Jul 22 08:34 - 09:55 (01:20)
reboot system boot 3.10.0-327.el7.x Wed Jul 22 08:34 - 11:04 (02:30)
root pts/0 192.168.92.1 Wed Jul 15 15:10 - 17:17 (02:06)
root tty1 Wed Jul 15 15:09 - 17:17 (02:08)
reboot system boot 3.10.0-327.el7.x Wed Jul 15 15:09 - 17:17 (02:08)
root pts/0 192.168.92.1 Wed Jul 15 13:58 - crash (01:11)

wtmp begins Mon Jul 13 09:57:12 2020

  1.  hostname	显示主机名	Hostname -a
    

[root@localhost log]# hostname
localhost.localdomain
[root@localhost log]# hostname client
[root@localhost log]#
[root@localhost log]#
[root@localhost log]# hostname
client
[root@localhost log]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值