You are here: Home » Windows » is it possible to set hidden attribute on file/folder for windows from linux?

is it possible to set hidden attribute on file/folder for windows from linux?

0 votes

I want to hide 1 folder in my pen drive for Windows but from Ubuntu, is it possible if yes then how?

Asked by Tumbleweed on October 4, 2010.

1 votes

With FAT... You can't.


It's really unlikely that your pendrive has NTFS, but:

Using ntfs-3g (not in all driver versions, unfortunately), you can change this information through extended attributes:

(The attribute system.ntfs_attrib_be only exists since ntfs-3g-2010.5.22AC.5) The NTFS attributes are mapped to two four-byte word extended attributes named system.ntfs_attrib and system.ntfs_attrib_be. The value of the former is represented with the endianness of the processor used (suitable for use with system functions such as getxattr(2)), the value of the latter is represented as big-endian and is more convenient for use with commands such as getfattr(1).

The table in that page gives FILE_ATTRIBUTE_HIDDEN = 2, so:

  1. getfattr -h -e hex -n system.ntfs_attrib_be yourfile
  2. Bitwise-OR getfattr's output with 0x2

    $ python
    >>> print hex(0x1234 | 0x2)
    0x1236
    

    Replace 0x1234 with whatever getfattr printed.

    (A calculator would work just as well.)

  3. setfattr -h -v 0x1236 -n system.ntfs_attrib_be yourfile

    Replace 0x1236 with whatever you got from step 2.

Damn, I should write chmod.ntfs or something.

Answered by grawity on October 5, 2010.

"Damn, I should write `chmod.ntfs` or something." DOO EET! - Ignacio Vazquez-Abrams on October 5, 2010

Also, it is possible with VFAT, but not pretty. http://stackoverflow.com/questions/1648117/how-to-get-more-vfat-attributes-of-files-in-linux-using-c - Ignacio Vazquez-Abrams on October 5, 2010

1 votes

you could try renaming to ./.whatever then renaming back with the hide_dot_files mount option enabled...i haven't seen another way to do it yet...

Answered by aking1012 on October 4, 2010.

http://www.tuxera.com/community/ntfs-3g-manual/ says respecting/setting the hidden attribute is supported, but they don't say a way to DO it. this is my workaround - aking1012 on October 4, 2010

Content from Superuser of Stack Exchange. Original article at Superuser.


Related Tags

Windows 5772
Ubuntu 3445
Operating Systems 277
Hidden Files 24