LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Permission denied as root for /etc/passwd (https://www.linuxquestions.org/questions/linux-newbie-8/permission-denied-as-root-for-etc-passwd-940319/)

ltoni 04-17-2012 04:24 PM

Permission denied as root for /etc/passwd
 
1. Signed in as root in RHEL 5 at the prompt [root@localhost ~]# and when I input the command, "/etc/passwd" the output is, bash: /etc/passwd: permission denied.

2. Next I tried to view the permissions of the file with "ls -l /etc/passwd". the output is, "-rw-r--r-- 1 root root 1980 Apr 17 15:16 /etc/passwd

It seems I have read and wite permissions for the file, and groups and users have read only.

What is you advice or suggestions?

Thanks in advance to all for your help.

ADxD_7 04-17-2012 04:26 PM

/etc/passwd is a text file - you cannot execute it, hence the permission denied because it is not a script/program - you need to use a text edit tool like vi or nedit to edit the file

Example:

# vi /etc/passwd

Be careful editing the /etc/passwd file

rodrifra 04-17-2012 04:49 PM

Are you trying to change a password?
In that case you want /usr/bin/passwd not /etc/passwd.

anomie 04-17-2012 05:43 PM

Also, if your intention is to simply view /etc/passwd, then use the less(1) pager.

Code:

$ less /etc/passwd
(Note that you don't need to be root to view it, BTW.)

chrism01 04-17-2012 06:01 PM

In fact, you should really use useradd/usermod/userdel tools rather than edit it directly.
http://linux.die.net/man/8/useradd http://linux.die.net/man/8/usermod http://linux.die.net/man/8/userdel

ltoni 04-18-2012 11:38 AM

Thanks for all your responses I'm still learning about he power and limits of root.
I was only trying to view /etc/passwd, and will use the command "less /etc/passwd".
Thanks again.

kyrunner 04-18-2012 12:30 PM

cat /etc/passwd


All times are GMT -5. The time now is 08:30 AM.