Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

fatattr can do it for VFAT. Not sure about NTFS.

share|improve this answer

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

share|improve this answer
    
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 – hbdgaf Oct 4 '10 at 16:23

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.

share|improve this answer
    
"Damn, I should write chmod.ntfs or something." DOO EET! – Ignacio Vazquez-Abrams Oct 5 '10 at 8:17
3  
Also, it is possible with VFAT, but not pretty. stackoverflow.com/questions/1648117/… – Ignacio Vazquez-Abrams Oct 5 '10 at 8:20

Try my shell script, which is a (mostly) re-implementation of attrib command in Windows.

This uses system.ntfs_attrib_be attribute from NTFS-3G, so you need gatfattr and setfattr utilities from your distro (in Debian/Ubuntu: sudo apt-get install attr).

But after that, just use it without remembering the bit masks, e.g.

./ntfs_attr.sh -h -s some_file_in_ntfs_volume

https://gist.github.com/Explorer09/ac4bf6838c271a9968b3

Notes:

/L option in attrib in Windows is implemented here, see the help in script for details.

/S and /S /D are (intentionally) not implemented. Try find(1) with this script instead.

By the way, I think this question could be merged with this one: Is there a Linux tool for changing DOS/Windows file attributes?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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