Make directory command not working
15,629
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.
Related videos on Youtube
Author by
user175925
Updated on September 18, 2022Comments
-
user175925 over 1 year
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:/$
-
Warren Hill almost 11 yearsWhile 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.
-
Meintjes almost 11 yearsYeah I know... and no I never create files and directories in a root directory ;)
-
Alaa Ali almost 11 yearsWhy do you have to log in as root if you want to create directories in
/
? On the contrary, you should usesudo
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 justsu
, notsu -root
, and that will actually ask you for the root password, which is not set by default in (newer) Ubuntu distros. -
user175925 almost 11 yearsi 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:/$
-
Meintjes almost 11 yearsyeah 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. -
user175925 almost 11 yearstried 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.
-
soulsource almost 11 yearsUser 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. -
pRAShANT almost 11 years@user175925: can u post the output what u get after executing
sudo -v
-
user175925 almost 11 years:get ouput as Sorry, user namu may not run sudo on ubuntu.
-
pRAShANT almost 11 yearsits 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.