linux基础命令篇三

1.uname显示所有输出系统信息

-a显示所有的信息

[root@andy ~]# uname -a
Linux andy 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

-r显示操作系统发行的版本

[root@andy ~]# uname -r
3.10.0-514.el7.x86_64

2.hostname显示并设置主机名

显示主机名

[root@andy ~]# hostname
andy

临时设置主机名,重启后失效

[root@andy ~]# hostname hello
[root@andy ~]#(打开一个新的窗口,主机名就显示hello)

[root@hello ~]# 

永久设置主机名

[root@hello ~]# hostnamectl set-hostname andy
[root@hello ~]#

[root@andy ~]# (重启后也不是失效)

3.history查看历史命令默认为1000

4.which显示完整路径(可以查看命令完整路径)

[root@andy ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls

5.wc统计文本信息

wc -c统计字节

[root@andy ~]# touch test
[root@andy ~]# echo -e "hello hello hello" >> test
[root@andy ~]# wc -c test
18 test

wc -w统计单词数量

[root@andy ~]# wc -w test
3 test

wc -l统计行数

[root@andy ~]# wc -l test
3 test

6.w显示登陆用户信息以及他们在做什么

[root@andy ~]# w
16:04:15 up 7:48, 2 users, load average: 0.00, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 0910月19 2:45m 0.03s 0.03s -bash
root pts/2 192.168.160.1 15:49 7.00s 0.01s 0.00s w

7.who时w的缩减版

[root@andy ~]# who
root tty1 2019-10-09 15:08
root pts/2 2019-10-29 15:49 (192.168.160.1)
[root@andy ~]#

8.whoami显示当前用户

[root@andy ~]# whoami
root

9.ping向网络主机发送icmp(检测主机是否在线)

ping -c发送包数量

ping -w等待时间(当试图检测不可达主机时此选项很有用)

-i(间隔秒数)指定收发信息间隔时间

[root@andy ~]# ping -c 4 -w 4 baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=32.3 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=32.4 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=31.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=31.0 ms

--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 31.001/31.896/32.429/0.571 ms

10.du文件和目录大小默认显示一个目录下的所有文件,最后一行会有大小和总和

du -s只显示总和

[root@andy ~]# du -s /etc
30644 /etc

du -h 人类易读

[root@andy ~]# du -h /root
0 /root/.pki/nssdb
0 /root/.pki
52K /root

[root@andy ~]# du -s -h /etc
30M /etc

原文地址:https://www.cnblogs.com/yzandy/p/11759502.html