Open an app in Linux
Open app
For example open firefox, we can type in terminal
1 | firefox $ |
- no need go to specific folder, can directly type this command in the terminal
- The reason add
$
at end is aim to run firefox at backend, so that the terminal will not be occupied by Firefox- if you forget type
$
, you can typeCtrl+Z
and then typebg
and return.
Close app
1 | ps |
- show the currently running process
1 | ps aux |
- is to show all the currently running process and their state
1 | grep |
- it means search
1 | grep evince |
- search for evince process
1 | $ ps aux | grep evince #查到evince的进程 |
- |:管道符号,command1 |command2,将command1输出结果通过管道作为command2命令的输入参数.
1 | $ kill -s 9 pid #杀死进程号为PID的进程,例如:kill -9 6705 |
Some commands
ps命令 (Process Status)
ps aux
‘output format
1 | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND |
格式说明:
USER: 行程拥有者
PID: pid 就是这个程序的 ID
%CPU: 占用的 CPU 使用率
%MEM: 占用的记忆体使用率
VSZ: 占用的虚拟记忆体大小
RSS: 占用的记忆体大小
TTY: 终端的次要装置号码 (minor device number of tty)
STAT: 该行程的状态,linux的进程有5种状态:
D 不可中断 uninterruptible sleep (usually IO) (收到信号不唤醒和不可运行, 进程必须等待直到有中断发生)
R 运行 runnable (on run queue) (正在运行或在运行队列中等待)
S 中断 sleeping (休眠中, 受阻, 在等待某个条件的形成或接受到信号)
T 停止 traced or stopped (进程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信号后停止运行运行)
Z 僵死 a defunct (”zombie”) process (进程已终止, 但进程描述符存在, 直到父进程调用wait4()系统调用后释放)
注: 其它状态还包括W(无驻留页), <(高优先级进程), N(低优先级进程), L(内存锁页).
START: 进程开始时间
TIME: 执行的时间
COMMAND:所执行的指令