linux mountpoint命令学习

mountpoint命令用来检查指定的目录是否是一个mountpoint。

设备总是挂载在某个指定的目录下,所以就可以使用mountpoint这条命令来
确认某个目录是否”临时性“的被文件系统占用。
sh- mountpoint /mnt/usb/sda1/
/mnt/usb/sda1/ is a mountpoint
sh-# echo $?
0
sh-#

如果指定-q选项,那么终端上不会打印出任何信息。
这个时候可以通过打印命令执行的回传码来确认该目录是否为一个mountpoint。
sh-# mountpoint -q /mnt/usb/sda1/
sh-# echo $?
0
sh-#
sh-# mountpoint -q /bin/
sh-# echo $?
1
sh-#

sh-# mountpoint -d /mnt/usb/sda1/
8:1
sh-# echo $?
0
sh-#

sh-# mountpoint -x /mnt/usb/sda1/
mountpoint: /mnt/usb/sda1/: not a block device
sh-# echo $?
1
sh-#

因为文件系统总是挂载在某个目录下的,所以我们也可以使用如下的方法
来确认某个目录是否是一个mountpoint。
sh-# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
none on /opt type tmpfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)

sh-# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /opt tmpfs rw,relatime 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
/dev/sda1 /tmp/mnt/usb/sda1 vfat rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue 0 0

带确认问题:
如何确认目录的属性?
sh-# ls -dlh /tmp/mnt/usb/sda1/
drwxrwxrwx 2 root root 4.0K Jan 1 00:00 /tmp/mnt/usb/sda1/
sh-# ls -dlh /mnt/usb/sda1/
drwxrwxrwx 2 root root 4.0K Jan 1 00:00 /mnt/usb/sda1/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值