Linux入門:常用命令:查看硬盤、分區、CPU、內存信息


查看硬盤信息

 $df -lh    #查看所有硬盤的使用狀       (df: disk file 的意思  -l :list的意思   -h:以容易理解的格式顯示文件系統的大小)

$du -sh /etc  #查看etc目錄大小du命令會顯示指定的目錄或者文件所占用的磁盤空間     -s或--summarize 僅顯示總計,-h或--human-readable 以K,M,G為單位,提高信息的可讀性

#獲得文件大小很方便,主要是目錄

 外部系統掛載

$mount                         #顯示所有的硬盤分區掛載

$mount partition path          #掛在partition到路徑path-

$umount partition              #卸載partition

 添加硬盤並分區

 1、添加硬盤

2、重啟,使系統識別到硬盤

3、分區fdisk

 Command (m for help): h

h: unknown command

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 $fdisk -l                      #顯示所有的分區

$fdisk device                  #為device(比如/dev/sdc)創建分區表。 進入后選擇n, p, w

$mkfs -t ext3 partition        #格式化分區patition(比如/dev/sdc1)

                                #修改 /etc/fstab,以自動掛載分區。增加行:

                                #/dev/sdc1  path(mount point) ext3 defaults 0 0

 

4、格式化(文件管理系統fat32、ntfs、ext3…)

5、掛載新分區(格式化好的)

 mount /dev/sdb1 /web        #將新分區sdb1掛載到/web目錄下(臨時掛載,重啟丟失)

 6、自動加載

 /etc/fstab              #文件系統配置文件,默認加載的文件都在

/dev/sdb1   /       ext3    defaults    1 2

#設備名/卷標 掛載點 文件類型    *       是否檢測(0、1)   檢測順序(0、1、2)  LABEL=/

 7、卷標

 e2label /dev/sda1           #查看sda1有沒有卷標

e2label /dev/sda1 abc       #設置卷標為abc

#在自動加載(6)中,可以添加卷標

LABLE=abc /web  ext3    defaults    1 2

 查看cpu信息

 $arch                           #顯示架構

$cat /proc/cpuinfo             #顯示CPU信息

$cat /proc/meminfo             #顯示內存信息

 查看內在使用情況

 $free                           #顯示內存使用狀況

 brwx------      #b指的是塊設備block,如硬盤

crwx------      #c指點的是字符設備char,如打印機

---------------------


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM