Linux甯哥敤鍛戒护
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux甯哥敤鍛戒护相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/set' title='set'>set
mysql ice tar ntp font cep 绯荤粺鏃堕棿 histsizecentos6 iptables闃茬伀澧?/span>
娓呯┖闃茬伀澧欒鍒欙細
iptables -F
寮€鍚槻鐏锛?/span>
service iptables start
鍏抽棴闃茬伀澧欙細
service iptables stop
閲嶅惎闃茬伀澧欙細
service iptables restart
寮€鏀?0绔彛锛?/span>
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
淇濆瓨闃茬伀澧欒鍒欙細
service iptables save 鎴?iptables-save
centos7 firewalld闃茬伀澧?/span>
寮€鏀緃ttpd鏈嶅姟
firewall-cmd --add-service=http
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
firewalld闃茬伀澧欏紑鏀?0绔彛
firewall-cmd --zone=public --add-port=80/tcp --permanent #寮€鍚?0绔彛
firewall-cmd --reload #閲嶆柊杞藉叆
firewall-cmd --zone=public --query-port=80/tcp #鏌ョ湅80绔彛鏄惁寮€鍚?/span>
firewall-cmd --zone=public --remove-port=80/tcp --permanent #鍒犻櫎80绔彛
firewall-cmd --zone=public --list-ports #鏌ョ湅鎵€鏈夋墦寮€鐨勭鍙?/span>
鍋滄銆佸惎鍔ㄥ拰閲嶅惎firewalld
鍋滄锛歴ystemctl stop firewalld
鍚姩锛歴ystemctl start firewalld
閲嶅惎锛歴ystemctl restart firewalld
鏌ョ湅CPU鐨勪釜鏁?/span>
cat /proc/cpuinfo | grep processor
鏌ョ湅鍗曚釜cpu淇℃伅
cat /proc/cpuinfo
鏌ョ湅CPU澶у皬
cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep "physical id"
鏌ョ湅鍐呭瓨鎯呭喌
free 鈥搈
鏌ョ湅鍐呭瓨澶у皬
cat /proc/meminfo |grep MemTotal 鎴?grep MemTotal /proc/meminfo
鏌ョ湅绌洪棽鍐呭瓨
grep MemFree /proc/meminfo
鏌ョ湅鎵€鏈夌殑浜ゆ崲鍒嗗尯
swapon -s
鏌ョ湅纭洏澶у皬
fdisk -l |grep Disk
鏌ョ湅鍚勪釜鍒嗗尯浣跨敤鎯呭喌
df -hT
鏌ョ湅绯荤粺璐熻浇纾佺洏鍜屽垎鍖?/span>
cat /proc/loadavg
鏌ョ湅鎸囧畾鐩綍鐨勫ぇ灏?/span>
du -sh
鏌ョ湅绯荤粺鐗堟湰
cat /etc/redhat-release
鏄剧ず鎿嶄綔绯荤粺鐨勫彂琛岀増鍙?/span>
uname -r
鏄剧ず绯荤粺鍚嶃€佽妭鐐瑰悕绉般€佹搷浣滅郴缁熺殑鍙戣鐗堝彿銆佹搷浣滅郴缁熺増鏈€佽繍琛岀郴缁熺殑鏈哄櫒 ID 鍙枫€?/span>
uname -a
鏌ョ湅璁$畻鏈虹殑鍚嶇О
hostname
Centos6 淇敼涓绘満鍚嶏紙姘镐箙淇敼锛?/span>
vim /etc/sysconfig/network
Centos7淇敼涓绘満鍚嶏紙姘镐箙淇敼锛?/span>
鏂规硶涓€锛氫慨鏀?etc/hostname鏂囦欢璁剧疆涓绘満鍚?/span>
鏂规硶浜岋細hostnamectl set-hostname xxx
鏌ョ湅鎵€鏈塒CI璁惧
lspci 鈥搕v
鏌ョ湅鎵€鏈塙SB璁惧
lsusb 鈥搕v
鏌ョ湅鍔犺浇鐨勫唴鏍告ā鍧?/span>
lsmod
鏌ョ湅鐜鍙橀噺璧勬簮
env
鏌ョ湅绯荤粺杩愯鏃堕棿銆佺敤鎴锋暟銆佽礋杞?/span>
uptime
鏌ョ湅褰撳墠绯荤粺鏃堕棿
date
鍚屾鏃堕棿
ntpdate -u ntp.api.bz #ntp.api.bz NTP鏈嶅姟鍣紙涓婃捣锛?/span>
鏌ョ湅鏃跺尯
date -R
鏌ョ湅鎸傝浇鐨勫垎鍖虹姸鎬?/span>
mount | column -t
鏌ョ湅鎵€鏈夌綉缁滄帴鍙g殑灞炴€?/span>
ifconfig
鏌ョ湅闃茬伀澧欒缃?/span>
iptables -L
鏌ョ湅璺敱琛?/span>
route 鈥搉
鏌ョ湅443绔彛鏄惁琚崰鐢?/span>
netstat -tnl | grep 443
鏌ョ湅鎵€鏈夊凡寤虹珛鐨勮繛鎺?/span>
netstat 鈥揳ntp
鏌ョ湅鏈嶅姟鐩戝惉绔彛
netstat -atunlp | grep ssh
鏌ョ湅鏈嶅姟杩涚▼
ps -aux | grep ssh 鎴?nbsp; ps -ef | grep ssh
鏌ョ湅鐢ㄦ埛鐧婚檰鏃ュ織
last
鏌ョ湅褰撳墠鐢ㄦ埛鐨勮鍒掍换鍔?/span>
crontab -l
鏌ョ湅鎵€鏈夌郴缁熸湇鍔?/span>
chkconfig --list #閫傜敤浜巆entos6
systemctl list-unit-files #閫傜敤浜巆entos7
systemctl --type service #閫傜敤浜巆entos7
鏌ョ湅鎵€鏈夊惎鍔ㄧ殑绯荤粺鏈嶅姟绋嬪簭
chkconfig --list | grep on #閫傜敤浜巆entos6
systemctl list-unit-files #閫傜敤浜巆entos7
鏌ョ湅鎸囧畾鏈嶅姟鐨勫綋鍓嶅惎鍔ㄤ俊鎭?
chkconfig --list httpd
鏌ョ湅鎵€鏈夊畨瑁呯殑杞欢鍖?/span>
rpm -qa
缁熻宸插畨瑁呰蒋浠跺寘鐨勬暟閲?/span>
rpm -qa | wc -l
瀹炴椂鏄剧ず杩涚▼鐘舵€?/span>
top
鏌ョ湅娲诲姩鐢ㄦ埛
w
鏌ョ湅鎸囧畾鐢ㄦ埛淇℃伅
id 鐢ㄦ埛
#centos7 systemctl
鏌ョ湅鏈嶅姟鍚姩椤?/span>
systemctl list-unit-files
鍒楀嚭鎵€鏈夋湇鍔?/span>
systemctl list-unit-files 鈥搕ype=service
濡備綍婵€娲绘湇鍔″苟鍦ㄥ紑鏈烘椂鍚敤鎴栫鐢ㄦ湇鍔★紙鍗崇郴缁熷惎鍔ㄦ椂鑷姩鍚姩mysql.service鏈嶅姟锛?/span>
systemctl is-active mysql.service
systemctl enable mysql.service
systemctl disable mysql.service
systemctl status cron.service #鏌ョ湅瀹氭椂浠诲姟鐘舵€?/span>
systemctl stop cron.service #鍏抽棴瀹氭椂浠诲姟
systemctl status cron.service #鏌ョ湅鎿嶄綔鎯呭喌
systemctl list-unit-files|grep enable #鏌ョ湅褰撳墠姝e湪杩愯鐨勬湇鍔?/span>
systemctl disable postfix.service #鍏抽棴閭欢鏈嶅姟
systemctl list-unit-files|grep postfix #鏌ョ湅閭欢鏈嶅姟鏄惁寮€鍚?/span>
systemctl stop firewalld.service #鍏抽棴闃茬伀澧?/span>
systemctl is-enable #寮€鍚殑鏈嶅姟
systemctl disable #鍏抽棴鐨勬湇鍔?/span>
鏌ョ湅nfs鏈嶅姟寮€鏈哄惎鍔ㄦ槸鍚︼細
systemctl is-enabled nfs.service
浣跨敤systemctl鍛戒护鏉€姝绘湇鍔★細
systemctl killcrond
涓存椂淇敼selinux锛?/span>
setenforce 0|1
鏌ョ湅selinux鐘舵€侊細
getenforce
姘镐箙鍏抽棴selinux锛?/span>
sed -i 鈥?SELINUX=enforcing/SELINUX=disabled/g鈥?/etc/sysconfig/selinux
鏌ョ湅绯荤粺杩愯绾у埆
runlevel 鎴?who -r
Linux绯荤粺鏈?涓繍琛岀骇鍒?runlevel)
杩愯绾у埆0锛氱郴缁熷仠鏈虹姸鎬侊紝绯荤粺榛樿杩愯绾у埆涓嶈兘璁句负0锛屽惁鍒欎笉鑳芥甯稿惎鍔?/span>
杩愯绾у埆1锛氬崟鐢ㄦ埛宸ヤ綔鐘舵€侊紝root鏉冮檺锛岀敤浜庣郴缁熺淮鎶わ紝绂佹杩滅▼鐧婚檰
杩愯绾у埆2锛氬鐢ㄦ埛鐘舵€?娌℃湁NFS)
杩愯绾у埆3锛氬畬鍏ㄧ殑澶氱敤鎴风姸鎬?鏈塏FS)锛岀櫥闄嗗悗杩涘叆鎺у埗鍙板懡浠よ妯″紡
杩愯绾у埆4锛氱郴缁熸湭浣跨敤锛屼繚鐣?/span>
杩愯绾у埆5锛歑11鎺у埗鍙帮紝鐧婚檰鍚庤繘鍏ュ浘褰UI妯″紡
杩愯绾у埆6锛氱郴缁熸甯稿叧闂苟閲嶅惎锛岄粯璁よ繍琛岀骇鍒笉鑳借涓?锛屽惁鍒欎笉鑳芥甯稿惎鍔?/span>
#centos7鏇存敼鍚姩妯″紡;
鏌ョ湅褰撳墠鏄互鍝妯″紡鍚姩鐨勶細
systemctl get-default 鎴?runlevel
涓存椂淇敼杩愯绾у埆锛?/span>
init 3
姘镐箙淇敼杩愯绾у埆锛?/span>
浠ュ懡浠よ妯″紡鍚姩锛?/span>
systemctl set-default multi-user.target
浠ュ浘褰㈠寲鐣岄潰鍚姩锛?/span>
systemctl set-default graphical.target
鏇存敼鍚巖eboot閲嶅惎鐢熸晥
centos6鏇存敼鍚姩妯″紡
浠ュ浘褰㈠寲鐣岄潰鍚姩
vim /etc/inittab
id:5:initdefault:
浠ュ懡浠よ鍚姩
id:3:initdefault:
鏌ョ湅褰撳墠PS1鐨勫畾涔夊€?/span>
set | grep PS1
淇敼鍛戒护鎻愮ず绗﹂鑹?/span>
vim ~/.bashrc
PS1="[e[37;40m][[e[32;40m]u[e[37;40m]@h [e[36;40m]w[e[0m]]\$ "
鏌ョ湅绯荤粺鏀寔璇█
locale
鏌ョ湅褰撳墠绯荤粺璇█
echo $LANG $LANGUAGE
淇敼绯荤粺璇█锛?/span>
鏀逛负鑻辨枃
vim /etc/profile
LANG="en_US.UTF-8"
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC LANG
鏀逛负涓枃
vim /etc/profile
LANG="zh_CN.UTF-8"
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC LANG
centos7淇敼瀛楃闆嗘柟娉?/span>
鏂规硶涓€锛氱紪杈戝瓧绗﹂泦閰嶇疆鏂囦欢
/etc/locale.conf
鏂规硶浜岋細鍛戒护琛屼慨鏀瑰瓧绗﹂泦
localectl set-locale LANG=zh_CN.UTF-8
localectl status
centos6淇敼瀛楃闆嗘柟娉?/span>
/etc/sysconfig/i18n
鏌ョ湅DNS瑙f瀽娴佺▼
dig +trace www.baidu.com
璺敱杩借釜
traceroute www.qq.com
鏌ョ湅nginx鑴氭湰浣嶇疆
which nginx
which鎸囦护浼氬湪PATH鍙橀噺鎸囧畾鐨勮矾寰勪腑锛屾悳绱㈡煇涓郴缁熷懡浠ょ殑浣嶇疆锛屽苟涓旇繑鍥炵涓€涓悳绱㈢粨鏋溿€?/span>
鏌ョ湅nginx閰嶇疆鏂囦欢璺緞
whereis nginx
鍦ㄥ綋鍓嶈矾寰勪笅鏌ユ壘鏂囦欢
find nginx*
鍦ㄦ牴鐩綍涓嬫煡鎵炬枃浠?/span>
find / nginx
娓呴櫎鍘嗗彶璁板綍
history -c
以上是关于Linux甯哥敤鍛戒护的主要内容,如果未能解决你的问题,请参考以下文章