Why can I not create new folders in newly created ext4 partition without using sudo?


(ruben) #1

Hello everyone,
It may sound stupid, but I don’t understand why I can’t create a new folder in a fresh ex4 partition I just created.
If I right click, “create new” is greyed out. But if I open a terminal, mkdir, it wants permission so I am forced to use sudo and then it works. Why would it need administrator rights to create a new folder ??
I feel there is a simple explanation but I am a bit stuck…Any ideas ?
Thanks


(Hans Tovetjärn) #2

Who is the owner of the partition? Use chown to change its owner to your user.


(ruben) #3

Thanks for the quick answer.

There is only one user on my computer : me. Never changed anything about users settings and when I created the partition I was logged normally as myself and there was nothing asking me to chose user or something.

I tried :

sudo chown ruben /dev/sda2

It looked like the command worked, but nothing changed about “create new” being still greyed out.


(Hans Tovetjärn) #4

I’d assume that the partition is owned by root:root. Check the permissions for the mount point using ls -l.


(ruben) #5

You assumed right, before the chown command /dev/sda2 was “root”, now it is “ruben”.
It still doesn’t let me create anything new though. (I tried log off - log-on)


(Hans Tovetjärn) #6

What about the mount point? Use lsblk.


(ruben) #7
$ lsblk /dev/sda2
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda2   8:2    0 434.6G  0 part /run/media/ruben/Lacie

Can’t understand it…


(Hans Tovetjärn) #8

Run ls -l /run/media/ruben.


(ruben) #9
$ ls -l /run/media/ruben
total 4
drwxr-xr-x 4 root root 4096 21.03.2018 19:44 Lacie/

I understand it was owned by this root root guy…:joy:
Chowned it, but still doesn’t help…I’ll try restarting maybe ?
By the way, how comes a folder named “ruben” is not owned by ruben ? Can’t understand the logic here…


(Hans Tovetjärn) #10

Please post both the command you run and the resulting output, guessing is tedious.

$ sudo chown -Rv ruben:ruben /run/media/ruben/Lacie

I’m assuming that your username is ruben.

You can name folders whatever you want, it has no impact on the ownership.


(ruben) #11

Oh, you are right, I was using sudo chown ruben /run/media/ruben

$ sudo chown -Rv ruben:ruben /run/media/ruben/Lacie
appartenance de '/run/media/ruben/Lacie/lost+found' modifiée de root:root en ruben:ruben
appartenance de '/run/media/ruben/Lacie/BACKUP' modifiée de root:root en ruben:ruben
appartenance de '/run/media/ruben/Lacie' modifiée de root:root en ruben:ruben

For some reason it decided to answer this time in french :face_with_raised_eyebrow:…It means it modified from root:root to ruben:ruben

Of course, but what the point of creating user when installing if at the end we still have to take ownership of stuff manually


(Hans Tovetjärn) #12

Please post in English:

Since /run/media/ruben/Lacie is now owned by you, try running the following:

$ touch /run/media/ruben/Lacie/foo

This will create an empty file named foo in that location. You should be able to do this, and also create directories, without the need for sudo.

Your $HOME directory should be owned by your user and have the correct permissions set. However I have no idea how this new partition was created:

I don’t know what software or options you used, so answering this question is difficult.


(ruben) #13

Thank you for all the info !
The “Create new” works now. I created the partition with KDE partition manager and it never occured me that I won’t be able to actually own the partition created…


(Hans Tovetjärn) #14

When running KDE Partition Manager, you should be prompted to enter your password in order to give you root privileges. Your user is likely to be a member of a group listed in /etc/sudoers, or listed there directly by name. Also note the option to use the same password for your user and the root accounts during installation.

I’m not familiar with the effects of changing ownership of devices and suggest that you change this back:

On my system, it looks like this:

$ ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Mar 19 10:55 /dev/sda
brw-rw---- 1 root disk 8,  1 Mar 19 10:55 /dev/sda1
brw-rw---- 1 root disk 8, 16 Mar 19 10:55 /dev/sdb
brw-rw---- 1 root disk 8, 17 Mar 19 10:55 /dev/sdb1
brw-rw---- 1 root disk 8, 32 Mar 19 10:55 /dev/sdc
brw-rw---- 1 root disk 8, 33 Mar 19 10:55 /dev/sdc1
brw-rw---- 1 root disk 8, 48 Mar 19 10:55 /dev/sdd
brw-rw---- 1 root disk 8, 49 Mar 19 10:55 /dev/sdd1
brw-rw---- 1 root disk 8, 64 Mar 19 10:55 /dev/sde
brw-rw---- 1 root disk 8, 65 Mar 19 10:55 /dev/sde1
brw-rw---- 1 root disk 8, 66 Mar 19 10:55 /dev/sde2
brw-rw---- 1 root disk 8, 67 Mar 19 10:55 /dev/sde3
brw-rw---- 1 root disk 8, 80 Mar 19 10:55 /dev/sdf
brw-rw---- 1 root disk 8, 81 Mar 19 10:55 /dev/sdf1
brw-rw---- 1 root disk 8, 96 Mar 21 19:18 /dev/sdg
brw-rw---- 1 root disk 8, 97 Mar 21 19:18 /dev/sdg1

So if you only changed /dev/sda2, this should undo it:

$ sudo chown -v root:disk /dev/sda2

I recommend using -v or at least -c when running chown, for the sake of knowing what changed or not.


(ruben) #16

Thank you, I used the command you sent me and it said ownership changed back to “root:disk”.

I always enter my password for KDE partition Manager and it is the same as root. I never created any distinct user and just used “ruben”

I’m not sure what is supposed to be there, but the only line without “#” in my /etc/sudoers is :
“root ALL=(ALL) ALL”


(Hans Tovetjärn) #17

Please edit your previous post rather than posting sequential replies. The partition was created with root privileges (you entered your password for those) and therefore owned by root:root rather than ruben:ruben. If you create a file without and then with sudo, the ownership will look like this:

$ touch abc 
$ sudo touch def
$ ls -l
total 0
-rw-r--r-- 1 totte totte 0 Mar 22 18:06 abc
-rw-r--r-- 1 root  root  0 Mar 22 18:06 def

For more information about sudo, please see the manual entries man sudo and man sudoers. For more information about the user root, see the link to Wikipedia in my previous post.


(system) #18

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