How do I set correct permissions permanently for my 2nd internal HDD?

Firstly, please can my last thread be deleted.

Apologies for the double post, and being in the wrong section.

Ill try to be clear in what Im asking this time, as I seemed to confuse some people last time, and it didn’t help anyone.

I have aslo tried to pm hcvv as my other thread got locked, So I could not reply to anyone after regarding the advice I was given, but I cannot see my message in my sent items, so think it failed to send.

Here is an image of my HDD partitions

http://img28.imageshack.us/img28/6484/partitionsv.png

The HDD mounted at media/Media is the drive I have problems with.

I changed it from ntfs to ext4 today, to explain further on this I simply backed up any data that wasn’t already on my lidevrive account to another HDD, formatted to ext4, and remounted at media/Media, This is not relevant to my question, it was successful, but I’m just explaining why I am at this point when I wasn’t yesterday.

here is the fstab,

rob@linux-mzrw:~> cat /etc/fstab
/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part1 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part5 /                    ext4       acl,user_xattr        1 1
/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part6 /home                ext4       acl,user_xattr        1 2
/dev/sdb5                                      /media/Media         ext4       user,acl,user_xattr   1 2
/dev/sdc1                                      /media/Stuff         ext4       user,acl,user_xattr   1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0



My only issue is permissions, all drives are mounting at boot up, all drive permissions seem correct, apart from the one highlighted in red.

This drive will not allow me to copy, write files, even play music unless i browse in Dolphin with super user, or log in as root.

From my last thread I have learned the following, please could somebody confirm them for me.

It is best to mount drives by-id, I will use this command to see how they should be listed

ls -l /dev/disk/by-id

I should NEVER create mount points in /media, but instead use /mnt. So I will edit that in fstab, and remount the drives at those location (/Media and /Stuff) using the partition tool (Im sure there is a command to do it, I’m used to windows and GUI)

I would like to chown and chmod the parent directories, /mnt/Media and /mnt/Stuff, That way I have permissions to write to both of those drives, I dont have multiple users, or any groups set up, just my log in.

IS this easiest done with commands, if so I would probably need some help, although I’m sure the info is out there, and Im happy to look for it, if I know its the right way to do it.

Or should I be using what looks to be a great script by **jdmcdaniel3 **S.A.F.P. - SUSE Automated File Permissions - Version 1.0.4: https://forums.opensuse.org/blogs/jd…ion-1-0-4-113/.

Again, apologies for the confusion last time, I hope this thread is better for everyone.

Thanks

Rob

Hi
You can mount it anyhow you like :wink: I always use /data

Check the ownership I let /data remain with root and then just create sub directories (as root) and change ownership to my user and users group.


drwxr-xr-x  22 root root    4096 Nov 14 10:12 data

/dev/sdb5            /data                ext4       acl,user_xattr 1 2

I don’t add user group to the attributes.

Hi, Thanks for the quick reply.

So far I have simply changeds the mount point, and listed it by device ID.

rob@linux-mzrw:~> cat /etc/fstab/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part1 swap                 swap       defaults              0 0                                                                                                                                                                       
/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part5 /                    ext4       acl,user_xattr        1 1                                                                                                                                                                       
/dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part6 /home                ext4       acl,user_xattr        1 2                                                                                                                                                                       
/dev/disk/by-id/ata-SAMSUNG_HD154UI_S1XWJ9BZA00981-part5 /mmt/Media           ext4       user,acl,user_xattr   1 2                                                                                                                                                             
/dev/disk/by-id/ata-ST96812AS_5PJ7EB02-part1   /mmt/Stuff           ext4       user,acl,user_xattr   1 2                                                                                                                                                                       
proc                 /proc                proc       defaults              0 0                                                                                                                                                                                                 
sysfs                /sys                 sysfs      noauto                0 0                                                                                                                                                                                                 
debugfs              /sys/kernel/debug    debugfs    noauto                0 0                                                                                                                                                                                                 
usbfs                /proc/bus/usb        usbfs      noauto                0 0                                                                                                                                                                                                 
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0  

Im not sure why, but /mmt/Stuff seems to have the correct permissions, I can delete, copy, eidt files on that drive as I would like to, but not on /mmt/Media, and I’m not sure how to set that?

I cant edit my post, have had to reply.

I have installed the automated permissions script.

managed to cd to /mmt

I’m displayed with this, a clear difference between the two drives

drwxr-xr-x 8 root root 4096 Dec  9 17:32 Media
drwx------ 6 rob  1000 4096 Dec  9 16:19 Stuff

I assume I want Media to match that or Stuff

On 2012-12-10 00:16, rob 1980 wrote:

