Linux管理程序的几个常用指令
背景执行:执行完毕后显示在终端 & ,如果要将其显示出来用fg命令
linux:/ # cp test1 test2 &
[1] 9039
jobs查看背景下的工作,在配合fg可将程序调出来
如果你正在进行 vi ,而且是在编辑一个重要数据文件,但是偏偏你想起有的程序需要留意,因此需要退出 vi ,不过,你并不想这个时候储存退出 vi ,那么该如何是好呢?!就将资料丢到背景里面去吧!以上面的例子来说明,当你在执行编辑 /root/test 这个档案时,想要暂时离开,那么就直接在 vi 的『一般模式』当中输入[Ctrl] 加上 z (小写)按键,,那么系统就会告诉你『工作项目 [1] 在背景当中,而其状态为[Stopped]亦即是停止的状态!』,并且会离开 vi 进入到 command line 当中,等待使用者输入指令!这个咚咚很好用的呦!那如果想要回到 vi 呢?!呵呵,就需要使用 jobs 配合 bg 或 fg 啰!
linux:/ # vi test1
[1] Done cp test1 test2
[2]+ Stopped vi test1
linux:/ # echo 123
123
linux:/ # jobs
[2]+ Stopped vi test1
linux:/ # fg 2
查看系统进程
linux:/ # ps -aux Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2200 712 ? Ss 16:29 0:01 init [5] root 2 0.0 0.0 0 0 ? S 16:29 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 16:29 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S 16:29 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 16:29 0:00 [watchdog/0] root 6 0.0 0.0 0 0 ? S 16:29 0:00 [migration/1] root 7 0.0 0.0 0 0 ? S 16:29 0:00 [ksoftirqd/1] root 8 0.0 0.0 0 0 ? S 16:29 0:00 [watchdog/1] root 9 0.0 0.0 0 0 ? S 16:29 0:00 [migration/2] root 10 0.0 0.0 0 0 ? S 16:29 0:00 [ksoftirqd/2] root 11 0.0 0.0 0 0 ? S 16:29 0:00 [watchdog/2] root 12 0.0 0.0 0 0 ? S 16:29 0:00 [migration/3] root 13 0.0 0.0 0 0 ? S 16:29 0:00 [ksoftirqd/3]
配置kill即可结束某个特定的进程
kill pid_number
linux:/ # free
total used free shared buffers cached
Mem: 1020304 680352 339952 0 14004 329600
-/+ buffers/cache: 336748 683556
Swap: 0 0 0
linux:/ # free -m
total used free shared buffers cached
Mem: 996 663 332 0 13 321
-/+ buffers/cache: 328 667
Swap: 0 0 0
uname查看系统信息
linux:/ # uname -a Linux linux 2.6.34-12-default #1 SMP 2010-06-29 02:39:08 +0200 i686 i686 i386 GNU/Linux
linux:/ # more /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 28 model name : Intel(R) Atom(TM) CPU 330 @ 1.60GHz stepping : 2 cpu MHz : 1596.222 cache size : 512 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 2
...................
查看开机时长
linux:/ # uptime
17:43pm up 1:13, 3 users, load average: 0.11, 0.06, 0.04
查看开机讯息
linux:/ # dmesg
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 2.6.34-12-default (geeko@buildhost) (gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux) ) #1 SMP 2010-06-29 02:39:08 +0200
。。。。。。。。。。。。。
linux:/ # who
root :0 Mar 11 16:30 (console)
root pts/2 Mar 11 16:30 (:0)
root pts/0 Mar 11 16:32 (:0.0)
linux:/ # whoami
root
linux:/ # hostname
linux
linux:/ # date
Fri Mar 11 17:46:50 CST 2011
linux:/ # cal
March 2011
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31