1. # ps [OPTION]...
    2. # OPTION STYLE: UNIX-style(-c), GNU-style(--dosomething), X-style(-dosomething), BSD-style(a)
    3. # a: 显示【所有用户】、【有 TTY】的进程
    4. # x: 无论有无 TTY
    5. # u: user-oriented output, 显示 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 信息
    6. # f: 使用树形结构(\_)格式化父子进程
    7. # --sort=[+|-NAME]... 根据 NAME 排序,+(升序,默认),-(降序),
    8. # e.g. ps faux --sort=uid,-user,+%cpu
    9. # -e, -A: 显示【所有用户】、【无论有无 TTY】的进程
    10. # e.g. ps ax = ps -e
    11. # -f: 显示 UID PID PPID C STIME TTY TIME CMD
    12. # -H: 树形结构(空格)格式化父子进程
    13. ps -ef --sort=cmd
    14. # jobs [OPTION]...
    15. # -l —Lists the process IDs along with the normal output
    16. # -n —Displays information only about jobs that have changed status since the user was last notified of their status
    17. # -r —Restricts output to running jobs
    18. # -s —Restricts output to stopped jobs
    19. # fg [%N] # 使 job number 为 N 的进程变为【前台】进程(如果不传 %N, 则选择最近交互的 job)
    20. # bg [%N] # 使 job number 为 N 的进程变为【后台】进程(如果不传 %N, 则选择最近交互的 job)
    21. # 在后台运行任务
    22. # command & # 运行一个
    23. # command1 & command2 & command3 & # 运行多个
    24. # command1 & | command2 & command3 & # 运行2个(后台运行command1的输出重定向给在后台运行的command2,这算是一个进程)
    25. # cmd -x # 原本想加个 & 使 cmd 在后台运行,但是忘记了
    26. # 按 CTRL+Z, 使 cmd 挂起
    27. # bg # 使 current job 即 cmd -x,变为后台程序
    28. # shell 关闭后,jobs 也会结束
    29. # 除非 1. 使用 byobu
    30. # 2. 守护进程(daemon)