Linux筆記02(有關係統操做命令)

一、 服務啓動

紅帽五、6:initbash

紅帽7之後:systemctl ……markdown

老系統命令 新系統命令 做用
service 服務start systemctl start服務 啓動服務
service 服務restart systemctl restart服務 重啓服務
service 服務stop systemctl stop服務 中止服務
service 服務reload systemctl reload服務 從新加載配置文件(不終止服務)
service 服務status systemctl status服務 查看服務狀態
chkconfig 服務on systemctl enable 服務 服務加入啓動項
chkconfig 服務off systemctl disable服務 開機不自動啓動

二、經常使用命令

echo輸出字符

[root@mingmingxingforcomputer ~]# echo hello

hello

date查看時間

[root@mingmingxingforcomputer ~]# date

Sat Jun 26 21:31:28 CST 2021

//添加參數形式:「年月日 時分秒」

[root@mingmingxingforcomputer ~]# date "+%y-%m-%d %H:%M:%S"

21-06-26 21:35:34

timedatectl設置時間

[root@mingmingxingforcomputer ~]# timedatectl status 

​        Local time: Sat 2021-06-26 00:00:04 CST

​      Universal time: Fri 2021-06-25 16:00:04 UTC

​         RTC time: Fri 2021-06-25 16:00:04

​        Time zone: Asia/Shanghai (CST, +0800)

System clock synchronized: no

​       NTP service: inactive

​     RTC in local TZ: no

[root@mingmingxingforcomputer ~]# timedatectl set-time 2021-6-25

[root@mingmingxingforcomputer ~]# timedatectl status 

​        Local time: Fri 2021-06-25 00:00:01 CST

​      Universal time: Thu 2021-06-24 16:00:01 UTC

​         RTC time: Thu 2021-06-24 16:00:01

​        Time zone: Asia/Shanghai (CST, +0800)

System clock synchronized: no

​       NTP service: inactive

​     RTC in local TZ: no

date -s 命令設置時間

[root@mingmingxingforcomputer ~]# date -s "2021/6/26 13:49:00"
Sat Jun 26 13:49:00 CST 2021

三、常見進程狀態:

一、5大狀態

R(運行):進程正在運行或在運行隊列中等待。異步

S(中斷):進程處於休眠中,當某個條件造成後或者接收到信號時,則脫離該狀態。ide

D(不可中斷):進程不響應系統異步信號,即使用kill命令也不能將其中斷。函數

Z(僵死):進程已經終止,但進程描述符依然存在, 直到父進程調用wait4()系統函數後將進程釋放。rest

T(中止):進程收到中止信號後中止運行。code

二、命令查看

[root@mingmingxingforcomputer ~]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.1 244508 13832 ?        Ss   10:19   0:03 /usr/lib/systemd/systemd --switched-root --system --deserial
root          2  0.0  0.0      0     0 ?        S    10:19   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        I<   10:19   0:00 [rcu_gp]
root          4  0.0  0.0      0     0 ?        I<   10:19   0:00 [rcu_par_gp]
root          6  0.0  0.0      0     0 ?        I<   10:19   0:00 [kworker/0:0H-kblockd]
root          8  0.0  0.0      0     0 ?        I<   10:19   0:00 [mm_percpu_wq]
root          9  0.0  0.0      0     0 ?        S    10:19   0:00 [ksoftirqd/0]
root         10  0.0  0.0      0     0 ?        I    10:19   0:00 [rcu_sched]
root         11  0.0  0.0      0     0 ?        S    10:19   0:00 [migration/0]
root         12  0.0  0.0      0     0 ?        S    10:19   0:00 [watchdog/0]
root         13  0.0  0.0      0     0 ?        S    10:19   0:00 [cpuhp/0]
root         14  0.0  0.0      0     0 ?        S    10:19   0:00 [cpuhp/1]

三、top命令

相似Windows任務管理器隊列

top - 13:59:37 up  3:39,  2 users,  load average: 0.00, 0.00, 0.00
Tasks: 371 total,   1 running, 370 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
MiB Mem :   7790.8 total,   5697.6 free,   1453.3 used,    639.9 buff/cache
MiB Swap:   2048.0 total,   2048.0 free,      0.0 used.   6051.2 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                
  2776 root      20   0  177712  29704   8160 S   0.3   0.4   0:19.50 sssd_kcm                                               
  5162 root      20   0   64128   4796   3932 R   0.3   0.1   0:00.02 top                                                    
     1 root      20   0  244508  13832   9032 S   0.0   0.2   0:03.22 systemd                                                
     2 root      20   0       0      0      0 S   0.0   0.0   0:00.05 kthreadd                                               
     3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                 
     4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp

四、nice命令

其中PR是進程的優先級 數值越低,優先級越高進程

[root@mingmingxingforcomputer ~]# nice -n 20 bash
[root@mingmingxingforcomputer ~]#

五、查看進程、關閉進程方式

命令 格式 說明
pidof pidof [參數] 服務名稱 查詢某個指定服務進程的PID號碼值
kill kill [參數] 進程的PID 終止某個指定PID值的服務進程
killall killall [參數] 服務名稱 終止某個指定名稱的服務所對應的所有進程

使用:it

[root@mingmingxingforcomputer ~]# pidof bash
5488 4713 3053 1003
[root@mingmingxingforcomputer ~]# killall bash
相關文章
相關標籤/搜索