天天看點

Linux基礎常用運維操作

 Linux基礎運維 :

1.   檢視主機型号:

dmidecode |grep Product

2.   檢視CPU: 檢視邏輯cpu個數: grep processor /proc/cpuinfo |wc -l

檢視實體cpu個數:

grep "physical id" /proc/cpuinfo | sort|uniq|wc -l

檢視實體croe數

grep "cpu cores" /proc/cpuinfo | sort|uniq

grep "core id" /proc/cpuinfo

檢視cpu是否超線程,如果siblings是cores個數的2倍就是enable了超線程(Hyper-Thread

grep "siblings" /proc/cpuinfo | sort

檢視cpu型号

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

dmesg |grep -i xeon

3.   以不同的使用者身份運作程式:

su - username -c "where/is/command/line"

有時候需要運作特殊身份的程式...就可以讓su來做...

4.   目錄統計腳本

儲存成total.sh ,然後用total.sh 絕對路徑,就會統計路徑下目錄的大小了

#!/bin/sh

du $1 --max-depth=1 | sort -n|awk '{printf "%7.2fM ----> %s\n",$1/1024,$2}'|sed 's:/.*/\([^/]\{1,\}\)$:\1:g'

5.   測試磁盤性能

用法: hdparm -tT /dev/sda (測試第一個實體硬碟的速度)

6.   在同一個指令行上同時執行多條指令

用分号分隔.如編譯一個源檔案:

#./configure && make && make install

7.   快速在兩個目錄中切換

重複鍵入 cd - 可在兩個目錄間切換.

8.   檢視系統中己有的使用者

cut -f1 -d: /etc/passwd

9.   修改網卡 MAC 位址

ifconfig eth0 down

ifconfig eth0 hw ether 00:AA:BB:CCD:EE

ifconfig eth0 up

上面的是臨時性的你可以加入rc.local讓它開機自動執行

10.  檢視系統是 32 位還是 64

getconf LONG_BIT     # 32 or 64

uname –m                # 如果是32位就是Ix 86, 如果是64位顯示x86_64

繼續閱讀