> I have aslo tried to pm hcvv as my other thread got locked, So I could
> not reply to anyone after regarding the advice I was given, but I cannot
> see my message in my sent items, so think it failed to send.

I believe it is open now, on a new link. I’m hesitant to reply here, as
a matter of of fact.

> here is the fstab,
>
>
> Code:
> --------------------
> rob@linux-mzrw:~> cat /etc/fstab
> /dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part1 swap swap defaults 0 0
> /dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part5 / ext4 acl,user_xattr 1 1
> /dev/disk/by-id/ata-ST3400620AS_5QG03ZZD-part6 /home ext4 acl,user_xattr 1 2
> /dev/sdb5 /media/Media ext4 user,acl,user_xattr 1 2
> /dev/sdc1 /media/Stuff ext4 user,acl,user_xattr 1 2

> --------------------

> From my last thread I have learned the following, please could somebody
> confirm them for me.
>
>
> It is best to mount drives by-id, I will use this command to see how
> they should be listed

I personally prefer mount by label.

> I should NEVER create mount points in /media, but instead use /mnt. So
> I will edit that in fstab, and remount the drives at those location
> (/Media and /Stuff) using the partition tool (Im sure there is a command
> to do it, I’m used to windows and GUI)

Yes, the partition tool should do it fine.

> I would like to chown and chmod the parent directories, /mnt/Media and
> /mnt/Stuff, That way I have permissions to write to both of those
> drives, I dont have multiple users, or any groups set up, just my log
> in.

Ok.

> IS this easiest done with commands, if so I would probably need some
> help, although I’m sure the info is out there, and Im happy to look for
> it, if I know its the right way to do it.

It can be done with commands. I can not say how to do it with a GUI
because I don’t know how :slight_smile:

However, there is something intermediate that I use: midnight commander
(mc). It is a file browser that runs in text mode, or inside a terminal.
You have to install it first.

>
> Or should I be using what looks to be a great script by *‘jdmcdaniel3’
> (https://forums.opensuse.org/members/jdmcdaniel3.html) *S.A.F.P. - SUSE
> Automated File Permissions - Version 1.0.4:
> ‘https://forums.opensuse.org/blogs/jd...ion-1-0-4-113/
> (http://tinyurl.com/cw4lrm7).

Dunno, not familiar with that one.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Hi
1000 = your user rather that the users group, plus make it 0755

So as root;


cd /mnt
chown rob:users Stuff
chmod 0755 Stuff

On 2012-12-10 00:56, rob 1980 wrote:
>
> I cant edit my post, have had to reply.
>
> I have installed the automated permissions script.
>
> managed to cd to /mmt
>
> I’m displayed with this, a clear difference between the two drives
>
>
> Code:
> --------------------
> drwxr-xr-x 8 root root 4096 Dec 9 17:32 Media
> drwx------ 6 rob 1000 4096 Dec 9 16:19 Stuff
>
> --------------------
>
>
> I assume I want Media to match that or Stuff

Good.

Do this, in a terminal:


> su -
> find /mnt/Media/ -type f -exec chown username:users '{}' \;
> find /mnt/Media/ -type f -exec chmod u+r+w,o-r-w,g-r-w '{}' \;
> find /mnt/Media/ -type d -exec chmod u+r+w+x,g-w-r-x,o-w-r-x '{}' \;

The first line finds all files in /mnt/Media and executes a command on
each that changes them to belong to user “username” and group “users”.
Just change “username” to your own user name.

The second line does the same find sequence, but this time it changes
the permissions of all files.

And the third line does the same, but instead of files finds directories
and changes their permissions (you need different permissions for files
than for directories).


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Yep, I wouldn’t mount an internal drive in /media either, if only for organization sake :).
I normally put dmask=0002 in mount options. That works fine.

On 12/10/2012 12:58 AM, Carlos E. R. wrote:
> It can be done with commands. I can not say how to do it with a GUI
> because I don’t know how

though i have never done it the GUI way, i would think it possible to:

-using the menu system launch Applications > System > File Manager >
File Manager - Superuser Mode (give root password when asked) then

-navigate to the drive in question (whether that is /media/Media or
/mnt/Media or /data/Media makes no difference to this method)

-right click on the icon of that drive, and select “Properties” then the
“Permissions” tab

-adjust “Access Permissions” to allow owner/group/others to any of the
three choices available (view = NO writes; modify = writes allowed;
forbidden = can’t write or view)

-adjust “Ownership” to ‘rob’ and ‘users’

-click “Ok”

-CLOSE the superuser powered file manager (that is, don’t forget it is a
superuser appliance and KILL your system by accident)

now, lets look at what you wrote in one of your post: “This drive will
not allow me to copy, write files, even play music unless i browse in
Dolphin with super user, or log in as root.”

by that last part (log in as root) i assume you say at the login
screen for KDE, GNOME, LDXE or other desktop environment (DE) and typed
in “root”, gave the root password and logged into the DE as root…

unfortunately, that is a very common mistake done by folks new to
*nix-like operating systems, because in their previous OS it was normal
to log in as the Administrator…

but, not so here:

you should never log into KDE/GNOME/LXDE/Xfce or any other *nix-like
system’s graphical user interface desktop environment as root…

doing so 1) opens you up to several different security problems if you
(for example) browse the net, 2) too many, far too easy ways to damage
your system no matter how careful your actions (for
example: cases of unintended change of ownership of some files from user
to root sometimes occurs which can preclude logging in as the user), 3)
anyway logging into KDE/etc as root is never required to do any or all
administrative duties, 4) and, not even logging in as root just to see
if it works as root is useful, because the “yes” or “no” learned is
almost always totally useless in finding the
problem giving the symptoms…while, logging into the GUI as root to
learn the yes/no could cause the next adverse symptom encountered.

