非root用户执行mount命令的方法

在mount的man手册中有说明:

       The non-superuser mounts.
              Normally, only the superuser can mount filesystems.  However, when fstab contains the user option on a line, anybody can mount the corresponding filesystem.


              Thus, given a line


                     /dev/cdrom  /cd  iso9660  ro,user,noauto,unhide


              any user can mount the iso9660 filesystem found on an inserted CDROM using the command


                     mount /dev/cdrom


              or


                     mount /cd


              For more details, see fstab(5).  Only the user that mounted a filesystem can unmount it again.  If any user should be able to unmount it, then use users instead of user in the fstab line.  The owner option is similar
              to  the  user option, with the restriction that the user must be the owner of the special file.  This may be useful e.g. for /dev/fd if a login script makes the console user owner of this device.  The group option is
              similar, with the restriction that the user must be member of the group of the special file.



FILESYSTEM-INDEPENDENT MOUNT OPTIONS

       nouser Forbid an ordinary user to mount the filesystem.  This is the default; it does not imply any other options.


       users  Allow  any  user  to  mount and to unmount the filesystem, even when some other ordinary user mounted it.  This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the
              option line users,exec,dev,suid).


为什么mount命令仅供root使用


If you mount under /usr or /bin or /sbin etc. a directory containing malicious files, the system might fail.

And this is a design in the operating systems like Unix. If you are a user, you don't have the permission. The systems should never go too permissive.

If you still want to allow users other than root to mount directories you desire, please hard-code /etc/fstab so that the system will know and mount them when users specify the commands.


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值