Linux常用命令_1__Linux

來源:互聯網
上載者:User
#getconf LONG_BIT

以下還有其他比較有用的命令:

1. uname –a
2. cat /proc/version
3. cat /etc/issue
4. lsb_release –a _
5.cat /etc/redhat-release (rhel)
6.cat /etc/issue
7.cat /etc/SuSE-release
8.cat /etc/releas

*****設定開機自動啟動服務*****
/sbin/chkconfig --level 345 server_name on

*****格式化磁碟**************
mkfs.ext4 block_device

*****建立lvm卷***************
#10G代表大小,還可用100000M或K
lvcreate -L 10G -n lv_name vg_name

********查看進程*******
#按記憶體大小排列
ps -e -o "%C : %p :%z : %a" | sort -k5 -nr
#按cpu利用率排列
ps -e -o "%C : %p :%z : %a" | sort -nr

********殺掉mysql進程*******
ps aux | grep mysql | grep -v grep | awk '{print $2}' | xargs kill -9
pgrep mysql | xargs kill -9
killall -TERM mysqld
kill -9 `cat mysqld.pid`

********查看記憶體大小********
free -m | grep "Mem" | awk '{print $2}'
cat /proc/meminfo

********cpu的數量***********核心數
cat /proc/cpuinfo | grep processor

********cpu負載**************
cat /proc/loadavg

********swap空間**********
vmstat 1 5

********磁碟空間**********
df -h
du -cks * | sort -rn | head -n 10
iostat -x 1 2    磁碟I/O負載

********可運行進程數目********
vmwtat 1 5

********查看是否有異常進程出現******
top -id 1

********開啟的檔案數目**********
lsof | wc -l

*******尋找佔用磁碟IO最多的進程*******
dstat -M topio -d -M topbio

*******查看機器支援的最大記憶體*********
sudo dmidecode  | grep -P 'Maximum\s+Capacity'

*********尋找某個網路裝置是否存在**********
ip link show dev ***

*********設定vlan名**********
#set_name_type後可加如下參數
#VLAN_PLUS_VID | VLAN_PLUS_VID_NO_PAD | DEV_PLUS_VID | DEV_PLUS_VID_NO_PAD
vconfig set_name_type VLAN_PLUS_VID_NO_PAD

**********把整個網站的網頁抓下來**************
wget -m -e robots=off -U "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6" http://www.taobao.com/

**********查看http的並發請求數及其TCP串連狀態************
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

**********取ip地址************
ifconfig eth0 | sed -n '2p' | awk '{print $2}'

**********查看apache的並發請求數及其TCP串連狀態***********
netstat -an -t | grep ':80' | grep ESTABLISHED | awk '{print "%s %s\n", $5, $6}' | sort

**********網路負載************
sar -n DEV

**********網路錯誤************
netstat -i

**********檢查網路連接數目***********
netstat -an | grep -E "^(tcp)" | cut -c 68- | sort | uniq -C | sort -n

**********殺掉80連接埠相關的進程***********
lsof -i :80 | grep -v "PID" |awk '{print "kill -9", $2}' | sh

**********tcpdump抓包,用來防止80連接埠被人攻擊時可以分析資料**********
tcpdump -c 10000 -i eth0 -n dst port 80 > /root/pkts

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.