[SOLVED] chmod 600 breaks directory

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mirabilit

[SOLVED] chmod 600 breaks directory

Post by mirabilit »

Hello,

I am seeing a strange behaviour when using chmod 600 on a .directory which actually breaks my ssh usage.

Here's what I do:

Code: Select all

mirabilit@minty ~/test $ mkdir .testdir
mirabilit@minty ~/test $ ll
insgesamt 12
drwxrwxr-x  3 mirabilit mirabilit 4096 Aug  2 18:41 ./
drwxr-xr-x 45 mirabilit mirabilit 4096 Aug  2 17:54 ../
drwxrwxr-x  2 mirabilit mirabilit 4096 Aug  2 18:41 .testdir/
mirabilit@minty ~/test $ ll .testdir/
insgesamt 8
drwxrwxr-x 2 mirabilit mirabilit 4096 Aug  2 18:41 ./
drwxrwxr-x 3 mirabilit mirabilit 4096 Aug  2 18:41 ../
mirabilit@minty ~/test $ touch .testdir/testfile
mirabilit@minty ~/test $ ll .testdir/
insgesamt 8
drwxrwxr-x 2 mirabilit mirabilit 4096 Aug  2 18:41 ./
drwxrwxr-x 3 mirabilit mirabilit 4096 Aug  2 18:41 ../
-rw-rw-r-- 1 mirabilit mirabilit    0 Aug  2 18:41 testfile
mirabilit@minty ~/test $ chmod 600 .
./        ../       .testdir/ 
mirabilit@minty ~/test $ chmod 600 .testdir/testfile 
mirabilit@minty ~/test $ ll .testdir/
insgesamt 8
drwxrwxr-x 2 mirabilit mirabilit 4096 Aug  2 18:41 ./
drwxrwxr-x 3 mirabilit mirabilit 4096 Aug  2 18:41 ../
-rw------- 1 mirabilit mirabilit    0 Aug  2 18:41 testfile
mirabilit@minty ~/test $ chmod 600 .testdir/
mirabilit@minty ~/test $ ll .testdir/
ls: Zugriff auf '.testdir/testfile' nicht möglich: Keine Berechtigung
ls: Zugriff auf '.testdir/..' nicht möglich: Keine Berechtigung
ls: Zugriff auf '.testdir/.' nicht möglich: Keine Berechtigung
insgesamt 0
d????????? ? ? ? ?            ? ./
d????????? ? ? ? ?            ? ../
-????????? ? ? ? ?            ? testfile
mirabilit@minty ~/test $ whoami
mirabilit
insgesamt 8
drw------- 2 mirabilit mirabilit 4096 Aug  2 18:41 .
drwxrwxr-x 3 mirabilit mirabilit 4096 Aug  2 18:41 ..
-rw------- 1 mirabilit mirabilit    0 Aug  2 18:41 testfile
Maybe I am doing something wrong or have wrong expectations but why does chmod 600 do this to .testdir? It also does this to my .ssh dir that hold my ssh keys.
I am running Linux Mint 19 in a VM and I think it only appears to be like that after the upgrade from Mint 18.
Any idea what's happening here? Why does it look ok with a sudo?

Thanks in advance,
Mirabilit
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: chmod 600 breaks directory

Post by gm10 »

chmod 600 gives read + write permissions to the owner and no permissions to anybody else. In other words, you stripped your own permission to traverse the directory, thus you cannot access the contents anymore. chmod 700 would restore those permissions to you.

A sudo prefix runs a command with root privileges. Root owns the system and has all the permissions.

PS: This is nothing new, has been like this since the beginning of recorded time. :mrgreen:
User avatar
Flemur
Level 20
Level 20
Posts: 10097
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: chmod 600 breaks directory

Post by Flemur »

mirabilit wrote: Thu Aug 02, 2018 12:51 pmMaybe I am doing something wrong or have wrong expectations but why does chmod 600 do this to .testdir? It also does this to my .ssh dir that hold my ssh keys.
A directory needs to be "executable":

Code: Select all

$ mkdir a
$ cd a     
$ cd ..
$ chmod -x a
$ cd a
bash: cd: a: Permission denied
It would make more sense if it just needed to be readable...
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
mirabilit

Re: chmod 600 breaks directory

Post by mirabilit »

ok, thanks. I didn't know that a directory needs to be executable. Learned something new today, thanks :-)

I looked at my snapshot before the upgrade and the permissions of .ssh were different but at least ssh keys were still working. So, whatever I was doing after the upgrade messed up my permissions of the .ssh folder. Maybe a blank where it shouldn't be or so. Something like chmod 600 .ssh/ id_rsa

Thanks for the quick reply, everything's working again.

Best regards,
Mirabilit
Locked

Return to “Other topics”