当前位置: 移动技术网 > 科技>操作系统>Linux > 系统相关命令

系统相关命令

2018年02月14日  | 移动技术网科技  | 我要评论

Linux 系统状态的查看及管理工具:

    pstree, ps, pidof,pgrep, top, htop, glance, pmap, vmstat, dstat, kill,pkill, job, bg, fg, nohup

pstree

    pstree - display a tree of processes
    pstree [ -a ] [ -c ] [ -h | -H PID ] [ -l ] [ -n ] [ -p ] [ -g ] [ -u ][ -A | -G | -U ] [ PID | USER ]
        -a      显示命令行参数
        -A      use ASCII line drawing(绘画) characters
        -c      不简洁输出相同的子结构
        -h      高亮显示当前进程和它们的父进程
        -H PID  高亮显示指定PID的进程和它们的父进程
        -G      use VT100 line drawing characters
        -l      不对长的行进行截断
        -n      通过PID来分类输出
        -p      显示PID
        -g,     显示进程组id
        -u      显示uid的过渡
        -U      使用UTF-8的格式来描绘字符
        -Z      显示SELinux安全内容
        PID     PID号,默认为1
        USER    用户

ps

    ps - report a snapshot(快照) of the current processes
        Linux 系统各进程的相关信息均保存在/proc/PID 目录下的各文件中
    ps [options]
    ps --help <simple|list|output|threads|misc|all>
     or 
    ps --help <s|l|o|t|m|a>
    ps --help s
        Basic options,基础选项:
        -A, -e                  所有进程
        -a                      带有tty,但没有会话发起者
         a                      带有tty,包含其他用户
        -d                      除去会话发起者本身
        -N, --deselect          否定选择
         r                      仅运行进程
         T                      在这个终端的所有进程
         x                      不带tty的进程
    
    ps --help l
        Selection by list,列表选择:
        -C <command>            命令名
        -G, --Group <GID>       真实组id或名称
        -g, --group <group>     会话或有效的组名
        -p, p, --pid <PID>      进程id
        --ppid <PID>    父进程id
        -q, q, --quick-pid <PID>    快速模式下的进程id
        -s, --sid <session>     会话id
        -t, t, --tty <tty>      终端
        -u, U, --user <UID>     有效的用户id或名称
        -U, --User <UID>        真实的用户id或名称
    
    ps --help o
        Output formats,输出格式:
        -F                      额外全部
        -f                      全部格式包括命令行
         f, --forest            ascii码art进程树
        -H                      显示进程等级
        -j                       工作的格式
         j                      BSD工作控制格式
        -l                      长格式
         l                      BSD 长格式
        -M, Z                   为SELinux添加安全数据
        -O <format>             使用默认列进行预加载
         O <format>             带有BSD个性,如-O一样
        -o, o, --format <format>    使用用户定义的格式
         s                      单一格式
         u                      用于所取的格式
         v                      虚拟内存格式
         X                      注册格式
        -y                      与-l一起,不显示flags,显示rss、vs、addr
        --context           显示SELinux的安全内容
        --headers           重复显示头行,每页一次
        --no-headers        不显示头行
        --cols, --columns, --width <num>    设置屏幕宽度
        --rows, --lines <num>   设置屏幕亮度
    
    ps --help t
        Show threads,显示线程:
         H                      如同进程一样
        -L                      可能显示带有LWP and NLWP 列
        -m, m                   在进程之后
        -T                      可能显示带有SPID列
    
    ps --help m
        Miscellaneous options:
         -c                     和-l一起显示时序安排级别
          c                     显示真实命令名
          e                     在命令后显示环境
          k,    --sort          显示分类命令,如同: [+|-]key[,[+|-]key[,...]]
          L                     显示格式说明符
          n                     显示数字版uid和wchan
          S,    --cumulative    包含include some dead child process data
         -y                     do not show flags, show rss (only with -l)
         -V, V, --version       display version information and exit
         -w, w                  unlimited output width
    示例:
        ps  -ef  :以完整的信息显示所有进程信息
        ps aux
        ps  axo  +指定的内容
        echo $$,显示当前进程编号
        查看每个进程在系统上的使用情况的标准语法
                  ps -e
                  ps -ef
                  ps -eF
                  ps -ely
        查看每个进程在系统上的使用情况的BSD语法
                  ps ax
                  ps axu
        打印进程树
                  ps -ejH
                  ps axjf
        显示线程的信息
                  ps -eLf
                  ps axms
        显示安全信息
                  ps -eo euser,ruser,suser,fuser,f,comm,label
                  ps axZ
                  ps -eM
        采用用户格式,查看root用户运行的每个进程
                  ps -U root -u root u
        
        采用用户定义的格式查看每个进程
                  ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
                  ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
                  ps -Ao pid,tt,user,fname,tmout,f,wchan
        仅显示系统log的进程id
                  ps -C syslogd -o pid=
        
        仅显示pid=42
                  ps -q 42 -o comm=
        搜索进程
            ps 选项|其他命令
            ps aux |grep ls
        
    结果中的含义
        ps -ef:
            UID/PID/PPID:   代表该进程的发起者/进程号/父进程号
            C:  代表cpu,单位是百分比
            STIME:  代表进程的启动时间,指的是进程什么时候启动的。
            TTY:    登录者的终端位置,远程登录的显示pst/n,本地登录的显示ttyn,?表示系统进程
            TIME:   进程实际花费cpu运行时间,不是系统时间
            CMD:    触发此进程的命令
        ps aux
            %MEM:   memory,进程所占用的物理内存的百分比
            VSZ:    Virtual memory SiZe ,进程使用掉的虚拟内存大小,单位为kb
            RSS:    ReSident Size,进程占用的固定内存大小,单位为kb
            TIME:   进程实际使用cpu 时间
            COMMAND:    触发此进程的命令
        ps  axo  pid,command,psr,pri,ni,rtprio(可以指定的还有很多,通过man ps查找解释)
            psr:    当前进程运行的cpu 编号
            pri:    当前进程的优先级
            ni: 当前进程的nice值
            rtprio:     实时优先级
        STAT:进程状态
            R:  running,运行状态
            S:  可中断的休眠
            D:  不可中断的休眠
            T:  stopped
            Z:  zombie,僵尸态
            +:      前台进程
            l:      多线程进程
            L : 内存分页并带锁
            N : 低优先级进程
            <:      高优先级进程
            s:  会话(子进程)发起者