so, always log in as yourself, and “become root” by using a root powered
application (like YaST, File Manager Superuser Mode) or using “su -”,
sudo, kdesu, or gnomesu in a terminal to launch whatever tool is needed
(like KWrite or gedit to edit a config file)…read more on all that here:

http://tinyurl.com/593e4c
http://tinyurl.com/ydbwssh
http://tinyurl.com/4nsaqst
http://tinyurl.com/665h5ek
http://www.linfo.org/root.html
http://tinyurl.com/6ry6yd

additionally: after logging into KDE/Gnome/etc as root, if you
experience problems (for example, with uncommanded file ownership and
permissions changes) and if you can provide us with details of what you
were doing while you were logged in as root, that would help us identify
if there’s a bug that needs to be fixed…thanks for your help…


dd http://tinyurl.com/DD-Caveat

On 2012-12-10 08:56, JopSway wrote:
> I normally put dmask=0002 in mount options. That works fine.

That works for fat, for ext4 that option is ignored or gives error.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Thanks to everyone for their responses.

I was at work today, did try a couple of things this morning, but didn’t succeed, I was keen to get home and continue to get this to work with the help provided by you all, although very slightly frustrating, I know once i have resolved this, I will have learned something more about linux.

The gui method below works to a certain point, in that it will allow me to have the permissions I need to all folders and sub folders.
My concern is that I would have to do that each time I created a new folder, correct me if I’m wrong?

In regards to login in as root, I did that once yesterday as a point of testing for this issue, ordinarily, in fact, I have never logged in as root before, I have never needed to, simply entered my password when required, mu understanding through help of some of you here, and on ubuntu forums when I was trying that out, is simply put, linux is more secure than other operating systems due to the fact that the user does not automatically have permissions to write to files that could damage the system, meaning a virus would also not have those permissions (unless logged in as root, or leaving a terminal window open logged in as super user)

So, back to my findings from this morning…

I tried this

> su -
> find /mnt/Media/ -type f -exec chown username:users '{}' \;
> find /mnt/Media/ -type f -exec chmod u+r+w,o-r-w,g-r-w '{}' \; 
> find /mnt/Media/ -type d -exec chmod u+r+w+x,g-w-r-x,o-w-r-x '{}' \;

and this

cd /mntchown rob:users Mediachmod 0755 Media

Both of the above failed.

I’m still slightly confused on my issue, I mean, is it permission issues I have, ownership, or both? (Im trying to figure these both out, and will start to do some more reading now)

I’m sure this permissions thing is pretty straight forward and simple, I hope I’ll be kicking myself when I realise just how easy it is.

Thanks for everyones input!!!

Rob

Hi
You replace username with your username…rob?

The chown and chmod commands are two separate commands, you output in the above posts shows all one line?

When changing to super user you used the su - and not just su?

sorry, for some reason, the paste hasnt displayed properly.

I think i put su , not su -

I guess that makes a difference, I will try again, thanks

Does it matter if the drive is mounted or not when I try to change permissions?

I did change usernsame to rob, but left “users”, perhaps this is incorrect…

Ive tried again, users must be right, as it is setting tyhe group, i got an error message when trying to change it… I will learn this lol!!!

rob@linux-mzrw:~> su -
Password: 
linux-mzrw:~ # cd /mmt
linux-mzrw:/mmt # chown rob:users Media
linux-mzrw:/mmt # chmod 0755 Media
linux-mzrw:/mmt # exit
logout
rob@linux-mzrw:~> 



I will try a reboot, as it hasn’t changed anything yet

Hi
Yes the drive needs to be mounted :wink:

