linux硬盘 linux模拟器网页版
Linux系统怎么查看电脑的磁盘空间
Linux系统怎么查看电脑的磁盘空间?Linux作为一款开源的操作系统,许多用户都在使用这款系统,而这款系统的操作方法和Windows完全不一样,下面就带着大家一起来看看怎么操作吧!
Linux系统查看电脑的磁盘空间的方法
可以使用 df和 du命令。
df
df以磁盘分区为单位查看文件系统,可以获取硬盘被占用了多少空间,目前还剩下多少空间等信息。
例如,我们使用df-h命令来查看磁盘信息,-h选项为根据大小适当显示:
显示内容参数说明:
Filesystem:文件系统
Size:分区大小
Used:已使用容量
Avail:还可以使用的容量
Use%:已用百分比
Mounted on:挂载点
相关命令:
df-hl:查看磁盘剩余空间
df-h:查看每个根路径的分区大小
du-sh[目录名]:返回该目录的大小
du-sm[文件夹]:返回该文件夹总M数
du-h[目录名]:查看指定文件夹下的所有文件大小(包含子文件夹)
du
du的英文原义为 disk usage,含义为显示磁盘空间的使用情况,用于查看当前目录的总大小。
例如查看当前目录的大小:
# du-sh
605M。
显示指定文件所占空间:
# du log2012.log
300 log2012.log
方便阅读的格式显示test目录所占空间情况:
# du-h test
608K test/test6
308K test/test4
4.0K test/scf/lib
4.0K test/scf/service/deploy/product
4.0K test/scf/service/deploy/info
12K test/scf/service/deploy
16K test/scf/service
4.0K test/scf/doc
4.0K test/scf/bin
32K test/scf
8.0K test/test3
1.3M test
du命令用于查看当前目录的总大小:
-s:对每个Names参数只给出占用的数据块总数。
-a:递归地显示指定目录中各文件及子目录中各文件占用的数据块数。若既不指定-s,也不指定-a,则只显示Names中的每一个目录及其中的各子目录所占的磁盘块数。
-b:以字节为单位列出磁盘空间使用情况(系统默认以k字节为单位)。
-k:以1024字节为单位列出磁盘空间使用情况。
-c:最后再加上一个总计(系统默认设置)。
-l:计算所有的文件大小,对硬链接文件,则计算多次。
-x:跳过在不同文件系统上的目录不予统计。
-h:以K,M,G为单位,提高信息的可读性。
linux磁盘分区方法
产品型号:Thinkpad E15
系统版本:centos8
案例:在sdb盘上建一个分区,大小为1G
在虚拟机上添加一块硬盘
例:对sdb这块盘划分一个100M的分区出来
[root@xuegod63~]# fdisk/dev/sdb
...
Command(m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition删除分区
g create a new empty GPT partition table
G create an IRIX(SGI) partition table
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 partitions system id改变分区类型
u change display/entry units
v verify the partition table
w write table to disk and exit写分区表信息到硬盘,保存操作并退出
x extra functionality(experts only)
Command(m for help): p-----打印分区表
Command(m for help): n----新建一个分区
Partition type:
p primary(2 primary, 0 extended, 2 free) p:主分区
e extended e:扩展分区
Select(default p):--#直接默认
Using default response p
Partition number(1,4, default 1):---#直接默认
First sector(1230848-41943039, default 1230848):---#直接默认
Using default value 1230848
Last sector,+sectors or+size{K,M,G}(1230848-41943039, default 41943039):+1G
#输入分区大小
Partition 3 of type Linux and of size 1 GiB is set
Command(m for help): w#保存退出
格式化并创建文件系统
[root@xuegod63~]# mkfs.xfs/dev/sdb1
注:-f参数可以对已经存在文件系统的分区,强制格式化
[root@xuegod63~]# mkdir/sdb1#创建挂载点
[root@xuegod63~]# mount/dev/sdb1/sdb1/#挂载
[root@xuegod63~]# df-h#查看
linux查看硬盘空间
linux怎么查看硬盘大小?我们一起来了解一下吧。
1、打开linux系统,在linux的桌面的空白处右击。
2、在弹出的下拉选项里,点击打开终端。
3、在命令窗口中输入查询语句df-h,然后按回车键运行语句,就可以查看到我的服务器磁盘的使用率和大小了,
4、还可以使用查询语句df,效果和df-h差不多,就是容量大小会具体到kb单位。