nice

    nice - run a program with modified scheduling(计划中的) priority
    nice [-n] [COMMAND [ARG]...]
        -n, --adjustment=N      添加整数N给niceness,默认为10

renice

    renice - alter(更改) priority of running processes
    renice [-n] <priority> [-p|--pid] <pid>...
    renice [-n] <priority>  -g|--pgrp <pgid>...
    renice [-n] <priority>  -u|--user <user>...
        -g, --pgrp <id>         解释进程组id参数
        -n, --priority <num>    指定nice增量值
        -p, --pid <id>          解释进程id参数
        -u, --user <name|id>    解释用户id参数

pgrep&&pkill

    pgrep, pkill - look up or signal processes based on name and other attributes
        查找或标记基于名和其他参数的进程,是按预定义的模式来搜索进程的
    pgrep [options] <pattern>
    pkill [options] <pattern>
        -d, --delimiter <string>    指定输出分隔符
        -l, --list-name             列出pid和程序名
        -a, --list-full             列出pid和完全的命令行
        -v, --inverse               negates the matching
        -w, --lightweight           list all TID
        -c, --count                 计算匹配进程数
        -f, --full                  使用进程全名匹配
        -g, --pgroup <PGID,...>     匹配列出的进程组id
        -G, --group <GID,...>       匹配真实的组id
        -n, --newest                选择大部分近期启动的
        -o, --oldest                选择少量近期启动的
        -P, --parent <PPID,...>     仅匹配所给父进程的子进程
        -s, --session <SID,...>     匹配会话id
        -t, --terminal <tty,...>    匹配控制终端
        -u, --euid <ID,...>         匹配有效的uid
        -U, --uid <ID,...>          匹配真实的uid
        -x, --exact                 精确匹配命令名
        -F, --pidfile <file>        从文件中读取pid
        -L, --logpidfile            如果pid文件没被锁定那么就显示fail
        --ns <PID>                  match the processes that belong to the same namespace as <pid>
        --nslist <ns,...>           list which namespaces will be considered for the --ns option. Available namespaces: ipc, mnt, net, pid, user, uts
    示例:
        Find the process ID of the named daemon:
            $ pgrep -u root named
        Make syslog reread its configuration file:
            $ pkill -HUP syslogd
        Give detailed information on all xterm processes:
            $ ps -fp $(pgrep -d, -x xterm)
        Make all netscape processes run nicer:
            $ renice +4 $(pgrep netscape)

pidof

    pidof -- find the process ID of a running program.
        显示指定命令所启动的进程ID,查找一个运行项目的进程id。
    pidof [-s] [-c] [-n] [-x] [-m] [-o omitpid[,omitpid..]][-o omitpid[,omitpid..]..]program [program..]