rob:users is correct :slight_smile:

That hasn’t worked.

I am learning something though.

My understanding is that the owner is the one who created the folder / file.

I cannot think of a reason why, but it seems that the disk when formatted to ext4 using partitioner, and then the folders created were done as root (I was logged in as rob at the time)

I have just found that in fact, If I do create a new folder in /mmt (which it is allowing me to do) I have the permissions I require, and when checking the permissions tab on that folder, ownership is set to

user:rob
group >users

in the other folders it is

user : root
goup :root

Upon further inspection now, mp3 files that would not play last night (they would open, but not start the track) now work fine, but I still cannot “cut” files or folders. (unless I have created a new folder)

So for now, I will log in super user on Dophin, set folder permissions to work, then as it seems any new folder created as rob will work, that should solve my issue.

I’m doubtful this is the absolute correct solution, but think it will achieve my goal.

Ok, that has worked and given me the permissions I had previous when it was ntfs. (or at least allows me to have the control of files I am used to)

I can now, logged in as rob, write files, create folders, cut, delete and use files in mmt/Media, all sub directories, and newly created files etc.

Many thanks to everyone for the help I have been given.

This is very much appreciated…

Rob

aaaggh, I cannot edit the title of my thread to include [solved]?

On 2012-12-10 17:26, rob 1980 wrote:

> The gui method below works to a certain point, in that it will allow me
> to have the permissions I need to all folders and sub folders.
> My concern is that I would have to do that each time I created a new
> folder, correct me if I’m wrong?

No if you create the files as that user (rob).

>
> I tried this
>
>
> Code:
> --------------------
> > su -
> > find /mnt/Media/ -type f -exec chown username:users ‘{}’ ;
> > find /mnt/Media/ -type f -exec chmod u+r+w,o-r-w,g-r-w ‘{}’ ;
> > find /mnt/Media/ -type d -exec chmod u+r+w+x,g-w-r-x,o-w-r-x ‘{}’ ;
> --------------------
>
>
> and this
>
>
> cd /mntchown rob:users Mediachmod 0755 Media
>
>
> Both of the above failed.

You have to post here the entire command sequence you did with prompt
and errors for us to see. But Malcolm is in the right track.

>
> I’m still slightly confused on my issue, I mean, is it permission
> issues I have, ownership, or both?

My guess is both, that’s the reason of the three lines.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Hi, thanks for the reply…

this is a paste from console, I just tried it again, there was no error code, or message, it just failed to make any changes ( I fear now, that perhaps the first time i used su, and not su - …

rob@linux-mzrw:~> su -
Password: 
linux-mzrw:~ # find /mnt/Media/ -type f -exec chown rob:users '{}' \;
linux-mzrw:~ # find /mnt/Media/ -type f -exec chmod u+r+w,o-r-w,g-r-w '{}' \;
linux-mzrw:~ # find /mnt/Media/ -type d -exec chmod u+r+w+x,g-w-r-x,o-w-r-x '{}' \;
linux-mzrw:~ # exit
logout
rob@linux-mzrw:~> 



However, I have resolved the issue now, everything seems to be as it should, and you are correct, creating any new folder as rob, sets rob as the owner.

Thank you again :slight_smile:

I just need to find out now how to edit the title of my thread to [solved] to save others from reading further if they dont have to.

cheers everyone!!

On 12/10/2012 06:36 PM, rob 1980 wrote:
> I cannot edit the title of my thread to include [solved]?

but you can tag it as solved–and if you do so and someone searches
using the forum search engine along with the solved tag, yipee

and if anyone searches with google using “solved” it just might turn up.

OH, look at that, my title includes [SOLVED], must be magic!! :slight_smile:


dd

On 2012-12-10 18:46, rob 1980 wrote:
>
> Hi, thanks for the reply…
>
> this is a paste from console, I just tried it again, there was no error
> code, or message, it just failed to make any changes ( I fear now, that
> perhaps the first time i used su, and not su - …
>
>
> Code:
> --------------------
> rob@linux-mzrw:~> su -
> Password:
> linux-mzrw:~ # find /mnt/Media/ -type f -exec chown rob:users ‘{}’ ;
> linux-mzrw:~ # find /mnt/Media/ -type f -exec chmod u+r+w,o-r-w,g-r-w ‘{}’ ;
> linux-mzrw:~ # find /mnt/Media/ -type d -exec chmod u+r+w+x,g-w-r-x,o-w-r-x ‘{}’ ;
> linux-mzrw:~ # exit
> logout
> rob@linux-mzrw:~>
>
>
>
> --------------------

In Linux terminal, no message means success. There is no need to talk if
there is no error. If there is an error, print it.

So the above commands worked fine. :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)