天天看點

shell之小知識點

last:顯示/var/log/wtmp檔案,顯示使用者登入曆史及重新開機曆史

    -n #:僅顯示最近幾次的相關資訊

lastb:/var/log/btmp檔案,顯示使用者錯誤的登入嘗試

    -n #

lastlog:顯示每一個使用者最近一次成功的登入資訊

    -u username 顯示特定使用者最近的登入資訊

 not in the sudoers file.  This incident will be reported

 $ vi /etc/sudoers

         找到有句話“root  ALL=(ALL)”,在它的下面添加一行

         ”你的使用者名“    ALL=(ALL)

/usr/sbin/lsof用于檢視已經打開的檔案描述符

shell之小知識點

/usr/sbin/lsof -a -p $$ -d 0,1,2

du -sh 檔案占空間大小

df 顯示整個磁盤分區使用情況

    -i inode    

    -h 機關換算

dd指令

    if=資料來源

    of=資料存儲目标

    bs=塊大小

    count=塊個數

dd if=/dev/zero of=/var/swapfile bs=1M count=1024

檔案系統在開機時可自動挂載/etc/fstab中的檔案系統

其格式 :

要挂載的裝置    挂載點    檔案系統類型    挂載選項    轉儲頻率(每隔多少天做一次備份)    自檢次序

/dev/sda5        /mnt/test    ext3            defaults    0        0

mount -a 全部挂載

umount

fuser驗證哪個使用者正在使用檔案或套接字

    -v 某個檔案上正在運作的程序資訊

fuser -km mount_point終止正在通路挂載點的所有程序

啟動服務設定

chkconfig --list檢視服務運作情況

chkconfig --add SERVICE

chkconfig --del SERVICE

chkconfig --level  LEVEL  SERVICE   {on|off}

chkconfig --level 2345 ntop on

檢視運作級别:

runlevel:

who -r

 tar 指令常用

  -c打包

  -x解包

  -j以bzip2壓縮

  -z以gzip壓縮

  -v顯示過程

tar -zcvf /tmp/etc.tar.gz /etc   --打包後,以 gzip 壓縮

tar -jcvf /tmp/etc.tar.bz2 /etc  --打包後,以 bzip2 壓縮

tar -jxvf /tmp/etc.tar.gz 解壓

轉載請注明出處:http://www.cnblogs.com/tla001/

一起學習,一起進步