top

    top - display Linux tasks
    top 动态持续监控进程的运行状态
    top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
    命令行选项 
        -h|-v   帮助和版本
        -b  批处理模式操作
        -c  命令行或项目名触发器
        -H  线程模式操作
        -i  闲置进程触发器
        -O  输出域名
        -s  安全模式操作
        -S  累计时间触发器
        -d  延迟时间间隔,如-d ss.
        -n  反复的次数,如-n number
        -u|-U   用户过滤模式,-u |-U number or name
        -p  监控pid模式 ,如-pN1 -pN2 ...or -pN1,N2,N3
        -o  覆写分类区域,如-o fieldname
        -w  输出宽度覆盖,-w [number]
    操作
        key/cmd     objective
        ^Z          挂起top
        fg          简要retop
        <Left>      强制屏幕重绘 (if necessary)
        reset       重启你的终端设置
        key         等价key组合
        Up          alt + \      or  alt + k
        Down        alt + /      or  alt + j
        Left        alt + <      or  alt + h
        Right       alt + >      or  alt + l (lower case L)
        PgUp        alt + Up     or  alt + ctrl + k
        PgDn        alt + Down   or  alt + ctrl + j
        Home        alt + Left   or  alt + ctrl + h
        End         alt + Right  or  alt + ctrl + l
        key         指定意义
        Up          召回老的字段来重新编辑
        Down        召回新的字段或删除整行
        Insert      触发插入和改写间的模式
        Delete      字符移动到光标出,移动其他到左侧
        Home        调到行首
        End         跳到行尾
    简易显示
         UPTIME and LOAD Averages
            top - 15:03:00 up  4:28,  3 users,  load average: 0.00, 0.01, 0.05
            项目或窗口名,显示模式,当前时间,状态,运行时长,用户数量,系统平均负载:1,5,15分钟时刻的数据。
        
        TASKs
            Tasks: 120 total,   1 running, 119 sleeping,   0 stopped,   0 zombie
            
        CPU States
            %Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
                us: user space,用户运行程序占用cpu的百分比
                sy: system(kernel space),用于运行内核占用的cpu的百分比
                ni: nice,用户进程空间所改变过优先级的进程占用cpu的百分比
                id: idle(闲置的),空闲cpu 百分比
                wa: wait IO,等待I/O花费的时间
                hi: hardware  interrupt,硬件中断占用cpu百分比
                si: software  interrupt,软件中断占用cpu百分比(模式切换)
                st: stolen ,被虚拟机偷走的百分比
            
            按t键进入t模式下
                %Cpu(s):   0.0/0.0     0[    
                %Cpu(s):   0.0/1.2     1[ 
                %Cpu(s):  75.0/25.0  100[ ...
                其中75.0代表us和ni的百分比,25.0是sy的百分比,100是前面百分比和,“...”表示前面信息以图形信息
        
        MEMORY Usage
            KiB Mem :   483616 total,    19900 free,   167636 used,   296080 buff/cache
            KiB Swap:  2097148 total,  2096812 free,      336 used.   254440 avail Mem 
            
            按m键进入m模式
                GiB Mem : 18.7/15.738   [ ...
                GiB Swap:  0.0/7.999    [ ...
                18.7表示百分比使用率,15.738表示总可用的,“...”表示图形显示
            
            单位转换
                按e或E键进行单位切换,e进行列表中的切换,E进行表头上的切换。
                KiB = kibibyte = 1024 bytes
                MiB = mebibyte = 1024 KiB = 1,048,576 bytes
                GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes
                TiB = tebibyte = 1024 GiB = 1,099,511,627,776 bytes
                PiB = pebibyte = 1024 TiB = 1,125,899,906,842,624 bytes
                EiB = exbibyte = 1024 PiB = 1,152,921,504,606,846,976 bytes
                
        DESCRIPTIONS of Fields
            PID         进程id             
            USER        用户名    
            PR          进程优先级,越小优先级越高
            NI          nice值             
            VIRT        进程需要的虚拟内存大小,而非使用的虚拟内存大小
            RES         进程当前使用的内存大小,不包括swap
            SHR         Shared Memory (KiB) ,进程与其他进程共享的内存大小,可以通过(RES - SHR)来计算进程所占用的物理内存大小
            %CPU        cpu使用率        
            S           Process Status,进程状态     
                D = 不间断休眠
                R = running
                S = sleeping
                T = stopped by job control signal
                t = stopped by debugger during trace
                Z =僵死态
            %MEM        内存使用率  
            TIME+       cpu使用时间的累加,小数点
            COMMAND     命令名或命令行   
            PPID        父进程id
            UID         用户id
            RUID        真实用户id
            RUSER       真实用户名      
            SUID        保存的用户id       
            SUSER       保存的用户名
            GID         组id
            GROUP       组名
            PGRP        进程组id    
            TTY         控制台tty
            TPGID       tty进程组identify
            SID         会话id     
            nTH         线程数   
            P           最后使用的cpu
            TIME        cpu时间
            SWAP        swap大小
            CODE        code大小
            DATA        数据+堆的大小
            nMaj        最大页面故障
            nMin        最小页面故障
            nDRT        脏页面数
            WCHAN       休眠的公共
            Flags       任务标志
            CGROUPS     控制组
            SUPGIDS     补充的组id
            SUPGRPS     补充的组名
            TGID        线程的组id
            ENVIRON     环境变量
            vMj         最大的故障增量差量
            vMn         最小的故障增差量
            USED        使用的内存
            nsIPC       IPC namespace Inode
            nsMNT       MNT namespace Inode 
            nsNET       NET namespace Inode 
            nsPID       PID namespace Inode 
            nsUSER      USER namespace Inode
            nsUTS       UTS namespace Inode 
            
    MANAGING Fields
        按f或F键进入到管理区域
        Fields Management for window 1:Def, whose current sort field is TIME+
        Navigate with Up/Dn, Right selects for move then <Enter> or Left commits,'d' or <Space> toggles display, 's' sets sort.  Use 'q' or <Esc> to end!
        
    INTERACTIVE Commands
        Global-Commands
            <Ent/Sp> ?, =, 0,
            A, B, d, E, e, g, h, H, I, k, q, r, s, W, X, Y, Z
        Summary-Area-Commands
            C, l, t, m, 1, 2, 3
        Task-Area-Commands
            Appearance:  b, J, j, x, y, z
            Content:     c, f, F, o, O, S, u, U, V
            Size:        #, i, n
            Sorting:     <, >, f, F, R
        Color-Mapping
            <Ret>, a, B, b, H, M, q, S, T, w, z, 0 - 7
        Commands-for-Windows
            -, _, =, +, A, a, g, G, w
        Scrolling-a-Window
            C, Up, Dn, Left, Right, PgUp, PgDn, Home, End
        Searching-in-a-Window
            L, &
            P   以占据的CPU 百分比,%CPU大小来排序
            M   以占据内存百分比,%MEM大小来排序
            T   累积占据CPU 时长,TIME+来排序
            l   uptime 信息,显示系统负载行
            t   tasks 及cpu 信息,显示进程摘要信息以及cpu负载状态,会进行几种显示切换
            1   cpu 分别显示,平均或单独显示cpu的负载状态
            2   显示%Node0相关信息
            m   想当于刷新,Enter也可以刷新
            q   退出命令
            s   修改延迟时长
            k   终止指定进程
            H   显示线程信息,Threads
            h   显示帮助信息
            E   切换表头上的单位
            e   切换表中的单位
            f和F 切换到区域管理
            t   切换tasks和%CPU的格式
            T   切换

htop

    需从Fedora-EPEL 源下载安装
    htop - interactive process viewer,交互式的进程查看
    htop [options]
    command-line options
        -C --no-color                   使用一个单颜色的方案
        -d --delay=DELAY                以秒为单位长度,在更新上设置延迟
        -s --sort-key=COLUMN            通过指定的列分类(try --sort-key=help for a list)
        -u --user=USERNAME              仅显示给定用户的进程
        -p --pid=PID,[,PID,PID...]      仅显示给出的PID的进程
    interactive command
        Arrows, PgUP, PgDn, Home, End   滚动进程列表
        space键  标记或取消标记的进程
        U   取消标记的所有进程
        s   追踪系统的进程调用
        l   显示进程打开的文件
        F1,h,?  进入帮助页面
         F2,S   进入配置界面,进行个性配置
        F3,/    递增地搜索显示的命令的行
        F4,\    递增的进程过滤
        F5,t    显示进程树
        F6  在分类视图中,选择范围进行分类
        F7,]    增加所选进程的优先级
        F8,[    减少所选进程的优先级
        F9,K    “杀死”所选的进程,即发送所选的信号给所选的进程
        F10,q   退出
        I   使被分类的表反向显示
        +,- 当在目录树模式下,来扩展或收缩树
        a   设置cpu的紧密度,(on multiprocessor machines)
        u   仅显示指定用户的进程
        M   按照内存使用率来分类
        P   按照进程使用来分类
        T   按照时间来分类
        F   
        K   隐藏内核线程
        H   隐藏用户线程
        Ctrl - L    刷新
        输入数值,如1234  PID搜索
    表头说明
        Command
             The full command line of the process (i.e program name and arguments).
        PID  
            The process ID.
        PPID 
            The parent process ID.
        PGRP 
            The process's group ID.
        SESSION (SESN)
             The process's session ID.
        TTY_NR (TTY)
             The controlling terminal of the process.
        TPGID
             The process ID of the foreground process group of the controlling terminal.
        STATE (S)
             The state of the process:
                S for sleeping (idle)
                R for running
                D for disk sleep (uninterruptible)
                Z for zombie (waiting for parent to read its exit status)
                T for traced or suspended (e.g by SIGTSTP)
                W for paging
        PROCESSOR (CPU)
             The ID of the CPU the process last executed on.
        NLWP The number of threads in the process.
        NICE (NI)
             The nice value of a process, from 19 (low priority) to  -20  (high  priority).  A  high
             value  means the process is being nice, letting others have a higher relative priority.
             Only root can lower the value.
        PERCENT_CPU (CPU%)
             The percentage of the CPU time that the process is currently using.
        UTIME (UTIME+)
             The user CPU time, which is the amount of time the process has spent executing  on  the
             CPU in user mode (i.e everything but system calls), measured in clock ticks.
        STIME (STIME+)
             The  system CPU time, which is the amount of time the kernel has spent executing system
             calls on behalf of the process, measured in clock ticks.
        TIME (TIME+)
             The time, measured in clock ticks that the process has spent in user  and  system  time
             (see UTIME, STIME above).
        CUTIME
             The  children's  user  CPU  time,  which is the amount of time the process's waited-for
             children have spent executing in user mode (see UTIME above).
        CSTIME
             The children's system CPU time, which is the amount of time the kernel has  spent  exe‐
             cuting  system  calls  on  behalf  of  all the process's waited-for children (see STIME
             above).
        PRIORITY (PRI)
             The kernel's internal priority for the  process,  usually  just  its  nice  value  plus
             twenty. Different for real-time processes.
        PERCENT_MEM
             The  percentage  of memory the process is currently using (based on the process's resi‐
             dent memory size, see M_RESIDENT below).
        M_SIZE (VIRT)
             Size in memory of the total program size.
        M_RESIDENT (RES)
             The resident set size, i.e the size of the text and data sections, plus stack usage.
        M_SHARE (SHR)
             The size of the process's shared pages
        M_TRS (CODE)
             The size of the text segment of the process (i.e the size of the  processes  executable
             instructions).
        M_LRS (LIB)
             The library size of the process.、
        M_DRS (DATA)
             The size of the data segment plus stack usage of the process.
        M_DT (DIRTY)
             The size of the dirty pages of the process.
        ST_UID (UID)
             The user ID of the process owner.
        USER 
            The username of the process owner, or the user ID if the name can't be determined.
        STARTTIME
             The time the process was started.
        RCHAR (RD_CHAR)
             The number of bytes the process has read.
        WCHAR (WR_CHAR)
             The number of bytes the process has written.
        SYSCR (RD_SYSC)
             The number of read(2) syscalls for the process.
        SYSCW (WR_SYSC)
             The number of write(2) syscalls for the process.
        RBYTES (IO_RBYTES)
             Bytes of read(2) I/O for the process.
        WBYTES (IO_WBYTES)
             Bytes of write(2) I/O for the process.
        IO_READ_RATE (IORR)
             The I/O rate of read(2) in bytes per second, for the process.
        IO_WRITE_RATE (IOWR)
             The I/O rate of write(2) in bytes per second, for the process.
        IO_RATE (IO)
             The I/O rate, IO_READ_RATE + IO_WRITE_RATE (see above).
        CNCLWB (IO_CANCEL)
             Bytes of cancelled write(2) I/O.
        CGROUP
             Which cgroup the process is in.
        CTID 
            OpenVZ container ID, a.k.a virtual environment ID.
        VPID
            OpenVZ process ID.
        VXID 
            VServer process ID.
        OOM  
            OOM killer score.
        All other flags
             Currently unsupported (always displays '-').

uptime

    uptime - Tell how long the system has been running.
        显示当前时间,系统已启动的时间、当前上线人数,系统平均负载(1 、5 、10 分钟的平均负载,一般不会超过1) 
        系统平均负载是指在特定时间间隔内运行队列中的平均进程数
        通常每个CPU内核的当前活动进程数不大于3,那么系统的性能良好。 
        如果每个CPU 内核的任务数大于5,那么此主机的 性能有严重问题
        如果linux 主机是1个双核CPU,当Load Average 为6的时候说明机器已经被充分使用
    uptime [options]
         -p, --pretty       采用漂亮格式显示
          -s, --since       系统启动时间

vmstat

    vmstat - Report virtual memory statistics
        动态显示系统资源的使用情况,包括内存、磁盘、网络、cpu等资源
    vmstat [options] [delay [count]]
    命令行选项
        -a, --active            active/inactive memory
        -f, --forks             从启动后有多少叉形指定(fork)
        -m, --slabs             slabinfo,池信息
        -n, --one-header        不重复显示头部
        -s, --stats             事件数量统计
        -d, --disk              磁盘统计
        -D, --disk-sum          磁盘统计总概括
        -p, --partition <dev>   指定统计分区
        -S, --unit <char>       定义显示单位
        -w, --wide              扩展输出
        -t, --timestamp         显示时间戳
    显示
        procs:
            r:  可运行(正运行或等待运行)进程的个数,和核心数有关(队列长度)
            b:  处于不可中断睡眠态的进程个数( 被阻塞的队列的长度)(IO阻塞的队列长度)
        memory:
            swpd:   交换内存的使用总量
            free:   空闲物理内存总量
            buffer(缓存): 用于buffer 的内存总量
            cache(高速缓存):    用于cache 的内存总量
        swap(交换):
            si: 从磁盘交换进内存的数据速率(kb/s)
            so: 从内存交换至磁盘的数据速率(kb/s)
        io:
            bi: 从块设备读入数据到系统的速率(kb/s)
            bo:     保存数据至块设备的速率
        system:
            in:     interrupts 中断速率,包括时钟,每秒中被中断的次数
            cs:     context switch 进程切换速率
        cpu:
            us: user space,用户运行程序占用cpu的百分比
            sy: system(kernel space),用于运行内核占用的cpu的百分比
            id: idle(闲置的),空闲cpu 百分比
            wa: wait IO,等待I/O花费的时间
            st: stolen ,被虚拟机偷走的百分比

iostat

    iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
        统计CPU 和设备IO 信息
    iostat [ options ] [ <interval> [ <count> ] ]
         -c  显示cpu报告  
         -d 显示设备报告   
         -h     可读性显示
         -k | -m    以KB或MB显示
         -N     显示注册设备的映射名
         -t     显示每个报告显示的时间
         -x     显示扩展的统计
         -y     忽略系统启动后的第一个报告
         -z     在取样期间,忽略任何设备的输出
         -j { ID | LABEL | PATH | UUID | ... }  显示设备名,ID等是指定类型
         -T     与-g配合,进行显示组中私有设备的全局统计
         -g <group_name>    显示一个组的设备统计   
         -p <device> ,... | ALL  <device> ... | ALL     显示被系统调用的块设备和它们分区的统计
    示例
        iostat
            Display a single history since boot report for all CPU and Devices.
        iostat -d 2
            Display a continuous device report at two second intervals.
        iostat -d 2 6
            Display six reports at two second intervals for all devices.
        iostat -x sda sdb 2 6
            Display six reports of extended statistics at two second intervals for devices sda and sdb.
        iostat -p sda 2 6
            Display six reports at two second intervals for device sda and all its partitions (sda1, etc.)
    相关文件
        系统统计
            /proc/stat 
        系统运行时间
            /proc/uptime 
        磁盘状态
            /proc/diskstats 
        块设备统计
            /sys 
        网络文件统计
            /proc/self/mountstats 
        当前设备名
            /dev/disk 

pmap

    pmap - report memory map of a process,进程对应的内存映射
    pmap [options] PID [PID ...]
    cat /proc/PID/maps
        -x, --extended          显示详情
        -X                              显示更加详细,警告:格式更改依赖于 /proc/PID/smaps
        -XX                          显示内核提供的任何信息
        -c, --read-rc                   读取默认的rc
        -C, --read-rc-from=<file>       从文件中读取rc
        -n, --create-rc                 创建新的默认的rc
        -N, --create-rc-to=<file>       创建新村rc到文件,注意pid参数不允许配合 -n, -N
        -d, --device                    显示设备格式
        -q, --quiet                     不显示头部和页脚
        -p, --show-path                 显示映射路径
        -A, --range=<low>[,<high>]      限制结果范围
    

glances

    glances是一款用于linux、BSD的开源命令行系统监控工具,它使用python开发语音开发,能够监视cpu、负载、内存、磁盘I/O、网络流量、文件系统、系统温度等信息。安装包在EPEL源。
    glances - A cross-platform curses-based system monitoring tool
    glances [OPTIONS]
    命令行选项
        -d, --debug             激活调试模式
        -C CONF_FILE    配置文件路径
        -3, --disable-quicklook     取消快速查看模式
        -4, --full-quicklook    取消几乎所有快速查看和加载
        --disable-cpu           取消cpu模式
        --disable-mem           取消内存模式
        --disable-swap          取消swap模式
        --disable-load          取消加载模式
        --disable-network       取消网络模式
        --disable-ip            取消ip模式
        --disable-diskio        取消磁盘IO模式
        --disable-fs            取消文件系统模式
        --disable-sensors       取消感应器模式
        --disable-hddtemp       取下HD温度模式
        --disable-raid          取消RAID模式
        --disable-docker        取消docker模式
        -2, --disable-left-sidebar   (py3sensors needed)取消网络,cipanIO,文件系统,触发器模式
        --disable-process       取消进程模式
        --disable-log           取消日志模式
        --disable-bold          取消在终端的加粗模式
        --enable-process-extended   激活在top进程中的扩展状态
        --enable-history        激活历史记录模式
        --path-history PATH_HISTORY     为图形历史设置输出路径
        --export-csv EXPORT_CSV     输出状态到一个CSV文件
        --export-influxdb        (influxdb needed)输出状态到一个influxDB服务
        --export-opentsdb       (potsdb needed)输出状态到一个openTSDB服务
        --export-statsd         (statsd needed)输出状态到一个statsD 服务
        --export-rabbitmq        (pika needed)输出状态到一个消息队列中间件
        -c CLIENT, --client CLIENT  通过ipv4/ipv6连接到glances服务
        -s, --server            在服务模式运行glances
        --browser                (list of servers)开启客户端浏览
        --disable-autodiscover  取消自动发现特性
        -p PORT, --port PORT    [default: 61209]定义客户端或服务器Tcp端口
        -B BIND_ADDRESS, --bind BIND_ADDRESS    绑定服务到给定的IPV4/ipv6地址或主机名
        --password              定义一个客户端或服务密码
        --snmp-community SNMP_COMMUNITY     SNMP 通信
        --snmp-port SNMP_PORT   SNMP 端口
        --snmp-version SNMP_VERSION SNMP 版本(1, 2c or 3)
        --snmp-user SNMP_USER   SNMP username用户名 (only for SNMPv3)
        --snmp-auth SNMP_AUTH   SNMP 认证密钥authentication key (only for SNMPv3)
        --snmp-force    强制SNMP模式
        -t TIME, --time TIME     [default: 3 sec]设置秒级别的更新
        -w, --webserver          (bottle needed)运行glances在web服务模式
        -q, --quiet             不显示安全接口
        -f PROCESS_FILTER,  (regular expression)设置进程过滤模式
        --process-short-name    强制使用简短名为进程名
        -0, --disable-irix      任务cpu使用率将被总的cpu划分
        --hide-kernel-threads   在进程列表中隐藏内核线程
        --tree                  用树状结构显示进程
        -b, --byte              采用b/s显示网络使用率
        --fahrenheit            使用华氏温度单位显示温度
        -1, --percpu            在每个cpu模式上开启glances
        --fs-free-space         显示纹系统空间取代使用率
        --theme-white           优化显示白色背景颜色
    交互式命令
        ENTER   设置进程过滤模式,使用正则表达式
        a       自动进程分类
        b       切换网络I/O的单位
        c       通过CPU使用率进行分类进程
        d       显示或隐藏磁盘I/O状态
        e       激活或关闭top扩展状态
        f       显示或因此文件系统状态
        F       在使用率或空余间切换
        g       生成当前历史的图表
        h       显示或隐藏帮助页面
        i       使用I/O使用率分类进程
        l       显示或隐藏日志信息
        m       MEM使用率分类进程
        n       显示或隐藏网络状态
        p       使用名称分类进程
        q       Quit
        r       重设历史
        s       显示隐藏传感器状态
        t       CPU times (TIME+)cpu时间分类进程
        T       合并的网络I/O视图
        u       使用用户分类进程
        U       显示累积的网络I/O视图
        w       删除结束的告警日志信息
        x       删除结束的告警或严重错误信息
        z        显示或隐藏进程状态
        z       显示或隐藏低cpu消耗的进程列表
        0        cpu总数分割任务cpu使用率
        1       在全局cpu和每个cpu间状态切换
        2        激活或关闭左边列
        3        激活或关闭快查模块
        4       激活或关闭所有快查和负载模块
        /        切换命令名的长短
    
    glances 支持远程模式,即可以以C/S 模式工作:
        server:
            服务器模式,以监听模式启动glances
            启动:glances -s -B IPADDR  ##-B:用于指明监听的本地地址,IPADDR: 指明监听的本机哪个地址
        Client:
            客户端模式,以远程模式启动glances,远程连入指定服务器,并且server上的相关性能数据
            启动:glances -c IPADDR  ##-c:用于连入的服务器的地址,IPADDR :要连入的服务器端地址
    
    示例
        Monitor local machine (standalone mode):
            $ glances
        Monitor local machine with the Web interface (Web UI):
            $ glances -w
            Glances web server started on http://0.0.0.0:61208/
        Monitor local machine and export stats to a CSV file (standalone mode):
            $ glances --export-csv
        Monitor local machine and export stats to a InfluxDB server with 5s refresh time (standalone mode):
            $ glances -t 5 --export-influxdb
        Start a Glances server (server mode):
            $ glances -s
        Connect Glances to a Glances server (client mode):
            $ glances -c <ip_server>
        Connect Glances to a Glances server and export stats to a StatsD server (client mode):
             $ glances -c <ip_server> --export-statsd
        Start the client browser (browser mode):
            $ glances --browser

dstat

    系统资源统计, 可以代替vmstat,iostat,netstat和ifstatd的多功能产品。
    增加了监控项,可以很方便监控系统运行状况并用于基准测试和排除故障。
    paging:
        系统分页活动,分页指的是一种内存管理技术用于查找系统场景,一个较大的分页表明系统正在使用大量的交换空间,或者说内存非常分散,大多数情况下你都系统看到page in(换入)和page out(换出)的值为0
    system:
        显示的是中断(init)和上下文切换(csw),比较基线时才有意义。这一栏中较高的统计值通常便是大量的进程造成的拥塞,需对cpu进行关注。
    dstat - versatile tool for generating system resource statistics
    dstat [-afv] [options..] [delay [count]]
        -c, --cpu               显示cpu 相关信息,-C #,#,...,total
        -C 0,3,total            显示包含 cpu0, cpu3 and total
        -d, --disk              显示disk 相关信息-D total,sda,sdb,...
        -D total,hda            显示包含hda and total
        -g, --page              显示page 相关统计数据
        -i, --int               显示interrupt相关的速率数据
        -I 5,eth2               显示包括 int5 和使用eth2的中端
        -l, --load              显示load average相关的统计数据
        -m, --mem               显示memory 相关统计数据
        -n, --net               显示network 相关统计数据
        -N eth1,total           显示包括eth1 and total
        -p, --proc              显示process 相关统计数据
        -r, --io                显示io 请求相关的统计数据
        -s, --swap              显示swapped 相关的统计数据
        -S swap1,total          显示包括swap1 and total
        -t, --time              启动时间/日期输出
        -T, --epoch             启用时间计数器
        -y, --sys               显示系统相关的数据,包括中断和进程切换
        --aio                   启用aio状态
        --fs, --filesystem      启动文件系统状态
        --ipc                   显示进程间通信相关的速率数据
        --lock                  启用lock状态enable lock stats
        --raw                   显示raw套接的相关数据
        --socket            启用sock而状态
        --tcp               显示tcp套接字的相关数据
        --udp               显示udp套接字的相关数据
        --unix                  显示unix sock接口相关的统计数据
        --vm                启用vm状态
        --plugin-name           通过插件名激活插件
        --list              显示所有可用的插件
        -a, --all           equals -cdngy (default)
        -f, --full          自动扩展-C, -D, -I, -N and -S lists
        -v, --vmstat    等同 -pmgdsc -D total
        --bits              强制使用bits来表示bytes
        --float             强制使用浮点型值
        --integer       强制使用整数值
        --bw, --blackonwhite    为白色背景终端更改颜色
        --nocolor           关闭颜色
        --noheaders     关闭重复头部
        --noupdate      关闭中间件更新
        --output file       把CSV输出到文件
        --profile           show profiling statistics when exiting dstat
        --top-cpu : 显示最占用CPU 的进程
        --top-io:   显示最占用io 的进程
        --top-mem:      显示最占用内存的进程
        --top-latency:      显示延迟最大的进程
        --top-bio   显示最消耗block io的进程
        delay   表示刷新时间,以秒为单位
        count   表示刷新数量
    示例
        显示最占内存的一些进程信息:
            dstat -g -I -m -s --top-mem
        显示最消耗cpu资源的信息:
            dstat -c -y -I --proc-count --top-cpu
        Using dstat to relate disk-throughput with network-usage (eth0), total CPU-usage and system counters:
            dstat -dnyc -N eth0 -C total -f 5
        Checking dstat’s behaviour and the system impact of dstat:
            dstat -taf --debug
        Using the time plugin together with cpu, net, disk, system, load, proc and top_cpu plugins:
            dstat -tcndylp --top-cpu
            this is identical to
            dstat --time --cpu --net --disk --sys --load --proc --top-cpu
        Using dstat to relate cpu stats with interrupts per device:
            dstat -tcyif

kill

    向进程发送控制信号,以实现对进程管理,每个信号对应一个数字,信号名称以SIG 开头(可省略 ),不区分大小写
    kill - terminate a process
    kill [-s sigspec | -n  signum | -signal]   pid | jobs ... 
    kill -l [signal]
        pid n代表pid的值,0代表在当前进程组中的所有进程,-1代表比1大的pid,-n代表进程组n,commandname代表命令
        -s|-n signal    指定发送的信号,-s后跟名,-n后跟数字
        -l [signal] 显示信号列表,或显示指定信号的数值
        -L  与-l相似,将显示信号名和它们相关的数字
        -a  显示所有,不做限制
        -p  指定要显示的pid的信息
        -q sigval   
            
    显示当前系统的可用信号
        kill -l or trap -l
    查看信号的解释
        man 7 signal
        0  :    配合echo !$ 来确认状态是否正常
        1) SIGHUP:      无须关闭进程而让其重读配置文件
        2) SIGINT:      中止正在运行的进程;相当于Ctrl+c
        3) SIGQUIT:     相当于ctrl+\
        9) SIGKILL:     强制杀死正在运行的进程
        15) SIGTERM :   正常终止正在运行的进程
        18) SIGCONT :   继续运行
        19) SIGSTOP :   后台休眠,暂停进程
    指定信号的方法:
        信号的数字标识:1, 2, 9
        信号完整名称:SIGHUP 
        信号的简写名称:HUP
    示例:
        kill [-SIGNAL] pid …
        kill –n SIGNAL pid
        kill –s SIGNAL pid
        

