1

I have tried the following and I really don't understand the result. Can someone help?

~$ pwd
/home/djj375
~$ ls -ald .docker
drwx------ 2 root root 4096 May 21 14:33 .docker
~$ realpath .docker
/home/djj375/.docker
~$ cd ../../home/djj375
~$ pwd
/home/djj375
~$ cd .docker
bash: cd: .docker: Permission denied
~$ sudo cd .docker
sudo: cd: command not found
~$
5
  • 5
    The issue is not that it's hidden - it's that it's owned by root and has no permission for others to access (execute / read) May 25, 2018 at 22:46
  • 1
    Look at /bin/ls -ld /home/djj375/.docker
    – waltinator
    May 25, 2018 at 22:48
  • Ii wanted to look at a file inside .docker == /home/djj375/.docker/config.json
    – DJJ375
    May 25, 2018 at 22:51
  • ~$ /bin/ls -ld /home/djj375/.docker drwx------ 2 root root 4096 May 21 14:33 /home/djj375/.docker
    – DJJ375
    May 25, 2018 at 22:53
  • @steeldriver Just answer May 25, 2018 at 23:13

2 Answers 2

1

Change the permissions with

sudo chmod o+rx .docker

to get access to read and execute (i.e. enter) the directory, this way you can cd into it and display files (provided you have the permissions to do that as well):

$ ls -la .docker
total 12
drwx------ 2 root       root       4096 Mai 26 01:15 .
drwxrwxr-x 3 dessert    dessert    4096 Mai 26 01:15 ..
-rw-r--r-- 1 root       root         10 Mai 26 01:15 file
$ sudo chmod o+rx .docker/
$ cd .docker/
$ cat file
something
3
  • Might not be the best practice to modify permission on directory intended for privileged user. But sure, it works. May 25, 2018 at 23:42
  • @SergiyKolodyazhnyy Should there be anything intended solely for a privileged user under ~/ by default? I don’t read anything out of OP’s question but how to enter this directory, so… it works. :)
    – dessert
    May 25, 2018 at 23:47
  • Oh, I agree with that - anything in user's home should be owned by that user. In cases where a file becomes owned by root accidentally, as it sometimes happened with .Xauthority in the past and user couldn't log into the GUI session - sure modifying back is fine. I just think it's alright or even desirable to have something root owned especially if intended for something significant, like docker. But I'm open to learning and acceptable of messing with important files :) May 25, 2018 at 23:56
1

There's nothing special about changing to a hidden folder. You change to a hidden folder using the method you described in your question. The folder in your question isn't hidden... the problem is that you don't have access to change to that folder, because you don't own it, and it's only available to the owner.

Details of what has caused the problem

You're having problems because you have run the sudo elevated command in your personal space (or some GUI application that stores configurations in your personal space). You can avoid this common problem by only running sudo to elevate a comment when you are trying to do something or install something to affect the system-wide behavior... not to as a normal routine while using your computer.

The files in your personal space should be owned by you. The example in your question shows the directory (which happens to be in your personal space) is not owned by you. It's owned by root.

You can check and verify which files and directories have this problem by running this command:

$ find ~/ -mount ! -user $(whoami)

You can take charge of the files in your personal space with this command:

$ sudo chown -R $(whoami):$(whoami) ~/

There is no reason for your personal files to be owned by anyone else but you. If you want to provide files and directories you can use the /opt area to place these files and folders.

You can directly affect the immediate folder you are having problems with by using sudo to change the owner to you, without checking all the other files and folders in your personal.

Direct and immediate resolution

You can use this command to directly fix the immediate problem described:

$ sudo chown $(whoami) ~/.docker
3
  • As suggested by L.D. James, I executed the command: $ sudo chown -R $(whoami):$(whoami) ~/
    – DJJ375
    May 27, 2018 at 16:45
  • @DJJ375 With tyhe provided command, you should now, not have problems making the directory change, because the folder will now be owned by you. May 27, 2018 at 16:50
  • This worked beautifully. I was able to examine the files in the .docker directory. It seems the depth of my ignorance of ownership in Linux is unlimited. I will make a real effort to correct this. My thanks to all who responded and in particular to Mr James for the completeness of his response.
    – DJJ375
    May 27, 2018 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.