You are not logged in.

#1 2020-07-10 20:43:22

callmejoe
Member
Registered: 2019-03-06
Posts: 84

[solved] root privileges to delete files and directories?

i have an ext4 partition mounted under /mnt via fstab.  There are some directories/files owned by me and some by root.

i always thought i could delete the directories/files owned by me without needing root privileges.  but seems I can't.  i can delete files and sub-directories within a parent directory i own though without being root.

is it because the partition was mounted as root? i tried setting the uid and gid to 1000 in fstab but got an error when trying to mount it. 

uid=1000 works on ntfs partitions.  maybe not so much on ext4 partitions??

Last edited by callmejoe (2020-07-10 23:23:39)

Offline

#2 2020-07-10 21:21:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [solved] root privileges to delete files and directories?

There's really nothing in your post to go on.

callmejoe wrote:

... but seems I can't... but got an error when trying to mount it.

Why does it seem that way?  What error did you get?

https://bbs.archlinux.org/viewtopic.php?id=57855
http://catb.org/~esr/faqs/smart-questions.html

Last edited by Trilby (2020-07-10 21:25:00)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2020-07-10 21:49:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,762

Re: [solved] root privileges to delete files and directories?

https://stackoverflow.com/questions/546 … le-in-unix

maybe not so much on ext4 partitions??

No.

Offline

#4 2020-07-10 22:13:17

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] root privileges to delete files and directories?

Owning the directory lets you create and modify stuff inside it.

Following that chain of thought, if you own the parent directory "a" of a directory "b", you can create and modify, and most importantly *delete*, directory "b".

If you own /home/callmejoe but obviously you don't own /home does that mean you should have the right to delete /home/callmejoe? How would you recover from this?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2020-07-10 22:20:48

callmejoe
Member
Registered: 2019-03-06
Posts: 84

Re: [solved] root privileges to delete files and directories?

here is the line in fstab for partition in quesiton

UUID=493ad287-bb83-404c-a6e6-26d236375196       /mnt/bitcoin    ext4    defaults,uid=1000,gid=1000,noauto,noatime,nofail,x-gvfs-show 0  0

was giving me this error

callmejoe@ArchMan ~ $ sudo mount /mnt/bitcoin
mount: /mnt/bitcoin: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error

but i scrapped those options and changed it to

UUID=493ad287-bb83-404c-a6e6-26d236375196       /mnt/bitcoin    ext4    defaults,user,noauto,noatime,nofail,x-gvfs-show 0       0

and i was able to mount without using sudo

but i still can't delete the files or directories that i own

callmejoe@ArchMan ~ $ ls -l /mnt/bitcoin
total 32
drwxr-xr-x 2 root      root       4096 Jul 10 16:15 arch
drwxr-xr-x 4 callmejoe callmejoe  4096 Jul 10 09:13 Bitcoin
drwx------ 2 callmejoe callmejoe 16384 Oct 29  2017 lost+found
-rw-r--r-- 1 callmejoe callmejoe     0 Jul 10 10:15 test
drwxr-xr-x 2 callmejoe callmejoe  4096 Jul 10 16:40 test3
drwxr-xr-x 9 root      root       4096 Mar 29 02:01 timeshift

i have rw permissions on test and test3.  shouldnt i be able to delete them without having to use sudo?

callmejoe@ArchMan /mnt/bitcoin $ rm test
rm: cannot remove 'test': Permission denied

Offline

#6 2020-07-10 22:23:50

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] root privileges to delete files and directories?

Once again, no.

If you had read-write for /mnt/bitcoin, then that would be a different story.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2020-07-10 22:28:12

callmejoe
Member
Registered: 2019-03-06
Posts: 84

Re: [solved] root privileges to delete files and directories?

eschwartz wrote:

Once again, no.

If you had read-write for /mnt/bitcoin, then that would be a different story.

hmmm. this is what i am having trouble getting my head around.  i thought if i mounted /mnt/bitcoin as user and not root then i would have rw permissions.

EDIT: oh wait i would have to go up a level and chown the bitcoin directory?

Last edited by callmejoe (2020-07-10 22:30:14)

Offline

#8 2020-07-10 22:29:57

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,762

Re: [solved] root privileges to delete files and directories?

Think it this way: a directory is a list of the files inside. If you want to add or remove files, you need to write that list.

The directory you mount has the permissions that it has, not the one of the user that calls mount.
You can re-chown/chmod it (nb. when the path is mounted, not the empty mountpath)

Offline

#9 2020-07-10 22:33:21

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: [solved] root privileges to delete files and directories?

The "test" file is an entry inside the "bitcoin" directory. When you remove "test", you are changing "bitcoin", so you would need permissions for "bitcoin". You get the error message because "bitcoin" is owned by root.

What you can do is collect all data for your user inside a sub-directory. I mean, create a directory "/mnt/bitcoin/callmejoe/", and make that directory owned by your user account, then afterwards only work inside that directory instead of inside /mnt/bitcoin. You will be able to delete files inside that "/mnt/bitcoin/callmejoe/" location.

If you feel that the names will get too long and awkward, perhaps create a directory "/data" and then mount your current "/mnt/bitcoin" filesystem in that "/data" location. The sub-directory for your user would then be "/data/callmejoe/", your stuff would have names like "/data/callmejoe/Bitcoin/".

Offline

#10 2020-07-10 22:56:57

callmejoe
Member
Registered: 2019-03-06
Posts: 84

Re: [solved] root privileges to delete files and directories?

seth wrote:

Think it this way: a directory is a list of the files inside. If you want to add or remove files, you need to write that list.

The directory you mount has the permissions that it has, not the one of the user that calls mount.
You can re-chown/chmod it (nb. when the path is mounted, not the empty mountpath)


getting clearer now. thanks!

Offline

Board footer

Powered by FluxBB