killall

    killall - kill processes by name
    killall [-Z CONTEXT] [-u USER] [ -eIgiqrvw ] [ -SIGNAL ] NAME...
    killall -l, --list
        -e,--exact              要求精确匹配名称
        -I,--ignore-case        不区分大小写的进程名称匹配
        -g,--process-group      终止进程组
        -y,--younger-than       杀死比TIME更年轻的进程
        -o,--older-than         杀死比TIME更老的进程
        -i,--interactive        交互模式,在杀死之前进行询问
        -l,--list               显示所有信号名
        -q,--quiet          不输出详情
        -r,--regexp             将名称解释为扩展正则表达式
        -s,--signal SIGNAL      发送指定的SIGNAL来代替SIGTERM
        -u,--user USER          仅杀死指定用户的进程
        -v,--verbose            显示详情
        -w,--wait               等待进程死去
        -Z,--context REGEXP     仅终止具有上下文的进程 (必须在其他参数之前)

nohup

    nohup - run a command immune to hangups, with output to a non-tty
    nohup COMMAND [ARG]...
    如果标准输入是一个终端,重定向到/dev/null。
    如果标准输出是一个终端,可能附加到nohup.out,或者$HOME/nohup.out。
    如果标准错误是一个i终端,重定向到标准输出。
    重定向:nohup COMMAND > FILE

