cannot create directory. permission denied. but i have permission

7,962

Solution 1

The /sys directory in Linux is deceptive. Unlike most other directories, it does not provide persistent storage for arbitrary files.

Rather, it's a way to look at the systems's devices - their states and configurations. These files go away between boots and are dynamically generated by your system at startup. It is normal to be denied permission to write new files or directories there, even as root. You can detect these filesystems by viewing the mount type:

$ mount
none on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600)
none on /proc type proc (rw,nosuid,nodev,noexec,relatime)
none on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
none on /sys/fs/fuse/connections type fusectl (rw,relatime)
none on /run type tmpfs (rw,nosuid,noexec,relatime,size=3284248k,mode=755)
/dev/md2 on /home type ext4 (rw,relatime,user_xattr,acl,barrier=1,data=ordered,discard)
  • devpts, proc, sysfs, binfmt_misc, and fusectl are all dynamically generated filesystems that reflect internal system information, and aren't for normal filesystem use. You will likely get permission denied errors even as root or other issues if you try to use these as a normal filesystem.
  • tmpfs is a temporary filesystem which resides within RAM - You can write to here and use it like a normal filesystem, but anything saved here will be erased as soon as the computer shuts down. Copy your files elsewhere if you want to save them.
  • ext4 is an actual filesystem on a device somewhere. Data saved here will be preserved like you would expect on a harddisk. There are many filesystems, but the key note is how this line has /dev/md2 instead of none: none means that there is no device backing the filesystem - it doesn't really exist, and is entirely virtual. If a mount point has an actual device (like /dev/sda1 or /dev/md1), then that means the contents actually exist on a device somewhere.

Would you be able to put your edited files in another directory? Or do you specifically mean to edit the configuration of a device?

Solution 2

I suspect this is happening because the filesystem you are attempting to write to is a read-only file system.

Run the command df to check this. If you run mkdir from your home directory as a check - this should work.

Share:
7,962

Related videos on Youtube

user2491795
Author by

user2491795

Updated on September 18, 2022

Comments

  • user2491795
    user2491795 over 1 year

    i'm fairly new to linux, and ran ubuntu the other day. it is running dual boot with windwos 8. now, the problem is, even though i log in as root and give a specific folder ALL PERMISSIONS (#chmod 777 filename), it still doesn't let me create a directory or save an edited file, saying (cannot create directory: no such file or directory). it gave me the same error even as i logged in as root GUI. since then, i have tried centOS 6.4, and it gives me the same problem. i mention again that i gave the directory full permission. i ran linux before on other computers and never came across this problem. my computer now is DELL XPS L502X.

    • Dmitry Kazakov
      Dmitry Kazakov almost 11 years
      what is the folder path ?
    • Jason
      Jason almost 11 years
      this is not a programming question.
    • Admin
      Admin almost 11 years
      folder path: /sys/module/snd
    • Ex Umbris
      Ex Umbris almost 11 years
      Do you have selinux enabled?
    • Admin
      Admin almost 11 years
      ah i'm sory i'm fairly new to linux, but i'll look up selinux right now
    • Admin
      Admin almost 11 years
      selinux was enable, so i disabled it and retried. i am still facing the same problem. i am running a 64bit version, if that has any significance.
    • Austin T French
      Austin T French almost 11 years
      Did you sudo your make directory command?
    • user2491795
      user2491795 almost 11 years
      @AthomSfere ah my friend...you see, i cannot use sudo since i am not in the sudoers list! i cannot even edit sudoers list because of this issue. even root is not recognized as root... in case of files they say "read only" and incase of folders they say "no such directory"..
    • user2491795
      user2491795 almost 11 years
      this has never happened before, and i don't know why i would need to work so hard to create a simple directory. i have installed various distros all having the same problem... is it because the filesystem is ext4 instead of ext3?
  • user2491795
    user2491795 almost 11 years
    hey suspectus, i think it might also be read-only, but i just tried the command: [#mount -o remount,rw /] but it's still giving me the error EVEN AFTER REBOOT. i thought root could do everything, but even root cannot create a simple directory or edit anything... i can change permissions, but they don't change anything. i changed the distro to openSUSE 12.3 KDE last night, and the problem isn't even close to being solved...
  • user2491795
    user2491795 over 10 years
    thanks. someone told me already that i would not be able to write files inside /sys directory... have to get used to the linux filesystem.. in windows you could do anything anywhere