快捷搜索:  汽车  科技

linux的常用的五个命令介绍(Linux工作常用命令二)

linux的常用的五个命令介绍(Linux工作常用命令二)那么我们需要分析,我们系统具体负载多少?11:16:46 up 1:31 2 users load average: 0.00 0.01 0.05我们 电脑 或服务器 ,都 会存在可能死机 ,或者是系统反应特别慢 ,这种情况下,有时候需要查系统负载 。我们确定了有两个 用户访问系统,产生负载[root@localhost tmp]# uptime

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

uptime

查看服务器负载

uptime

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

linux的常用的五个命令介绍(Linux工作常用命令二)(1)

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

[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分钟产生的负载

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]#

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

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<link>

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<host>

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]#

linux的常用的五个命令介绍(Linux工作常用命令二)(2)

linux的常用的五个命令介绍(Linux工作常用命令二)(3)

其实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:x:0:0:root:/root:/bin/bash

operator:x: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]#

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.

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

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]#

猜您喜欢: