I'm trying to create a new user on a Centos 6 system.
First, I do
useradd kevin
Then, I tried to run commands as that user
su - kevin
However, I get the following error messages
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
[kevin@gazelle ~]$
And I can't do very much as that user.
The permissions on /dev/null
are as follows:
-rwxr-xr-x 1 root root 9 Jul 25 17:07 null
Roughly the same as they are on my Mac,
crw-rw-rw- 1 root wheel 3, 2 Jul 25 14:08 null
It's possible, but really unlikely, that I touched dev.
As the root user, I tried adding kevin
to the root
group:
usermod -a -G root kevin
However I still am getting /dev/null
permission denied errors.
Why can't the new user write to /dev/null
?
What groups should the new user be a part of?
Am I not impersonating the user correctly?
Is there a beginners guide to setting up users/permissions on Linux?
Best Answer
Someone evidently moved a regular file to /dev/null. Rebooting will recreate it, or do
As @Flow has noted in a comment, you must be
root
to do this.1
and3
here are the device major and minor number on Linux-based OSes (the 3rd device handled by themem
driver, see/proc/devices
,cat /sys/devices/virtual/mem/null/dev
,readlink /sys/dev/char/1:3
). It varies with the OS. For instance, it's2
,2
on OpenBSD and AIX, it may also not be always the same on a given OS. Some OSes may supply amakedev
/MAKEDEV
command to help recreate them.