LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 08-31-2023, 10:35 PM   #1
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Rep: Reputation: 0
How to add owner and group to a folder


Hello,

I accidentally make /mnt folder having no owner and group like this:
d????????? ? ? ? ? ? mnt

How to make it a normal folder as before with owner and group of root?

Thanks!
Crane
 
Old 09-01-2023, 04:28 AM   #2
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,521

Rep: Reputation: Disabled
Likely, as the root user...

Code:
chown root:root /mnt
 
Old 09-01-2023, 09:12 PM   #3
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by fatmac View Post
Likely, as the root user...

Code:
chown root:root /mnt
Tried, but it doesn't work. Here is the result:

crane@Ubuntu2204:~/yocto-pi$ sudo chown root:root /mnt

[sudo] password for crane:

chown: cannot access '/mnt': Protocol error
 
Old 09-01-2023, 09:27 PM   #4
___
Member
 
Registered: Apr 2023
Posts: 156
Blog Entries: 1

Rep: Reputation: Disabled
Something inaccessible probably got mounted there. Try: df /mnt; grep mnt /proc/mounts

Can you?: sudo rm /mnt; sudo umount -f /mnt

Last edited by ___; 09-01-2023 at 09:29 PM.
 
1 members found this post helpful.
Old 09-02-2023, 04:12 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
you cannot add owner and group to anything, everything has owner and password always. You can only modify it. ??? means the information is not available, the device is not accessible.
Would be nice to know what is it, how is it mounted and if there was any error message in your logs about it.
How did you "produce" it at all?
 
Old 09-02-2023, 08:58 AM   #6
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ___ View Post
Something inaccessible probably got mounted there. Try: df /mnt; grep mnt /proc/mounts

Can you?: sudo rm /mnt; sudo umount -f /mnt

Here are the results after running these commands:
crane@Ubuntu2204:~/yocto-pi$ df /mnt
df: /mnt: Protocol error
crane@Ubuntu2204:~/yocto-pi$ grep mnt /proc/mounts
nsfs /run/snapd/ns/snapd-desktop-integration.mnt nsfs rw 0 0
nsfs /run/snapd/ns/snap-store.mnt nsfs rw 0 0
vmshare /mnt vboxsf rw,nodev,relatime,iocharset=utf8,uid=0,gid=999,dmode=0770,fmode=0770,tag=VBoxAutomounter 0 0
crane@Ubuntu2204:~/yocto-pi$ sudo rm -r /mnt
rm: cannot remove '/mnt': Is a directory
crane@Ubuntu2204:~/yocto-pi$ sudo umount -f /mnt
crane@Ubuntu2204:~/yocto-pi$

Yes, it works to delete the foler /mnt using sudo umount -f /mnt.
Then I set up the shared folder with the mounting point /mnt again and it works to create the folder /mnt again.
The issue is addressed.

Quote:
Originally Posted by pan64 View Post
you cannot add owner and group to anything, everything has owner and password always. You can only modify it. ??? means the information is not available, the device is not accessible.
Would be nice to know what is it, how is it mounted and if there was any error message in your logs about it.
How did you "produce" it at all?
Yes, it seems not accessible any more.

Here are what's in the log:
crane@Ubuntu2204:~/yocto-pi$ sudo dmesg | grep mnt
[sudo] password for crane:
[ 5365.468560] 03:06:24.126084 automount vbsvcAutomounterMountIt: Successfully mounted 'vmshare' on '/mnt'
[ 5666.238214] 03:11:24.895731 automount vbsvcAutomounterMountIt: Successfully mounted 'vmshare' on '/mnt/'
[ 5895.652601] 03:15:14.310132 automount Error: vbsvcAutomounterMountIt: Failed to create mount path '/mnt/vmshare' for share 'vmshare': VERR_NET_PROTOCOL_ERROR
[ 5895.653087] 03:15:14.310630 automount Error: vbsvcAutomounterMountIt: Failed to create mount path '/mnt/vmshare' for share 'vmshare': VERR_NET_PROTOCOL_ERROR
[ 5895.653783] 03:15:14.311332 automount Error: vbsvcAutomounterMountIt: Failed to create mount path '/mnt/vmshare' for share 'vmshare': VERR_NET_PROTOCOL_ERROR
[ 5895.653933] 03:15:14.311487 automount Error: vbsvcAutomounterMountIt: Failed to create mount path '/mnt/vmshare' for share 'vmshare': VERR_NET_PROTOCOL_ERROR
crane@Ubuntu2204:~/yocto-pi$

This is produced when I play around with shared folder on VirtualBox. I don't know exactly what happened. Probably after I change the mount point back and forth for the shared folder in VirtualBox settings.

Thank all of you for your help!

Last edited by Cranegsh; 09-02-2023 at 09:19 AM.
 
Old 09-02-2023, 10:50 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
nice. In that case I would suggest you to mark the thread as solved!
Don't forget, the mount point itself is a directory, but what you mounted is a device. In your case you removed the mounted device without umount-ing it, therefore the mount pointed to something invalid.
You need to keep the order: umount, rename/move mount point, mount again. Do not attempt to move a mounted device (or you will get an error like that).
 
1 members found this post helpful.
Old 09-11-2023, 01:00 PM   #8
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
nice. In that case I would suggest you to mark the thread as solved!
Don't forget, the mount point itself is a directory, but what you mounted is a device. In your case you removed the mounted device without umount-ing it, therefore the mount pointed to something invalid.
You need to keep the order: umount, rename/move mount point, mount again. Do not attempt to move a mounted device (or you will get an error like that).
Ok got it. Thanks for the summary!
 
Old 09-11-2023, 01:10 PM   #9
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
This time, it happens again, but not with a mount point.

This is how it happens. I found the folders in a folder are all executable. I don't like these folders with x attribute, so I tried to make the change.

crane@Ubuntu2204:~/farview$ ls -ltr kmodule/
total 20
drwxrwxr-x 2 crane crane 4096 Sep 5 17:06 start
drwxrwxr-x 2 crane crane 4096 Sep 6 13:41 simple
drwxrwxr-x 2 crane crane 4096 Sep 7 14:17 simple-rw
drwxrwxr-x 2 crane crane 4096 Sep 7 14:44 memory
drwxrwxr-x 2 crane crane 4096 Sep 10 00:58 devspi
crane@Ubuntu2204:~/farview$ sudo chmod -x -R kmodule/
[sudo] password for crane:
crane@Ubuntu2204:~/farview$ ls -ltr kmodule/
ls: cannot access 'kmodule/devspi': Permission denied
ls: cannot access 'kmodule/simple-rw': Permission denied
ls: cannot access 'kmodule/start': Permission denied
ls: cannot access 'kmodule/memory': Permission denied
ls: cannot access 'kmodule/simple': Permission denied
total 0
d????????? ? ? ? ? ? start
d????????? ? ? ? ? ? simple-rw
d????????? ? ? ? ? ? simple
d????????? ? ? ? ? ? memory
d????????? ? ? ? ? ? devspi
crane@Ubuntu2204:~/farview$

I am able to use "chmod +x -R" to change the attribute back to be executable and then they are accessible.

But I have no idea why chmod causes this result. Any idea?
 
Old 09-11-2023, 01:18 PM   #10
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by Cranegsh View Post
This time, it happens again, but not with a mount point.

This is how it happens. I found the folders in a folder are all executable. I don't like these folders with x attribute, so I tried to make the change.
The 'x' attribute on directories is not 'executable', it is 'traversable'. A directory cannot be executed, only traversed.

When you remove the 'x', or the traversability you can no longer see into its meta-data or see what is in it! Hence, d????????? ? ? ? ? ? start as it knows it is a directory and gets its name from the parent's meta-data, but can see nothing else.

Directories should always be traversable for those users who need to see inside them.

Last edited by astrogeek; 09-11-2023 at 01:29 PM. Reason: formatting, link, tpoys
 
1 members found this post helpful.
Old 09-11-2023, 01:18 PM   #11
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by Cranegsh View Post
This time, it happens again, but not with a mount point.

This is how it happens. I found the folders in a folder are all executable. I don't like these folders with x attribute, so I tried to make the change.
The 'x' attribute on directories is not 'executable', it is 'traversable'. A directory cannot be executed, only traversed.

When you remove the 'x', or the traversability you can no longer see into its meta-data or see what is in it! Hence, d????????? ? ? ? ? ? start as it knows it is a directory and gets its name from the parent's meta-data, but can see nothing else.

Directories should always be traversable for those users who need to see inside them.

Last edited by astrogeek; 09-11-2023 at 01:29 PM. Reason: formatting, link, tpoys
 
1 members found this post helpful.
Old 09-11-2023, 01:55 PM   #12
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by astrogeek View Post
The 'x' attribute on directories is not 'executable', it is 'traversable'. A directory cannot be executed, only traversed.

When you remove the 'x', or the traversability you can no longer see into its meta-data or see what is in it! Hence, d????????? ? ? ? ? ? start as it knows it is a directory and gets its name from the parent's meta-data, but can see nothing else.

Directories should always be traversable for those users who need to see inside them.
Thanks astrogeek! I realize that. I change the files in the folder first. Then once I change the folders' attribute, it happens.
 
Old 09-12-2023, 01:02 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
just one comment: "x" is usually not enough, you need to add "r" too. Without r the directory (or file) is unreadable, therefore you will not [be able to] see the content of it.
additionally we have more flags (like X, s, t), but I think that is another story. see for example here: https://linuxize.com/post/chmod-command-in-linux/
 
Old 09-14-2023, 09:40 PM   #14
Cranegsh
Member
 
Registered: Jan 2023
Posts: 40

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
just one comment: "x" is usually not enough, you need to add "r" too. Without r the directory (or file) is unreadable, therefore you will not [be able to] see the content of it.
additionally we have more flags (like X, s, t), but I think that is another story. see for example here: https://linuxize.com/post/chmod-command-in-linux/
Thanks pan64 for sharing. Good to know.
 
  


Reply



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
change of owner and group owner of a file belongs to diff user ? somorg Linux - Newbie 3 06-14-2015 09:11 AM
change of owner and group owner of a file belongs to diff user ? somorg Linux - Security 2 06-13-2015 02:33 AM
change of owner and group owner of a file belongs to diff user ? somorg Linux - General 2 06-12-2015 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:02 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
Open Source Consulting | Domain Registration