cd into directory without having permission

260,312

Solution 1

Enter super user mode, and cd into the directory that you are not permissioned to go into. Sudo requires administrator password.

sudo su
cd directory

Solution 2

@user812954's answer was quite helpful, except I had to do this this in two steps:

sudo su
cd directory

Then, to exit out of "super user" mode, just type exit.

Solution 3

If it is a directory you own, grant yourself access to it:

chmod u+rx,go-w openfire

That grants you permission to use the directory and the files in it (x) and to list the files that are in it (r); it also denies group and others write permission on the directory, which is usually correct (though sometimes you may want to allow group to create files in your directory - but consider using the sticky bit on the directory if you do).

If it is someone else's directory, you'll probably need some help from the owner to change the permissions so that you can access it (or you'll need help from root to change the permissions for you).

Solution 4

chmod +x openfire worked for me. It adds execution permission to the openfire folder.

Solution 5

Alternatively, you can do:

sudo -s
cd directory
Share:
260,312

Related videos on Youtube

user812954
Author by

user812954

Usually post questions when exploring new technologies.

Updated on July 12, 2022

Comments

  • user812954
    user812954 almost 2 years

    When cding into one of my directories called openfire the following error is returned:

    bash: cd: openfire: Permission denied
    

    Is there any way around this?

  • wcyn
    wcyn about 7 years
    @Winnemucca I'm not sure. I haven't worked with docker before. But I assume it can
  • GrayedFox
    GrayedFox over 5 years
    Been googling for an hour now trying to fix the fact that I could not SSH without using "sudo" (which I knew had to be wrong) - and this fixed it. Finally!
  • Gaurav
    Gaurav almost 5 years
    flawless answer!
  • Masih
    Masih over 3 years
    This does the job without any complications!
  • alper
    alper over 2 years
    Would it be possible to give read-only permission to it? When I do chmod 0444 <folder_name> I start to have same error message
  • Jonathan Leffler
    Jonathan Leffler over 2 years
    If the directory permissions are 444, then you can read the directory to find which files are named in it, but you cannot access those files, regardless of the permissions on the files.