1. 程式人生 > >linux系統日常維護常用命令

linux系統日常維護常用命令

環境: OS:Red Hat Linux As 5   1.find 11.查詢當前目錄以及子目錄下包含ORA字元的檔案 find . -type f|xargs  grep "ORA"

2.檢視當前目錄佔用空間大小
[[email protected] soft]# pwd
/soft
[[email protected] soft]# du -sh
6.9G    .

檢視某個目錄佔用空間大小
[[email protected]
soft]# du /bak -sh


3.mount光碟機
[[email protected] soft]# mount /dev/cdrom /mnt

4.圖形介面檢視啟動的服務
ntsysv

5.檢視當前安裝的服務
system-config-services

6.切換使用者
su - 使用者名稱 -- 切換後使用切換後用戶名的環境bash_profile
su  使用者名稱  -- 切換後使用當前使用者的bash_profile
  
7.scp

將本機上的檔案傳輸到192.168.50.192機器上的soft目錄下
scp "/u01/soft/linux_11gR2_database_1of2(1).zip" [email protected]:/u01/soft/
scp "/u01/soft/linux_11gR2_database_2of2(1).zip" [email protected]2:/u01/soft/

8.tar

tar -cvf /u01/soft/Server.tar ./Server  將Server目錄下的檔案打包成為Server.tar
tar cvf rpm.tar -P ./rpm                P 使用相對路徑,對應解壓的命令 tar -Pxvf rpm.tar

tar rvf rpm.tar a.txt                   將a.txt 追加到rpm包中
tar xvf rpm.tar -C /soft/mytest/test    將rpm包解壓到指定目錄

9.rpm
rpm -Uvh gcc-c++-4.1.2-50.el5.i386.rpm --force --nodeps --強制安裝,不需要依賴關係     10.檢視目錄佔用空間大小 [[email protected] self]$ du -h ./20160807
36K     ./20160807/17
44K     ./20160807/14
36K     ./20160807/18
36K     ./20160807/16
36K     ./20160807/13
40K     ./20160807/15
592M    ./20160807/12
593M    ./20160807   11.查詢目錄下一個小時之前生成的檔案 find /home/logs/1_mmlogs/mmlog_7711/self/20160825 -cmin +60|xargs ls -1   12.檢視指定目錄下第一層級目錄佔用空間大小
du -lh --max-depth=1 /app/richdm

13.測試磁碟速度
hdparm -Tt /dev/mapper/vg_mmskd-lv_mmsdk
time cp -Rp MB.dat /mmsdk
  14.替換檔案內容sed
sed 's/auth_user/auth_user01/g' dump0605.sql>a.sql

15.檢視一級目錄佔用空間情況
du -h ./db --max-depth=1  


16.壓縮/解壓縮
壓縮命令
gzip schema_bak20181119.dmp
解壓
gunzip schema_bak20181119.dmp.gz



------------------------------CPU相關--------------------------------

幾個cpu

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

每個cpu是幾核(假設cpu配置相同)

more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l

cat /proc/cpuinfo | grep processor

1. 檢視物理CPU的個數
#cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l
 
2. 檢視邏輯CPU的個數
#cat /proc/cpuinfo |grep "processor"|wc -l
 
3. 檢視CPU是幾核
#cat /proc/cpuinfo |grep "cores"|uniq
 
4. 檢視CPU的主頻
#cat /proc/cpuinfo |grep MHz|uniq

 

uname -a

Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux

(檢視當前作業系統核心資訊)

 

cat /etc/issue | grep Linux

Red Hat Enterprise Linux AS release 4 (Nahant Update 5)

(檢視當前作業系統發行版資訊)

 

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

      8  Intel(R) Xeon(R) CPU            E5410   @ 2.33GHz

(看到有8個邏輯CPU, 也知道了CPU型號)

 

cat /proc/cpuinfo | grep physical | uniq -c

      4 physical id      : 0

      4 physical id      : 1

(說明實際上是兩顆4核的CPU)

 

getconf LONG_BIT

32

(說明當前CPU執行在32bit模式下, 但不代表CPU不支援64bit)

 

cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

8

(結果大於0, 說明支援64bit計算. lm指long mode, 支援lm則是64bit)

  

如何獲得CPU的詳細資訊:

linux命令:cat /proc/cpuinfo

用命令判斷幾個物理CPU,幾個核等:

邏輯CPU個數:
# cat /proc/cpuinfo | grep "processor" | wc -l

物理CPU個數:
# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

每個物理CPU中Core的個數:
# cat /proc/cpuinfo | grep "cpu cores" | wc -l

是否為超執行緒?
如果有兩個邏輯CPU具有相同的”core id”,那麼超執行緒是開啟的。

每個物理CPU中邏輯CPU(可能是core, threads或both)的個數:
# cat /proc/cpuinfo | grep "siblings"