screen

    screen - screen manager with VT100/ANSI terminal emulation
    screen [-opts] [cmd [args]]
    screen -r [host.tty]
        -A      将所有的视窗都调整为目前终端机的大小。
        -d <作业名称>   将指定的screen作业离线。
        -h <行数>     指定视窗的缓冲区行数。
        -m      即使目前已在作业中的screen作业,仍强制建立新的screen作业。
        -r <作业名称>   恢复离线的screen作业。
        -R      先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。
        -s      指定建立新视窗时,所要执行的shell。
        -S <作业名称>   指定screen作业的名称。
        -v      显示版本信息。
        -x      恢复之前离线的screen作业。
        -ls或--list      显示目前所有的screen作业。
        -wipe   检查目前所有的screen作业,并删除已经无法使用的screen作业。
    
    示例:
        创建新screen 会话
            screen –S [SESSION]
        加入screen 会话
            screen –x [SESSION]
        退出并关闭screen 会话
            exit
        剥离当前screen 会话
            Ctrl+a,d
        显示所有已经打开的screen 会话
            screen -ls
        恢复某screen 会话
            screen -r [SESSION]

systemd-tmpfiles

    systemd-tmpfiles-Creates, deletes and cleans up volatile(易变的)and temporary files and directories.管理临时文件和目录
    systemd-tmpfiles [OPTIONS...] [CONFIGURATION FILE...]
        --create                创建带有标记的文件或目录
        --clean                 清空带有标记的目录
        --remove                删除带有标记的文件或目录
        --boot                  在启动时执行安全的操作
        --prefix=PATH           仅应用带有指定前缀的规则
        --exclude-prefix=PATH   忽略带有指定前缀的规则
        --root=PATH             Operate on an alternate filesystem root
        
        CentOS6 使用/etc/cron.daily/tmpwatch定时清除临时文件
        CentOS7 使用systemd-tmpfiles-setup 服务实现
    配置文件:
        /etc/tmpfiles.d/*.conf
        /run/tmpfiles.d/*.conf
        /usr/lib/tmpfiles/*.conf
        /usr/lib/tmpfiles.d/tmp.conf
        /tmp 1777 root root 10d
        /var/tmp 1777 root root 30d
        

sleep

    sleep - delay for a specified amount of time
    sleep NUMBER[SUFFIX]…
        NUMBER  数字
        SUFFIX  可为s,m,h,d;分别代表秒,分,时,天

chkconfig

    chkconfig - updates and queries runlevel information for system services
        主要用于维护/etc/rc[0-6].d的目录,在7以前版本和7以后的版本有所不同。
        7以前主要是SysV 服务和xinetd服务,7之后为systemd的服务,且在7中使用也仅显示SysV的服务,且管理已经被systemd代替。
    chkconfig [--list] [--type <type>] [name]
    chkconfig --add <name>
    chkconfig --del <name>
    chkconfig --override <name>
    chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>
        --list  查看服务在所有级别的启动或关闭设定情形
        --type  指定sysv服务还是xinetd服务
        --add   为某存放在/etc/init.d的服务在对应的/etc/rc.d/rc0-6.d目录下添加符号链接
        --del   把指定SERVICE_SCRIPTS的在7个级别符号链接统统删除
        --level     指定要设置的级别,省略时表示2345
        --override  覆盖
        resetpriorities 重启开启或关闭服务的优先顺序,不考虑init脚本的情况
    xinetd 管理的服务
        瞬态(Transient )服务被xinetd 进程所管理
        进入的请求首先被xinetd代理
        配置文件:
            /etc/xinetd.conf 
            /etc/xinetd.d/<service>
        用chkconfig 控制的服务,与libwrap.so 文件链接

ntsysv

    ntsysv - simple interface for configuring runlevels,经由chkconfig来配置服务运行水平的,是个交互式的工具,
    ntsysv [--back] [--level <levels>]
        --back  在交互界面出现back按钮
        --level 运行水平指定,如--level 016来编辑runlevels为0,1,6.

service

    service - run a System V init script
    service < option > | --status-all | [ service_name [ command | --full-restart ] ]
        SCRIPT: /etc/init.d/SCRIPT
        COMMADN:    start|stop|restart
        --status-all:   运行所有初始化脚本,按照字母顺序,并带有状态命令

systemctl

    systemctl - Control the systemd system and service manager
    systemctl [OPTIONS...] COMMAND [NAME...]
    Query or send control commands to the systemd manager.
           --system             连接到系统管理
          -H --host=[USER@]HOST     在远处主机上操作
          -M --machine=CONTAINER    在本地容器上操作
          -t --type=TYPE        列出指定类型的--state=STATE的单元,
          -p --property=NAME    仅显示指定名称的信息
          -a --all               显示所有加载的单元或性能
          -l --full             不翻译单元名称作为输出
          -r --recursive         显示主机的单元列表和本地容器
          --reverse         一起显示反转的依赖性
          --job-mode=MODE   指定怎样解决已经存在的队列任务,当排到一个新的任务时候
          --show-types      当显示sockets时,明确地显示他们的类型
          -i --ignore-inhibitors    当关闭或睡眠时,忽略抑制
          --kill-who=WHO    谁发送信号
          -s --signal=SIGNAL    发送那个信号
          --now             开启或关闭单元,且激活或取消单元
          -q --quiet            抑制输出
          --no-block        不等到操作结束
          --no-wall         在关机前不发送wall信息
          --no-reload       在取消单元文件后不重新加载后台进程
          --no-legend       不显示图标
          --no-pager        不使用管道输出到pager
          --no-ask-password     不询问系统密码
          --global          激活或取消全局单元文件
          --runtime         仅临时激活单元文件直到下个重启
          -f --force            当激活单元文件,覆盖已经存在的软连接,当关闭时,立即执行
          --preset-mode=    应用仅激活,取消,或执行所有预设
          --root=PATH       激活单元文件在指定的root根目录下
          -n --lines=INTEGER    显示日报实体号码
          -o --output=STRING    (short, short-iso, short-precise, short-monotonic, verbose, export, json, json-pretty, json-sse, cat)更改日志输出模式
          --plain           显示单元依赖性作为一个列表来取代树状输出
    Unit Commands:
          list-units [PATTERN...]           列出加载的单元List loaded units
          list-sockets [PATTERN...]         列出加载的sockets,并按照地址排列
          list-timers [PATTERN...]          列车加载的定时器,以消逝时间排列
          start NAME...                     开始或激活一个或多个单元
          stop NAME...                      停止或取消一个或多个单元
          reload NAME...                    重载一个或多个单元
          restart NAME...                   开启或重启一个或多个单元
          try-restart NAME...               重启一个或多个单元,若已经为激活状态
          reload-or-restart NAME...         若可能的话,重载一个或多个单元,否则开启或重启          
          reload-or-try-restart NAME...     若能则重载一个或多个单元,否则若激活状态则重启
          isolate NAME                      启动一个单元和停止所有其他的单元
          kill NAME...                      发送信号给一个单元的进程
          is-active PATTERN...              检查单元是否已经被激活
          is-failed PATTERN...              检查单元是否已经失败
          status [PATTERN...|PID...]        显示一个或多个单元的运行状态
          show [PATTERN...|JOB...]          显示一个或多个单元/任务/管理的性能
          cat PATTERN...                    显示一个或多个单元的文件和混入信息
          set-property NAME ASSIGNMENT...   设置一个或多个单元的性能
          help PATTERN...|PID...            显示手册
          reset-failed [PATTERN...]         为所有,一个或多个重设失败状态
          list-dependencies [NAME]          递归显示所需的单元
    Unit File Commands:
          list-unit-files [PATTERN...]      显示已安装的单元文件
          enable NAME...                    激活一个或多个单元文件
          disable NAME...                   取消一个或多个单元文件
          reenable NAME...                  重新激活一个或多个单元文件
          preset NAME...                    激活或取消一个或多个基于事先设定配置的单元文件
          preset-all                        激活或取消所有基于事先配置的单元文件
          is-enabled NAME...                检查单元文件是否被激活
          mask NAME...                      标记一个或多个单元
          unmask NAME...                    取消标记一个或多个单元
          link PATH...                      连接一个或多个单元文件到搜索路径
          add-wants TARGET NAME...          添加wants依赖性为目标,在指定的一个或多个单元上
          add-requires TARGET NAME...       在指定的一个多个单元上为目标添加requires依赖
          edit NAME...                      编辑一个或多个单元文件
          get-default                       取得默认目标名
          set-default NAME                  设置默认目标
    Machine Commands:
          list-machines [PATTERN...]         列出本地容器和主机
    Job Commands:
          list-jobs [PATTERN...]            列车任务
          cancel [JOB...]                   取消所有,一个或多个任务
    Snapshot Commands:
          snapshot [NAME]                   创建快照
          delete NAME...                    移动一个或多个快照
    Environment Commands:
          show-environment                  显示环境
          set-environment NAME=VALUE...     设置一个或多个环境变量
          unset-environment NAME...         取消设置一个或多个环境变量
          import-environment [NAME...]      输入所有或一些环境变量
    Manager Lifecycle Commands:
          daemon-reload                     重载系统管理配置
          daemon-reexec                     重新执行systemd管理
    System Commands:
          is-system-running                 检查系统是否全速运行
          default                           进入系统默认模式
          rescue                            进入系统安全模式
          emergency                         进入系统紧急模式
          halt                              关闭系统
          poweroff                          关闭系统,关闭电源
          reboot [ARG]                      重启系统
          kexec                             使用kexec重启系统
          exit                              要求用户实例退出
          switch-root ROOT [INIT]           切换到一个不同的root文件系统
          suspend                           抑制系统
          hibernate                         休眠系统
          hybrid-sleep                      抑制休眠系统
    示例:
        管理服务
            启动:
                service name start ==> systemctl start  name.service
            停止:
                service name stop ==> systemctl stop  name.service
            重启:
                service name restart ==> systemctl restart  name.service
            状态:
                service name status ==> systemctl status  name.service
            条件式重启:
                已启动才重启,否则不做操作
                service name condrestart ==> systemctl try-restart name.service
            重载或重启服务:
                先加载,再启动
                systemctl reload-or-restart name.service
            重载或条件式重启服务:
                systemctl reload-or-try-restart name.service
            禁止自动和手动启动:
                systemctl mask name.service
            取消禁止:
                systemctl unmask name.service
        查看服务
            查看某服务当前激活与否的状态:
                systemctl is-active name.service
            查看所有已经激活的服务:
                systemctl list-units [--type|-t] service
            查看所有服务:
                systemctl list-units --type service [–all|-a]
            chkconfig 命令的对应关系:
                设定某服务开机自启:
                    chkconfig name on ==> systemctl enable name.service
                设定某服务开机禁止启动:
                    chkconfig name off ==> systemctl disable name.service
            查看所有服务的开机自启状态:
                chkconfig --list ==> systemctl  list-unit-files --type service
            用来列出该服务在哪些运行级别下启用和禁用
                chkconfig sshd –list ==>ls /etc/systemd/system/*.wants/sshd.service
            查看服务是否开机自启:
                systemctl is-enabled name.service
            查看服务的依赖关系:
                systemctl list-dependencies name.service
            杀掉进程:
                systemctl kill 进程名
        服务状态
            显示状态命令
                systemctl list-unit-files --type service --all 
            loaded  Unit配置文件已处理
            active(running):    一次或多次持续处理的运行
            active(exited):     成功完成一次性的配置
            active(waiting):    运行中,等待一个事件
            inactive:   不运行
            enabled:    开机启动
            disabled:   开机不启动
            static:     开机不启动,但可被另一个启用的服务激活

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网