0

I am new to the Ubuntu. I have logged in as guest then switch to namu user and want to make directory but get error as follows:

gest@ubuntu:~$ su namu
Password: 
namu@ubuntu:/home/gest$ cd ..
namu@ubuntu:/home$ cd ..
namu@ubuntu:/$ mkdir file
mkdir: cannot create directory ‘file’: Permission denied
namu@ubuntu:/$
1

Actually namu@ubuntu:/$ mkdir file means you are currently in root directory as namu user. Now to make any changes to this location you need root permission (although you should not make changes in root(/) directory). You could use super user privileges to make a new folder, by sudo mkdir by assigning you root user privilege after prompting for the password.

| improve this answer | |
  • i used this sudo mkdir but getting error as.. namu@ubuntu:/$ sudo mkdir file [sudo] password for namu: namu is not in the sudoers file. This incident will be reported. namu@ubuntu:/$ – user175925 Jul 17 '13 at 8:56
  • @user175925: can u post the output what u get after executing sudo -v – pRAShANT Jul 17 '13 at 11:19
  • :get ouput as Sorry, user namu may not run sudo on ubuntu. – user175925 Jul 18 '13 at 6:55
  • its bcz u are not assigned super user permissions by your system administrator or u not assigned super user privileges. Thats why it prompts u as u cant use sudo command. – pRAShANT Jul 18 '13 at 10:06
0

Are you sure you are working in the correct directory?

Following your command list:

gest@ubuntu:~$ su namu Password: 
namu@ubuntu:/home/gest$ cd .. 
namu@ubuntu:/home$ cd .. 
namu@ubuntu:/$ mkdir file 
mkdir: cannot create directory ‘file’: Permission denied 

you were trying to create a folder within in the root directory. No normal user should ever write anything there (it should be considered a system directory), and therefore the only user that can write on that folder is root. Normal users should only be allowed to write to their respective home folder and the folders for temporary files.

| improve this answer | |
  • tried to create directory at home folder but still getting error... gest@ubuntu:~$ su namu Password: namu@ubuntu:/home/gest$ mkdir aa mkdir: cannot create directory ‘aa’: Permission denied namu@ubuntu:/home/gest$ sudo mkdir aa [sudo] password for namu: namu is not in the sudoers file. This incident will be reported. – user175925 Jul 17 '13 at 10:00
  • User namu can of course only write to the home folder of namu (usually that's /home/namu). By this, it is ensured that users can't easily delete files of other users. On some systems the permissions are even more strict and users cannot read files of other users per default. If you want to return to the home folder of the current user, you can use cd without any argument. – soulsource Jul 17 '13 at 10:44
0

In Order to use mkdir in namu@ubuntu:/$ you need root rights. So type in the following:

sudo mkdir file

after that type in the password and check with ls -la. Your new directory should show up.

Update:

Never create files or directories in a root directory! Except you have too. If you have to create files or directories in a root folder, log in as root.

You can log in as root using this command:

sudo -s and then the passwoord.

or

su -root and then the passwoord.

| improve this answer | |
  • While this command will work assuming namu is an administrator. You are in the root directory are you sure you want to put a file here. Users files normally only go in the users home directory. – Warren Hill Jul 17 '13 at 8:35
  • Yeah I know... and no I never create files and directories in a root directory ;) – Meintjes Jul 17 '13 at 8:39
  • Why do you have to log in as root if you want to create directories in /? On the contrary, you should use sudo for better security. What Warren was trying to say is that one usually shouldn't put files in / in the first place. Also, the command to log in as root is just su, not su -root, and that will actually ask you for the root password, which is not set by default in (newer) Ubuntu distros. – Alaa Ali Jul 17 '13 at 8:51
  • yeah i get that and I also stated in my Answer that he should use sudo mkdir file... well you can argue about security but logging in as root and using sudo is basically the same thing... In both cases a normal User can't change stuff if you created it with sudo or you logged in as root and then created the file or directory. – Meintjes Jul 17 '13 at 8:58

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.