Advice Needed regarding Sudo/Permissions

I’m a Linux newbie, running Manjaro/KDE for about a week. Recently, I added a USB HD to my box and partitioned it to ext4 and NTFS. The NTFS portion was for sharing with my Windows box. I managed to get this working, not via Dolphin and not the way I want, but working for now.

The etx4 partition, however, has got me scratching my head. It appears both partitions have root as the owner and group. The NTFS portion has full read/write for everyone, but the ext4 partition lacks write privileges for everyone. I’m not sure if this is “normal” or if I missed something while partitioning.

I want both partitions to act as if they’re mine; not that greedy root fellow. After some thought, it seemed I have two options (again, newbie):

  1. Increase my user authority/privileges. This sounds like logging in as root. It feels wrong and I’m not sure it would bring the desired result (freely adding/removing files/folders in Dolphin).

  2. Change the partition(s) owner/group. This seems like the “proper” way to take control (and pull the rug out from under that greedy root person).

I believe I can change the owner/group using chmod/chown, but I’m not sure whether I should change the owner AND the group, or just the owner. Changing owner to “me” and group to “me” feels like I’m shooting myself in the foot should my user account get scrambled (by a newbie). On the other hand, changing the owner to “me” and leaving the group as root, seems strange.

In the end, I’m the only user on this machine and its ultimate use will be an Emby media server at some point.

I know I sound like an ignorant newbie. The fact is, I am an ignorant newbie, but I’m hoping this post will ensure I don’t become a stupid, ignorant newbie. :slight_smile:

I really need a shove down the right path. Some opinions/examples/ URLs would be nice too.

Thanks, Chris.

I recently ran into this when partitioning a 2TB external USB HDD for backups.
Made three partitions - 1 NTFS and 2 ext4.
Found out later that the NTFS partition was owned by ‘me’ but the two ext4 partitions were owned by ‘root’ and I could not write to them as a ‘regular’ user :confused:
I just used the ‘chown’ command to take ownership of them.

sudo chown -R user_name:group_name directory_name

The -R is ‘recursive’ as I was taking ownership of the whole Directory and wanted that ownership to apply to all the files inside of it.

The Linux Handbook site has some good examples. I think I cannot post links yet so just go to linuxhandbook dot com /chown-command

3 Likes

Hello everyone,
I would generally advise against taking ownership with chown, instead I would use chmod to give the user privileges. To be able to acces and write to the harddrive without becoming root, you need to type:

chmod -R +rw [path to you harddrive: usually something like /run/media/Seagate or whatever]

-R is for recursive
+rw means adding Read and Write permissons to the user

4 Likes

Hello again,

@VraiChevalier: Yes… This is the same thing except “I” don’t own anything.

@julius-gu: This looks like an elegant solution; I thought I was going to have light bulb moment, but then:

Ran: chmod -R +rw /mnt/… and got a screen dump of “access denied” (basically).

Ran: sudo chmod -R +rw /mnt/… and it seemed to work, but then I opened Dolphin, went to the partition, right clicked, and “Create…” is grayed out.

On a wing and a prayer, I returned the drive to its default state and:

Ran: chmod -R +rw /run/media/username/… and got the same screen dump. Running with sudo also produced the same (non)result.

In Dolphin, the permissions show as:

Access Permission
Owner: Can View & Modify Content
Group: Can Only View Content
Others: Can Only View Content

Ownership
User: root
Group: root

What am I missing here?

Thanks, Chris.

that is interesting.
I guess, you will have to change the ownership then :man_shrugging:, sorry
Best Regards, Julius

Good point. I wondered about this.
I wonder if it is possible for a user to take ownership with ‘chown’ but still not have write and execute permissions?
Any thoughts on this would be appreciated.

No worries Julius.

Chown worked on the ext4 partition (that I couldn’t write to). I thought it might be worth mentioning that it did nothing to the NTFS partition (that had full permissions anyway) and the owner and group remained as root. I suspect this is because NTFS doesn’t “respect” Linux permissions.

@VraiChevalier: When you changed your partition(s), did you change both owner and group to “you”, or did you change owner to “you” and leave group as root?

Thanks again to everyone for the help, Chris.

1 Like

@cwebster : I used chown and changed both owner and group to me. Like this:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.