Permissions for automatic mounting of hard disks on Ubuntu

Source: Internet
Author: User

By default, partitions automatically mounted on Ubuntu do not have the write permission and must have the root permission. How can I change this setting?
Use man mount to view the manual page and find several useful options:
Umask, fmask, dmask, uid, gid
First, check umask. This is used to specify the default permissions for files attached to windows partitions (in fact, the default permissions are not available, that is, the files attached with the value specified by umask parameters will not have permissions ),
Because files in Windows partitions do not have the permission concept, you must manually specify the default permission. Therefore, if you specify umask to 000, you do not exclude any permission, that is, you have all permissions. For example:
Code:

 
 
1 /dev/hda1 /media/hda1 ntfs defaults,utf8,umask=000 0 0

In this way, even if a text file has executable permissions, double-click the file manager and choose whether to view or execute the file. This is inconvenient, so you want to block the executable permissions:
Code:

 
 
1 /dev/hda1 /media/hda1 ntfs defaults,utf8,umask=111 0 0

This problem occurs again. For a directory, the executable permission has another significance. If you do not have this permission, you cannot enter the directory (but you can read it, that is, list the files in the directory, you can also write,

You can add or delete files in the directory and rename the files. Haha! Linux File Permission is really strange), so we use the fmask and dmask parameters, they are the corresponding file and
Directory "umask", so the directory is set to executable, the file is not executable (usually there are no files that can be directly executed in Linux under Windows partition ?) :
Code:

 
 
1 dmask=022,fmask=133

Which means
Directory:
All users can execute (enter) and others can read (enter). Only users can write (modify, add, or delete the files in ))
File:
All users can read and write on their own, but others cannot.
Then you can use uid and gid as your own.
Code:

 
 
1 id username

Username is the user name of the local machine.

To view the gid and uid of username, for example:

Terminal input code: id kanna

Uid = 1000 (kanna) gid = 1000 (kanna) group = 1000 (kanna), 4 (adm), 24 (cdrom), 27 (sudo), 30 (dip ), 46 (plugdev), 109 (lpadmin), 124 (sambashare)

If it is not set, the "self-writable" and "self" above will not be yours.
As a result, it becomes like this:
Code:

 
 
1 /dev/sda3 /media/program ntfs defaults,utf8,uid=1000,gid=1000,dmask=022,fmask=133 0 0

OK!
Finally, I would like to remind you not to change it to a non-Windows partition. During the experiment, I accidentally changed it to the root partition and provided unrecognized parameters, the ext3 partition parameter used for Windows partitions cannot be identified, so the root partition is mounted as read-only when an error occurs, and the files in the root partition cannot be modified, fstab is placed in the root partition, which is a tragedy. (You can fix it with livecd)

Original

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.