Linux 系统命令

时间:2023-03-09 16:23:30
Linux 系统命令

1、ctrl+z 让正在运行的任务暂停运行, 然后可用 bg %jobId使之后台运行,相当于: 命令 &

2、 jobs -l 查看任务

3、 echo $$ 查看当前进程

4、nohup 或者 setpid 是 执行的程序进程脱离当前 shell

5、 unzip -o xxx.zip -d direcotry

6、 crontab -l 、 crontab -e

7、 du -sh 查看当前目录下文件总大小、 du -h --max-depth=1 查看当前目录下最上层个子目录的大小

8、 top 监控进程cpu 和内存

9、 free 查看内存使用

10、 whereis 文件名, 查找文件路径, 如: whereis java, which

  which       查看可执行文件的位置 
  whereis    查看文件的位置 
  locate       配 合数据库查看文件位置 
  find          实际搜寻硬盘查询文件名称

11、 uname -a、cat /proc/version、cat /etc/issue 查看系统信息

12、 让正在运行的运行的任务忽略hup信号,不再因为当前shell关闭而退出运行。disown -h %{jobid} 或 disown -ah | disown -rh。而单独 disown 命令会删除任务,千万别这么做~

disown [-ar] [-h] [jobspec ...] Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

  • disown -h jobspec 来使某个作业忽略HUP信号。
  • disown -ah 来使所有的作业都忽略HUP信号。
  • disown -rh 来使正在运行的作业忽略HUP信号。

参考资料:

1、 http://blog.sina.com.cn/s/blog_605f5b4f0100x2bq.html 让Linux终端中执行的程序在后台运行 从前台变到后台

2、 http://os.51cto.com/art/201312/425014.htm 十个鲜为人知的 Linux 命令 - Part 4

3、http://www.cnblogs.com/peida/archive/2012/11/09/2761928.html 每天一个linux命令(17):whereis 命令

4、Linux下which、whereis、locate、find 命令的区别

5、http://heylinux.com/archives/1282.html  Linux运行与控制后台进程的方法:nohup, setsid, &, disown, screen

6、Linux 技巧:让进程在后台可靠运行的几种方法  https://www.ibm.com/developerworks/cn/linux/l-cn-nohup/

7、http://blog.****.net/bytxl/article/details/24018015  linux进程后台运行的几种方法 - nohup/setsid/&/disown/screen