LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-26-2011, 05:59 AM   #1
Snigger
Member
 
Registered: Jul 2007
Distribution: Ubuntu Lucid Lynx
Posts: 55

Rep: Reputation: 15
Question Add/Remove Hidden and ReadOnly attributes from files and directories on vfat filesyst


Hi
How can I add/remove FAT32 hidden and readonly attributes in linux on a vfat drive ?
Is there any console command or any other way?

Thanks
 
Old 01-26-2011, 08:26 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955Reputation: 1955
The swiss-army-knife for dos/fat filesystems is mtools. But it's not all that simple to use, at least based on the little experience I have with it.

Here's the manual:
http://www.gnu.org/software/mtools/manual/mtools.html

A quick search of apt turned up fatattr, though, which from the description may be closer to what you're looking for.
 
1 members found this post helpful.
Old 11-07-2015, 10:23 PM   #3
dedec0
Member
 
Registered: May 2007
Posts: 135

Rep: Reputation: 10
Question How to AddRemove Hidden attributes from vfat media mounted?

How to set or unset hidden attribute (or others) from vfat media? Does it need, must or must not be mounted?

For example, I have a pendrive mounted in /media/LAPIS. It has 3 folders: ".secret", "wanted" and "trash"; and 4 files: ".secret/password.txt", "wanted/better.txt", "trash/their.txt" and "start.txt". I want to make everything but the "start.txt" file, in the root folder, to have the VFAT's hidden attribute set. And I assume that making a folder hidden naturally will hide its files, so we should need only 3 commands, or 3 arguments.

From the previous post and the page it points (http://www.gnu.org/software/mtools/manual/mtools.html) I could not find the command line I should use. And I have tried a few before and after reading that page. None worked. For all the commands below, the current directory is the root folder of the mounted VFAT media: "/media/LAPIS". My tries:

Code:
# Just checking silliness
$ mount|grep LAPIS
/dev/sdd1 on /media/LAPIS type vfat (rw,nosuid,nodev,uhelper=hal,
                                     shortname=mixed,uid=1000,utf8,
                                     umask=077,flush)

# Same result on two different distros:
$ mdir start.txt
Can't open /dev/fd0: No such file or directory
Cannot initialize 'A:'

$ mdir -a start.txt
Can't open /dev/fd0: No such file or directory
Cannot initialize 'A:'

# Ok, it says it needs a folder as argument... right? No.
$ mdir -a .
Can't open /dev/fd0: No such device or address
Cannot initialize 'A:'
$ mdir -a .secret
Can't open /dev/fd0: No such device or address
Cannot initialize 'A:'

# Try #2 with folder arg
$ mdir -a /media/LAPIS/
Can't open /dev/fd0: No such device or address
Cannot initialize 'A:'

# Another way, just trying silly guesses
$ mdir -a /dev/sdd1 # the VFAT media is here
Can't open /dev/fd0: No such device or address
Cannot initialize 'A:'
The wanted command is like the exampĺes below. If possible to be done with the mtool set, better - it should be installed on all machines I want to do this.

Code:
# Set hidden attribute for a file OR directory, locally referenced
# (with linux names, that should be the same as the long names)
$ mset +h file.txt
$ mset +h folder
# Unset hidden attribute for a file OR directory, locally referenced
# ( " ... " ... " )
$ mset -h file.txt
$ mset -h folder

Last edited by dedec0; 11-07-2015 at 10:24 PM.
 
Old 11-07-2015, 11:25 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Posts: 16,257

Rep: Reputation: Disabled
the almost antique fat partition format knows nothing about linux permissions
-- it never supported that

and seeing as this is a necro post

For current Linux OS's it is your desktop manager mounting it as READ ONLY for non root users

use the GUI tools for your Desktop Manager

or write a udev rule and a fstab entry


"/dev/fd0"

fd0 is going to be a problem
a 3.5 in floppy
most current OS's do not automatically look nor mount a IDE floppy drive
 
Old 11-09-2015, 02:39 AM   #5
dedec0
Member
 
Registered: May 2007
Posts: 135

Rep: Reputation: 10
The two machines I tried are Debian and Ubuntu (yes, current).

This is not a necro post because: I have the same problem today; I still could not do it for the pendrives I use today (that I keep with vfat FS so they're recognized when I eventually have to open the in uindozes). I could not find another command line tool (that should exist as an option, but you also did not say which GUI programs are able to do that, I did not find it (searched but didn't).

From what John VV said, should I conclude that there is a bug in mtools, and then I could report it?

And I still want the command lines to fiddle with these permissions. I opted for replying this old post because otherwise it would be a duplicate.

Edit: now I see that this thread is on Linux Desktop subforum. Should I ask to move it to the general forum (or maybe the software one), or create a new thread there?

Last edited by dedec0; 11-09-2015 at 02:42 AM.
 
Old 11-09-2015, 11:18 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Posts: 16,257

Rep: Reputation: Disabled
???
why not just mount it with the " rw " and "user" option in fstab

read
Code:
man fstab
or

WRITE a udev rule for it so that it mounts as RW for the users and not just root

this is NOT a bug

it is a security setting
root has read / write by default
users have READ ONLY by default


this is do to changes since 2011

systemd and udev are NOW used

Last edited by John VV; 11-09-2015 at 11:21 PM.
 
Old 11-11-2015, 08:31 AM   #7
dedec0
Member
 
Registered: May 2007
Posts: 135

Rep: Reputation: 10
Arrow

Quote:
Originally Posted by John VV View Post
???
why not just mount it with the " rw " and "user" option in fstab

read
Code:
man fstab
or

WRITE a udev rule for it so that it mounts as RW for the users and not just root

this is NOT a bug

it is a security setting
root has read / write by default
users have READ ONLY by default


this is do to changes since 2011

systemd and udev are NOW used
I have no problem using it in any linux (and *nix similar OS). And I know how to do it with permissions/owner, and I would change it to ext3 fs; in practice, this is not so good for pendrive I need to use elsewhere.

->Eventually I want some files to be hidden (by default) in Windows (and only in Windows!). So I want to set/unset these "exotic" bits of VFAT in some files.

In Linux I don't need those files to be hidden, so I won't change their owner and permissions as you pointed.

Although I'm not sure I got everything you said about systemd and udev, it does not seem related to my problem and wish - right? Hope it is clearer now.

Last edited by dedec0; 11-11-2015 at 08:32 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] remove directories that only contain .txt and .log files? jmark Linux - Newbie 13 08-09-2010 03:55 AM
[SOLVED] recursively cp all directories, files and hidden files WildDrake! Linux - Newbie 9 05-18-2010 04:39 PM
Regarding coparing file attributes in different directories., sharp859 Programming 1 01-15-2009 04:46 PM
rsync - How to Include Hidden (.something) Files and Directories? edwin11 Linux - Software 4 11-29-2006 07:47 AM
How to compare directories (inc. attributes)? jdupre Linux - Software 3 07-07-2005 01:16 AM


All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration