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
鎴戠殑链嶅姟鍣ㄧ敤镄勬槸灏忛笩浜戠殑锛屾т环姣旈珮銆傛尯涓嶉敊镄勚