#启动一个linux进程
[root@client01 ~]# /etc/init.d/postfixstart
[root@client01 ~]# /etc/init.d/postfix stop
Shutting down postfix: [ OK ]
[root@client01 ~]# service postfix start
Starting postfix: [ OK ]
[root@client01 ~]# service postfix stop
Shutting down postfix: [ OK ]
[root@client01 ~]# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@client01 ~]# ps -ef|grep postfix
root 2145 1 0 13:34 ? 00:00:00 /usr/libexec/postfix/master
postfix 2147 2145 0 13:34 ? 00:00:00 pickup -l -t fifo -u
postfix 2148 2145 0 13:34 ? 00:00:00 qmgr -l -t fifo -u
root 2150 1157 0 13:34 pts/0 00:00:00 grep postfix
#安装httpd
服务器
[root@client01 ~]#
yum install httpd -y
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]# /etc/init.d/httpd stop
Stopping httpd: [ OK ]
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]# ps -ef|grep httpd
root 2203 1 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2205 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2206 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2207 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2208 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2209 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2210 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2211 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 2212 2203 0 13:35 ? 00:00:00 /usr/sbin/httpd
root 2214 1157 0 13:35 pts/0 00:00:00 grep httpd
[root@client01 ~]# /etc/init.d/httpd stop
Stopping httpd: [ OK ]
[root@client01 ~]# ps -ef|grep httpd
root 2222 1157 0 13:37 pts/0 00:00:00 grep httpd
#关闭一个linux进程
#一个服务:多个linux进程组成
#模拟孤儿进程
#kill 杀死进程
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd:
[root@client01 ~]# ps -ef|grep httpd
root 2228 1 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2230 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2231 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2232 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2233 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2234 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2235 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2236 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
apache 2237 2228 0 13:38 ? 00:00:00 /usr/sbin/httpd
root 2250 1157 0 13:40 pts/0 00:00:00 grep httpd
#杀掉后,再次查询,没有该服务
[root@client01 ~]# kill 2228
[root@client01 ~]# ps -ef|grep httpd
root 2252 1157 0 13:40 pts/0 00:00:00 grep httpd
#模拟孤儿进程
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]# ps -ef|grep httpd
root 2258 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2260 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2261 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2262 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2263 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2264 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2265 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2266 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2267 2258 0 13:41 ? 00:00:00 /usr/sbin/httpd
root 2269 1157 0 13:41 pts/0 00:00:00 grep httpd
#强制杀死
[root@client01 ~]# kill -9 2258
[root@client01 ~]# ps -ef|grep httpd
apache 2260 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2261 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2262 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2263 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2264 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2265 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2266 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2267 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
root 2271 1157 0 13:41 pts/0 00:00:00 grep httpd
#访问:可以正常浏览器访问,说明服务正常,但是以后是否能访问就不一定,这些linux进程过一段会自动回收
[root@larrywen ule-sa1]# firefox
http://192.168.1.11/
[root@client01 ~]# /etc/init.d/httpdrestart
Stopping httpd: [FAILED]
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
(98)Address already in use: make_sock:could not bind to address [::]:80
(98)Address already in use: make_sock:could not bind to address 0.0.0.0:80
no listening sockets available, shuttingdown
Unable to open logs
[FAILED]
[root@client01 ~]# ps -ef|grep httpd
apache 2260 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2261 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2262 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2263 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2264 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2265 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2266 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2267 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
root 2326 1157 0 13:45 pts/0 00:00:00 grep httpd
[root@client01 ~]# kill 2260
[root@client01 ~]# ps -ef|grep httpd
apache 2261 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2262 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2263 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2264 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2265 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2266 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
apache 2267 1 0 13:41 ? 00:00:00 /usr/sbin/httpd
root 2328 1157 0 13:45 pts/0 00:00:00 grep httpd
#正则匹配,全部杀死
[root@client01 ~]# pkill httpd
[root@client01 ~]# ps -ef|grep httpd
root 2331 1157 0 13:45 pts/0 00:00:00 grep httpd
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]# ps -ef|grep httpd
root 2337 1 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2339 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2340 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2341 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2342 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2343 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2344 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2345 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
apache 2346 2337 0 13:47 ? 00:00:00 /usr/sbin/httpd
root 2348 1157 0 13:48 pts/0 00:00:00 grep httpd
#要查清楚,强制杀:很危险
[root@client01 ~]# pkill -9 httpd
[root@client01 ~]# ps -ef|grep httpd
root 2351 1157 0 13:48 pts/0 00:00:00 grep httpd
#列出所有的信号量
[root@client01 ~]# kill -l
1)SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6)SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12)SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22)SIGTTOU 23) SIGURG 24) SIGXCPU 25)SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30)SIGPWR
31) SIGSYS 34)SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37)SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42)SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45)SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50)SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55)SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62)SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
#使用
killall命令(启动的服务名字,不能通配使用)。建议使用,避免误杀(因为其他服务有可能重名)
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]# ps -ef|grep http
root 2366 1 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2368 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2369 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2370 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2371 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2372 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2373 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2374 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
apache 2375 2366 0 13:52 ? 00:00:00 /usr/sbin/httpd
root 2377 1157 0 13:53 pts/0 00:00:00 grep http
[root@client01 ~]# killall httpd
[root@client01 ~]# ps -ef|grep http
root 2380 1157 0 13:53 pts/0 00:00:00 grep http
[root@client01 ~]# /etc/init.d/httpd start
Starting httpd: httpd:apr_sockaddr_info_get() failed for client01.host.com
httpd: Could not reliably determine theserver's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@client01 ~]##x
kill命令
killall http
#xkill命令(点谁谁死)
[root@larrywen Desktop]# yum install xkill-y
[root@larrywen Desktop]# xkill
Select the window whose client you wish tokill with button 1....
#保存top的信息然后用于分析
[root@client01 ~]# top -b -n 2 > top.txt
#前台进程
[root@client01 ~]# find / -name"aaaaa"
[root@client01 ~]# vim aa01.txt
#后台进程
[root@client01 ~]# vim aa01.txt
[1]+ Stopped vimaa01.txt
[root@client01 ~]# ps -ef|grep vim
root 2561 2426 0 14:09 pts/0 00:00:00 vim aa01.txt
root 2563 2426 0 14:09 pts/0 00:00:00 grep vim
[root@client01 ~]# vim aa02.txt
[2]+ Stopped vimaa02.txt
[root@client01 ~]# vim aa03.txt
[3]+ Stopped vimaa03.txt
#查看任务
[root@client01 ~]# jobs
[1] Stopped vimaa01.txt
[2]- Stopped vimaa02.txt
[3]+ Stopped vimaa03.txt
#按Ctrl+Z将进程停止,可以发现拷贝的文件大小不变
[root@larrywen opt]# cp -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./
^Z
[1]+ Stopped cp -i -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./
[root@larrywen opt]# ll rhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 163512320 Aug 5 14:13 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 163512320 Aug 5 14:13 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# jobs
[1]+ Stopped cp -i -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./
#放到后台执行 bg加编号
[root@larrywen opt]# bg %1
[1]+ cp -i -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./ &
[root@larrywen opt]# ll rhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 487411712 Aug 5 14:13 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 683212800 Aug 5 14:13 rhel-server-6.1-x86_64-dvd.iso
[root@client01 ~]# bg %1
[1] vim aa01.txt &
#放到前台执行
[root@client01 ~]# fg %1
vim aa01.txt
[root@client01 ~]# jobs
[2]- Stopped vimaa02.txt
[3]+ Stopped vimaa03.txt
#放到后台执行
[root@larrywen opt]# cp /home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso./ &
[1] 12611
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 1289060352 Aug 5 14:16 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 1392214016 Aug 5 14:16 rhel-server-6.1-x86_64-dvd.iso
[1]+ Done cp -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./
[root@larrywen opt]# cp/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./ &
[1] 12647
[root@larrywen opt]# jobs
[1]+ Running cp -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./ &
#Ctrl+C:中断,可以发现文件大小不变
[root@larrywen opt]# fg %1
cp -i/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso ./
^C
[root@larrywen opt]# jobs
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 2298707968 Aug 5 14:17 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 2298707968 Aug 5 14:17 rhel-server-6.1-x86_64-dvd.iso
[root@client01 ~]# jobs
[2]- Stopped vimaa02.txt
[3]+ Stopped vimaa03.txt
[root@client01 ~]# kill %2
[2]- Stopped vimaa02.txt
[root@client01 ~]# jobs
[2]+ Stopped vim aa02.txt
[3]- Stopped vimaa03.txt
[root@client01 ~]# kill -9 %2
[2]+ Stopped vimaa02.txt
[root@client01 ~]# jobs
[2]+ Killed vimaa02.txt
[3]- Stopped vimaa03.txt
[root@client01 ~]# jobs
[3]+ Stopped vimaa03.txt
[root@client01 ~]# kill -9 %3
[3]+ Stopped vimaa03.txt
[root@client01 ~]# jobs
[3]+ Killed vimaa03.txt
[root@client01 ~]# jobs
#后台执行
[root@client01 ~]# cp rhel.iso /opt/ &
[root@client01 ~]#
nohup cp rhel.iso /opt/
#拷贝的时候关闭终端
[root@larrywen Desktop]# scp/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso 192.168.1.11:/root
#文件大小不变
[root@client01 ~]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 171425792 Aug 5 14:33 rhel-server-6.1-x86_64-dvd.iso
[root@client01 ~]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 171425792 Aug 5 14:33 rhel-server-6.1-x86_64-dvd.iso
[root@client01 ~]# llrhel-server-6.1-x86_64-dvd.iso
[root@client01 ~]# rm -frhel-server-6.1-x86_64-dvd.iso
#后台执行,&,关闭终端后仍然在拷贝
[root@larrywen opt]# cp/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso /opt &
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 3600812032 Aug 5 14:38 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 3600812032 Aug 5 14:38 rhel-server-6.1-x86_64-dvd.iso
#后台执行,nohup,关闭终端后仍然在拷贝
[root@larrywen opt]# nohup cp/home/Wentasy/software/rhel-server-6.1-x86_64-dvd.iso /opt
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 2561306624 Aug 5 14:40 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso
-rwxr-xr-x. 1 root root 2665922560 Aug 5 14:40 rhel-server-6.1-x86_64-dvd.iso
[root@larrywen opt]# llrhel-server-6.1-x86_64-dvd.iso