linuxservice命令
❶ linux鏌ョ湅鏈嶅姟鐘舵乴inux鏌ョ湅鏈嶅姟
濡備綍鍦↙inux涓嬫煡鐪嬫湇鍔$殑榪愯屾儏鍐碉紵
鍙浠ュ湪Linux涓嬭緭鍏ュ懡浠わ細
1銆$servicesshdstatus
2銆#serviceservicenamestatus鏄褰撳墠鐘舵
3銆#chkconfig--listservicename鏄鏌ョ湅鍚鍔ㄧ姸鎬侊紝涔熷氨鏄鏄鍚﹀紑鏈鴻嚜鍔ㄥ惎鍔ㄦ敞錛1銆佸傛灉service鍜宑hkconfig鎵句笉鍒幫紝鍙浠ヨ瘯璇/sbin/service鍜/sbin/chkconfig2銆佸傛灉鐢╱buntu濂藉儚鏄瑕佺敤/etc/init.d/servicenamestatus鏌ョ湅褰撳墠鐘舵侊紙servicename灝辨槸浣犺佹煡鐨勬湇鍔″悕錛
linux鎬庝箞鏌ョ湅鏈嶅姟鏄鍚﹁繍琛岋紵
鍙浠ュ湪Linux涓嬭緭鍏ュ懡浠わ細
1銆$servicesshdstatus2銆#serviceservicenamestatus鏄褰撳墠鐘舵3銆#chkconfig--listservicename鏄鏌ョ湅鍚鍔ㄧ姸鎬侊紝涔熷氨鏄鏄鍚﹀紑鏈鴻嚜鍔ㄥ惎鍔ㄦ敞錛
1銆佸傛灉service鍜宑hkconfig鎵句笉鍒幫紝鍙浠ヨ瘯璇/sbin/service鍜/sbin/chkconfig2銆佸傛灉鐢╱buntu濂藉儚鏄瑕佺敤/etc/init.d/servicenamestatus鏌ョ湅褰撳墠鐘舵侊紙servicename灝辨槸浣犺佹煡鐨勬湇鍔″悕錛夋墿灞曡祫鏂欙細鏌ョ湅鏌愰」鏈嶅姟褰撳墠鍚鍔ㄧ姸鎬佺殑鍏朵粬鏂瑰紡涓銆佸埄鐢ㄨ繘紼嬫潵鏌ョ湅鍛戒護閲宲s-aux鍀済repxxx鏄鏌ョ湅鏌愪釜榪涚▼鎴栬呮湇鍔℃槸鍚﹀瓨鍦ㄣ
浜屻佸埄鐢╯ervices鍛戒護1銆佹煡鐪嬪崟涓鏈嶅姟鐨勮繍琛岀姸鎬侊細service鏈嶅姟鍚峴tatus濡傦細#servicesshdstatusopenssh-daemon(pid3701)姝e湪榪愯?
2銆佹煡鐪嬫墍鏈夋湇鍔$殑榪愯岀姸鎬侊細service_status-all
linux濡備綍鍚鍔,鍋滄,鏌ョ湅鏈嶅姟錛
鍙浠ラ氳繃servicexxxstart/stop/resrart鎺у埗錛屽彲浠ラ氳繃systemctl錛屼篃鍙浠ラ氳繃/etc/init.d/xxx.service鏉ユ帶鍒躲
濡備綍鏌ョ湅linux緋葷粺瀹夎呬簡鍝浜涙湇鍔★紵
鍥犱笉鍚岀増鏈鐨勬搷浣滅郴緇熷彲鑳戒嬌鐢ㄧ殑鍛戒護涓嶄竴鏍鋒垨鑰呮湁浜涘懡浠ゅ湪鏌愪簺鎿嶄綔緋葷粺涓嶅彲鐢錛岀幇鍒椾婦涓浜涘父鐢ㄦ煡鐪嬪懡浠わ紙鍩轟簬鎴戠殑linux鐗堟湰錛夈傛垜鐨勬搷浣滅郴緇熺増鏈濡備笅錛
1.service--status-all杈撳嚭緇撴灉杈冨氾紝鎴鍙栭儴鍒嗐傛瘮濡傛煡鐪婱ysql鏈嶅姟瀹夎呬簡娌℃湁錛屽彲浠庡垪鍑虹殑淇℃伅涓鏌ユ壘銆
2.chkconfig--list鍙浠ヤ嬌鐢ㄨュ懡浠ゆ煡鎵劇壒瀹氱殑鏈嶅姟鏄鍚﹀畨瑁咃紙鍓嶆彁鏄浣犳寚瀹氳ユ湇鍔¤繍琛岀殑鍚嶇О錛夛紝姣斿侻ySQL錛岄敭鍏ュ懡浠わ細chkconfig--listmysql3.psaux4.榪涘叆init.d鐩褰曟煡鐪5.netstat-lntp6.ntsysv鍏朵腑*鍙瘋〃紺哄紑鏈哄惎鍔ㄣ傚傛灉鎯寵╂煇涓鏈嶅姟寮鏈哄惎鍔錛屽彲浠ヤ嬌鐢╟hkconfigmysqlon銆傚彟鏈夋煡鐪媘ysql鐘舵/鍋滄mysql鏈嶅姟/鍚鍔╩ysql鏈嶅姟鍒嗗埆涓猴細servicemysqlstatus/stop/start銆
linux鎬庝箞鏌ョ湅涓涓鏈嶅姟鏄鍚﹀紑鍚錛
1銆乸saux鎴杗etstat-tlunpps鏄榪涚▼鏌ョ湅鍛戒護
netstat鏄絝鍙f煡鐪嬪懡浠
鍦↙inux緋葷粺涓錛屾湇鍔′竴瀹氭槸鏈夎繘紼嬬殑錛屾墍浠ヤ嬌鐢╬s鍛戒護鍙浠ユ煡鐪嬫湇鍔¤繍琛屾儏鍐點
鍙﹀栵紝Linux鏈嶅姟澶氭暟鏄緗戠粶鏈嶅姟錛屾墍浠ラ氳繃netstat鍛戒護涔熷彲浠ユ煡鐪嬫湇鍔¤繍琛岀姸鎬併
2銆乻ervice鏈嶅姟鍚峴tatus
姣斿傛煡鐪媓ttpd鐨刉eb鏈嶅姟鐨勮繍琛岀姸鎬侊紝鎵ц宻ervicehttpdstatus錛
3銆/sbin/service--status-all|grep"鏈嶅姟鍚"
姣斿傛煡鐪媓ttpd鐨剋eb鏈嶅姟
鎵ц/sbin/service--status-all|grep"httpd"鍗沖彲銆
4銆乧hkconfig--list
姣斿傛煡鐪媓ttpd鐨剋eb鏈嶅姟
鎵ц宑hkconfig--list|grep"httpd"鍗沖彲銆
1
鍙嬪ソ鐨勬樉紺烘墍鏈夋湇鍔$殑榪愯岀姸鎬:
service--status-all
chkconfig--list
2
鏌ョ湅鍗曚釜鏈嶅姟鐨勮繍琛岀姸鎬
濡
servicesshdstatus
3
鏌ョ湅鍚鍔ㄧ姸鎬侊紝鏄鍚﹀紑鏈鴻嚜鍔ㄥ惎鍔
chkconfig--listservicename
寮鏈
1錛氬崟鐢ㄦ埛妯″紡
2錛氬氱敤鎴鋒ā寮忥紝涓嶅叿鏈夌綉緇滄。妗堢郴緇燂紙NFS錛夊姛鑳
3錛氬氱敤鎴鋒ā寮忥紝鍏鋒湁緗戠粶妗f堢郴緇燂紙NFS錛夊姛鑳
4錛氭煇浜涘彂琛岀増linux鐢ㄨ繖涓絳夌駭榪涘叆Xwindows緋葷粺
5錛氬悓4
6錛氶噸鏂板惎鍔
娉ㄦ剰錛氬垏璁版棤鐢1鍜6
鍏抽棴鎴栧紑鍚鏈嶅姟鐘舵侊細
chkconfig--level345nscdoff/on
4
澧炲姞鏈嶅姟錛
chkconfig--addxxx
(娉ㄦ剰錛氭湇鍔¤剼鏈蹇呴』瀛樻斁鍦/etc/init.d/鐩褰曚笅)
濡俶ysqld
#cpsupport-files/mysql.serveretc/init.d/mysqld
chkconfigmysqldon錛堝悇絳夌駭涓篛N,鍚勭瓑綰т負2345絳夌駭錛
榪欐牱灝變細浠ョ郴緇熸湇鍔$殑褰㈠紡鍚鍔ㄤ簡
鍒犻櫎鏈嶅姟錛
chkconfig--delXXX
runlevel鏌ョ湅褰撳墠絳夌駭銆
娉ㄦ剰錛氳繍琛岀駭鍒灝辨槸鎿嶄綔緋葷粺姝e湪榪愯岀殑鍔熻兘綰у埆銆
❷ 如何重啟伺服器服務 linux
Linux有如下的關機和重啟命令:shutdown, reboot, halt, poweroff
shutdown - 建議使用的命令
shutdown是最常用也是最安全的關機和重啟命令,它會在關機之前調用fsck檢查磁碟,其中-h和-r是最常用的參數:
-h:停止系統服務並關機 -r: 停止系統服務後重啟 更詳細的命令介紹可查看」Linux命令大全「
❸ 鐢╔shell鐧婚檰linux鏈嶅姟鍣錛屽畨瑁呭畬mysql鍚庯紝鍚鍔
linux涓嬪備綍鍚鍔/鍋滄/閲嶅惎mysql錛
涓銆佸惎鍔ㄦ柟寮
1銆佷嬌鐢╨inux鍛戒護service
鍚鍔錛
service
mysqld
start
2銆佷嬌鐢
mysqld
鑴氭湰鍚鍔錛
/etc/inint.d/mysqld
start
3銆佷嬌鐢
safe_mysqld
鍚鍔錛
safe_mysqld&
浜屻佸仠姝
1銆佷嬌鐢
service
鍚鍔錛
service
mysqld
stop
2銆佷嬌鐢
mysqld
鑴氭湰鍚鍔錛
/etc/inint.d/mysqld
stop
3銆
mysqladmin
shutdown
涓夈侀噸鍚
1銆佷嬌鐢
service
鍚鍔錛
service
mysqld
restart
2銆佷嬌鐢
mysqld
鑴氭湰鍚鍔錛
/etc/inint.d/mysqld
restart
澶囨敞錛氭煡鐪媘ysql絝鍙f槸鍚﹀凡緇忎嬌鐢錛屼嬌鐢╪etstat
-anp
鍛戒護鏌ョ湅
鏈嶅姟鍣ㄧ鍙
浣跨敤鎯呭喌銆
絎浜岄儴鍒嗭紝linux涓嬮噸鍚
mysql鏁版嵁搴
鐨勫悇縐嶆柟娉
1銆侀氳繃rpm鍖呭畨瑁呯殑MySQL
浠g爜紺轟緥:
service
mysqld
restart
/etc/inint.d/mysqld
start
2銆佷粠婧愮爜鍖呭畨瑁呯殑MySQL
浠g爜紺轟緥:
//
linux鍏抽棴MySQL鐨勫懡浠
$mysql_dir/bin/mysqladmin
-uroot
-p
shutdown
//
linux鍚鍔∕ySQL鐨勫懡浠
$mysql_dir/bin/mysqld_safe
&
鍏朵腑mysql_dir涓篗ySQL鐨勫畨瑁呯洰褰曪紝mysqladmin鍜宮ysqld_safe浣嶄簬MySQL瀹夎呯洰褰曠殑bin鐩褰曚笅銆
3銆佷互涓婃柟娉曢兘鏃犳晥鏃訛紝閫氳繃寮鴻屽懡浠わ細
浠g爜紺轟緥:
killall
mysqld
#鍏抽棴mysql
鎴戠殑鏈嶅姟鍣ㄧ敤鐨勬槸灝忛笩浜戠殑錛屾т環姣旈珮銆傛尯涓嶉敊鐨勩