As root user I created a new user in my Ubuntu.
adduser isliThan i granted to newly created user sudo permissions
usermod -aG sudo isliThan switched to newly created user
su isliin my isli user directory have projects directory which i want to open
sudo ls -al Give the following output
drwx------ 6 root root 4096 Feb 7 15:15 .
drwxr-xr-x 23 root root 4096 Jan 29 06:10 ..
drwxr-xr-x 4 root root 4096 Jan 18 09:43 projectsBut while i am trying cd projects the output is permissions denied
What i am doing wrong
1 Answer
Your user isli does not have any permissions for the directory you are in (.), which is the parent directory of your projects directory. This is because the directory . is owned by root and others do not have any permissions to it (the last --- in the mode indicator).
A solution is to give everyone read (r) and access (x) permissions for the directory:
sudo chmod o+rx .Another option which you might prefer is to set the directory to be owned by the user isli:
sudo chown isli .or if you want to also give isli the ownership of everything under that directory (such as the projects directory):
sudo chown -R isli .(The -R switch stand for recursive.) Then isli will also be able to edit files in these directories, which you may be what you want.
Another suggestion
In fact, you might not want to do that, after all: you may be in root's home directory, and you probably want to keep that owned by root. The command su root did not change the current working directory, so if you started in root's home directory, which is normally /root, you would still be there. You probably want to keep that owned by root. You can display the current working directory using the command:
pwdThe solution you are looking for may be to move the projects directory into isli's home directory, which is normally /home/isli, but if you are not sure about that, you can, in most interactively used shells, refer to it by ~isli.
To set isli as the owner of the projects directory, to move it to isli's home directory, and finally to change to that directory, do:
sudo chown isli projects
sudo mv projects ~isli/
cd ~isli/projects