1

I have an external hard drive, which has a ntfs file system.

From output of sudo fdisk -l:

Disk /dev/sdb: 931.5 GiB, 1000170586112 bytes, 1953458176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00023f15

Device     Boot Start        End    Sectors   Size Id Type
/dev/sdb1        2048 1953458175 1953456128 931.5G  7 HPFS/NTFS/exFAT

From output of mount:

/dev/sdb1 on /media/t/My Passport type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)

If I set some permission bits on a directory in the file system , for example to be executable and readable and writable only by root, will the permission bits be respected when I plug the external hard drive to a Windows system?

I would like to find a way to restrict access to a directory on my external hard drive from any OS (in particular, Linux and Windows). Also see https://askubuntu.com/a/104544/1471

I just found that chmod doesn't work on the external hard drive, and I wonder why and how I can do about it:

$ ls -ld temp/
drwxrwxrwx 1 t t 144 May 27 18:31 temp/
$ sudo chmod o-rwx temp
$ ls -ld temp/
drwxrwxrwx 1 t t 144 May 27 18:31 temp/

Thanks.

  • Permission bits on NTFS? How are you setting them? – Ignacio Vazquez-Abrams May 27 '18 at 22:22
  • Updated, can I change permission bits on a directory on NTFS? – Tim May 27 '18 at 22:35
  • There are ways to set the ACLs on a NTFS filesystem, but they can be (and usually are) ignored on mount. – Ignacio Vazquez-Abrams May 27 '18 at 22:40
  • Thanks. Added some information from mount. Could you be more specific? – Tim May 27 '18 at 22:43
  • See the mount.ntfs-3g(8) man page, "Description" section, "Access Handling and Security" subsection. – Ignacio Vazquez-Abrams May 27 '18 at 23:36
2

If I set some permission bits on a directory in the file system , for example to be executable and readable and writable only by root, will the permission bits be respected when I plug the external hard drive to a Windows system?

No, UNIX file permissions don't work on Windows.

I would like to find a way to restrict access to a directory on my external hard drive from any OS.

In general, every OS has its different way to set permissions, so that's not possible. You'll need to set the appropriate permissions on the files depending on which OS the filesystem is currently mounted.

Quoting from this answer:

NTFS has Windows ACEs. Unix uses "mode bits" on each file.

On NTFS, each file can have an owner, and zero or more Windows access control entries (ACEs). An ACE consists of a principal (users and groups are principals), a set of operations (Read, Write, Execute, etc.) and whether those operations are allowed or denied. Files can have many ACEs. Other objects in Windows other than files can have ACEs as well, such as registry entries, printer objects, and other things. All ACEs are taken into account when a file operation occurs. Deny takes precedence over allow. Windows ACEs support inheritance where you can set an ACE for a directory and have it automatically propagate to lower level directories.

Files in Unix have an owning user (owner) and an owning group (owner-group). There are three fixed "principals" which are owner, members of the owning group, and everyone else (a.k.a world). For each principal there are three "bits" which cover read, write, and execute abilities. (these have different meanings for directories than files, see this). These bits determine who can perform what operations. This is called the file's mode and is built into the file (there are no separate ACEs).

  • 2
    Uhm ... Unix has POSIX/SUS ACLs. That is to say that the same thing exists, albeit with different semantics. To pretend in 2018 that Unix has just file modes is a bit negligent. The real question isn't whether both NT and Unix have ACLs but whether they can be mapped onto each other and whether a facility exists on the unixoid system in question. – 0xC0000022L May 28 '18 at 8:15
  • 2
    @0xC0000022L There are also NFSv4 ACLs. See en.wikipedia.org/wiki/Access_control_list#Filesystem_ACLs – Andrew Henle May 28 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.