16 Linux中的掛載命令

掛載命令(可理解為分配盤符)

(1)查詢與自動(dòng)掛載

mount 查詢系統(tǒng)中已掛載的設(shè)備
mount -a 依據(jù)配置文件/etc/fstab的內(nèi)容,自動(dòng)掛載

(2)掛載命令的格式

mount [-t 文件系統(tǒng)] [-o特殊選項(xiàng)] 設(shè)備 文件名 掛載點(diǎn)
選項(xiàng):
-t 文件系統(tǒng):加入文件系統(tǒng)類型來(lái)指定掛載的類型,ext3,ext4,iso9660等文件系統(tǒng)
-o 特殊選項(xiàng):可以指定掛載的額外選項(xiàng)
例:mount -o remount,noexec /home/

重新掛載/home分區(qū),使用noexec權(quán)限

Linux腳本文件
[root@localhost ~]# cd /home
[root@localhost home]# vi hello.sh

#########################
#!/bin/bash (.sh腳本文件開(kāi)頭)
echo "Hello world!"
########################
-----賦予執(zhí)行權(quán)限
[root@localhost home]# chmod 755 hello.sh
----執(zhí)行腳本文件,此時(shí)輸入Hello world
[root@localhost home]# ./hello.sh

----將home重新掛載,并將權(quán)限設(shè)為不可執(zhí)行
mount -o remount,noexec /home/

----此時(shí)執(zhí)行腳本文件,提示權(quán)限不足
[root@localhost home]# ./hello.sh
-bash: ./hello.sh: 權(quán)限不夠

(3)掛載光盤

1:[root@localhost ~]# mkdir /mnt/cdrom/ #建立掛載點(diǎn),空目錄都可以
2:[root@localhost ~]# mount -t iso9660 /dev/sr0 /mnt/cdrom
----掛載默認(rèn)權(quán)限為可寫(xiě)的,但是光盤一旦壓縮完成,將不能能寫(xiě)入
mount: block device /dev/sr0 is write-protected, mounting read-only

----光盤默認(rèn)格式為iso9660 ,所以-t iso9660 可以省略不寫(xiě)
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom/ #掛載光盤

(4)卸載光盤

umount 設(shè)備文件名或掛載點(diǎn)
umount /mnt/cdrom/或umount /dev/sr0

(5)掛載優(yōu)盤

fdisk -l

查看設(shè)備文件名

mount -t vfat /dev/sdb1 /mnt/usb/

vfat指的是fat32文件系統(tǒng)

Linux默認(rèn)不支持NTFS文件系統(tǒng)的

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容