Linux系统基础命令

date命令

date命令用于显示及设置系统的时间或日期,格式为“date [选项] [+指定的格式]”。

参数作用
%H小时(00~23)
%I小时(00~12)
%M分钟(00~59)
%S秒(00~59)
%j今年中的第几天

按照不同格式查看当前系统时间:

[root@localhost ~]# date "+%j"
127
[root@localhost ~]# date "+%Y-%m-%d %H:%M:%S"
2020-05-06 13:59:54

临时重置系统时间

[root@localhost ~]# date -s "20200506 08:30:00"
Wed May  6 08:30:00 CST 2020
wget命令

wget命令用于在终端中下载网络文件,格式为“wget [参数] 下载地址”。

参数作用
-b后台下载模式
-P下载到指定目录
-t最大尝试次数
-c断点续传
-p下载页面内所有资源,包括图片、视频等
-r递归下载
-O文件重命名

执行下载命令

[root@localhost ~]# wget -O /tmp/test.txt "http://192.168.3.33:9000/test/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20200506%2F%2Fs3%2Faws4_request&X-Amz-Date=20200506T060915Z&X-Amz-Expires=432000&X-Amz-SignedHead
ers=host&X-Amz-Signature=b5d2391e135e1c5e261d4398d5669983388e6e87b03414de62c32773b918afd7"
--2020-05-06 14:16:37--  http://192.168.3.33:9000/test/test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20200506%2F%2Fs3%2Faws4_request&X-Amz-Date=20200506T060915Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=b5d2391e135e1c5e261d4398d5669983388e6e87b03414de62c32773b918afd7
Connecting to 192.168.3.33:9000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 386 [text/plain]
Saving to: '/tmp/test.txt'

100%[===================================================================================================================================================================================================>] 386         --.-K/s   in 0s

2020-05-06 14:16:37 (72.5 MB/s) - '/tmp/test.txt' saved [386/386]

[root@localhost ~]# ll /tmp/test.txt
-rw-r--r--. 1 root root 386 May  6 14:09 /tmp/test.txt
ps命令

ps(Process Status)命令用于查看系统中的进程状态,格式为“ps [参数]”。

参数作用
-a显示所有进程(包括其他用户的进程)
-u用户以及其他详细信息
-x显示没有控制终端的进程

Linux系统中时刻运行着许多进程,如果能够合理地管理它们,则可以优化系统的性能。在Linux系统中,有5种常见的进程状态,分别为运行、中断、不可中断、僵死与停止,其各自含义如下所示。

**R(Running 运行):**进程正在运行或在运行队列中等待。

**S(Sleeping 中断):**进程处于休眠中,当某个条件形成后或者接收到信号时,则脱离该 状态。

**D(Do Not Interrupt 不可中断):**进程不响应系统异步信号,即便用kill命令也不能将其中断。

**Z(Zombie僵死):**进程已经终止,但进程描述符依然存在, 直到父进程调用wait4()系统函数后将进程释放。

**T(Terminated停止):**进程收到停止信号后停止运行。

查看进程命令如下

[root@localhost ~]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.1  53788  7672 ?        Ss   14:02   0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 23
root         2  0.0  0.0      0     0 ?        S    14:02   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    14:02   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   14:02   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    14:02   0:00 [kworker/u4:0]
root         7  0.0  0.0      0     0 ?        S    14:02   0:00 [migration/0]
root         8  0.0  0.0      0     0 ?        S    14:02   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    14:02   0:00 [rcuob/0]
root        10  0.0  0.0      0     0 ?        S    14:02   0:00 [rcuob/1]
USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND
进程的所有者进程ID号运算器占用率内存占用率虚拟内存使用量(单位是KB)占用的固定内存量(单位是KB)所在终端进程状态被启动的时间实际使用CPU的时间命令名称与参数
top命令

top命令用于动态地监视进程活动与系统负载等信息。

[root@localhost ~]# top
top - 14:27:32 up 25 min,  2 users,  load average: 0.00, 0.03, 0.05
Tasks: 140 total,   2 running, 138 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:   4048264 total,   554936 used,  3493328 free,     1024 buffers
KiB Swap:  2097148 total,        0 used,  2097148 free.   197660 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
   29 root      20   0       0      0      0 R   0.3  0.0   0:00.16 kworker/0:1
 2156 root      20   0  123672   1632   1104 R   0.3  0.0   0:00.01 top
    1 root      20   0   53788   7672   2524 S   0.0  0.2   0:01.54 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/0
    5 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.01 kworker/u4:0
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 migration/0

load average: 0.00, 0.03, 0.05是显示当前系统CPU负载,从右往左看,第一位为当前CPU使用率,后两位为历史值。

pidof命令

pidof命令用于查询某个指定服务进程的PID值,格式为“pidof [参数] [服务名称]”。

查看sshd pid 如下:

[root@localhost ~]# pidof sshd
1783 1307
[root@localhost ~]# ps aux | grep 1783
root      1783  0.0  0.1 135680  4980 ?        Ss   14:07   0:00 sshd: root@pts/0
root      2216  0.0  0.0 112612   684 pts/0    S+   14:32   0:00 grep --color=auto 1783
[root@localhost ~]# ps aux | grep 1307
root      1307  0.0  0.0  82956  3564 ?        Ss   14:02   0:00 /usr/sbin/sshd -D
root      2226  0.0  0.0 112616   940 pts/0    S+   14:32   0:00 grep --color=auto 1307
kill命令

kill命令用于终止某个指定PID的服务进程,格式为“kill [参数] [进程PID]”。

killall命令

killall命令用于终止某个指定名称的服务所对应的全部进程,格式为:“killall [参数] [服务名称]”。

reboot命令

系统重启命令。

poweroff命令

系统关机命令。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值