Linux常用命令(一)

1. man命令是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助,配置文件帮助和编程帮助等信息。


查看ls命令的帮助信息:

[root@zfs linux]# man ls


2. echo命令用于在shell中打印shell变量的值,或者直接输出指定的字符串。


输出字符串:

[root@zfs linux]# echo "welcome to www.zfsphp.com"
welcome to www.zfsphp.com


打印环境变量:

[root@zfs linux]# echo $SHELL
/bin/bash


3. date命令是显示或设置系统时间与日期。


显示当前时间:

[root@zfs linux]# date
2018年 07月 21日 星期六 15:35:15 CST


按指定格式输出时间:

[root@zfs linux]# date "+%Y-%m-%d %H:%M:%S"
2018-07-21 15:38:05


设置时间:

[root@zfs linux]# date -s "2018-07-21 21:12:30"
2018年 07月 21日 星期六 21:12:30 CST


参数%j可用来查看今天是当年中的第几天:

[root@zfs linux]# date "+%j"
202


4. reboot命令用来重启正在运行的Linux系统。

[root@zfs linux]# reboot


5. poweroff命令用来关闭计算机系统。

[root@zfs linux]# poweroff


6. wget命令用来从指定的URL下载文件。

[root@zfs linux]# wget https://www.linuxprobe.com/docs/LinuxProbe.pdf
--2018-07-21 21:20:10--  https://www.linuxprobe.com/docs/LinuxProbe.pdf
正在解析主机 www.linuxprobe.com (www.linuxprobe.com)... 122.228.95.139
正在连接 www.linuxprobe.com (www.linuxprobe.com)|122.228.95.139|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:20105266 (19M) [application/pdf]
正在保存至: “LinuxProbe.pdf”
100%[==========================================================================================>] 20,105,266  2.78MB/s 用时 7.3s
2018-07-21 21:20:22 (2.61 MB/s) - 已保存 “LinuxProbe.pdf” [20105266/20105266])


7. ps命令用于查看当前系统的进程状态。ps命令是最基本同时也是非常强大的进程查看命令,使用该命令可以确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等等。

[root@zfs linux]# ps
  PID TTY          TIME CMD
 5644 pts/1    00:00:01 bash
11691 pts/1    00:00:00 ps


查看 nginx 相关进程:

[root@zfs linux]# ps aux | grep nginx
root       699  0.0  0.0  23740   124 ?        Ss   16:14   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www        702  0.0  1.2  47036 13188 ?        S    16:14   0:00 nginx: worker process
root     11709  0.0  0.0 110228   916 pts/1    R+   21:24   0:00 grep --color=auto nginx


8. top命令可以实时动态地查看系统的整体运行情况,是一个综合了多方信息监测系统性能和运行信息的实用工具。

[root@zfs linux]# top
top - 21:26:08 up  5:11,  3 users,  load average: 0.00, 0.01, 0.05
Tasks: 159 total,   2 running, 157 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.2 sy,  0.2 ni, 99.2 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   1017936 total,   874992 used,   142944 free,       16 buffers
KiB Swap:   839676 total,    16724 used,   822952 free.   180580 cached Mem
第1行:系统时间、运行时间、登录终端数、系统负载(三个数值分别为1分钟、5分钟、15分钟内的平均值,数值越小意味着负载越低)。
第2行:进程总数、运行中的进程数、睡眠中的进程数、停止的进程数、僵死的进程数。
第3行:用户占用资源百分比、系统内核占用资源百分比、改变过优先级的进程资源百分比、空闲的资源百分比等。其中数据均为CPU数据并以百分比格式显示,例如“97.1 id”意味着有97.1%的CPU处理器资源处于空闲。
第4行:物理内存总量、内存使用量、内存空闲量、作为内核缓存的内存量。
第5行:虚拟内存总量、虚拟内存使用量、虚拟内存空闲量、已被提前加载的内存量。


9. pidof命令用于查找指定服务进程PID值。

查看sshd服务的PID:

[root@zfs linux]# pidof sshd
5550 1066


10. kill命令用于终止某个指定PID的服务进程。


终止掉nginx主进程(699为nginx主进程PID,这种操作等同于强制终止nginx服务):

[root@zfs linux]# kill 699


发布于 。 属于 Linux 分类,被贴了 linux - 常用命令 标签

Linux常用命令(一)》上有 1 条评论!

  1. 烟雨庄
    学习一下!