I'm learning Ubuntu and experimenting with things.
I noticed I couldnt create a directory within /sys
Is this a special directory or something? Are there other types of directories?
(I did a sudo -i
and a chmod a+w /sys
)
I'm learning Ubuntu and experimenting with things.
I noticed I couldnt create a directory within /sys
Is this a special directory or something? Are there other types of directories?
(I did a sudo -i
and a chmod a+w /sys
)
First, you should change /sys
's permissions back (sudo chmod a-r /sys
will do it, since the default permissions are dr-xr-xr-x
). /sys
should not be world-writeable!
In general, to create files and directories in parts of the system outside your home folder, external media, and the /tmp
folder, you should do it as root
with sudo
, rather than by changing permissions or ownership to give yourself access. Making directories world-writeable is particularly not recommended.
For information on the recommended way, see:
You can even use gksudo nautilus
(or sudo -H nautilus
if you don't have gksudo
) to open a root-owned file browser window. Be careful with this, though--it can do just about anything, and most of those things are things you probably don't want done. Also, note that if you launch a program from a root-owned file browser window, that program will run as root too.
That's generally what you should do, to edit or create new contents of directories owned by root
. However...
/sys
is different; even root
can't directly create stuff thereLike /proc
and /dev
, in Ubuntu and other OSes using the Linux kernel, /sys
is a virtual filesystem, what it represents is not real files on your disk (or anywhere).
In short, /sys
is a way the kernel provides information about (physical and virtual) devices.
Some entries in the /sys
filesystem are also meaningfully writable and writing to them is a way to dynamically set configuration for devices. (This should not be confused with the /dev
filesystem; writing to entries in /dev
is a way of sending data to devices.)
But this still must be done as root. Rather than changing permission on /sys
or any part of it, you should just perform those action as root with sudo
as explained above.
This answer on Unix.SE explains how to do that, and even how to allow some non-administrators (who cannot perform most actions as root) to change some /sys
settings.
For more information about how /sys
works, see:
Entries in /sys
are created by the kernel and by drivers; you cannot just create them from the command-line. (As stated above, you can edit some as root, but you cannot generally make new ones from userspace except by loading kernel modules or otherwise installing drivers or modifying the kernel.)
If you happen to be interested in writing drivers, see: