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:
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:
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