LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   ssh login with normal user, receive: /dev/null: Permission denied (https://www.linuxquestions.org/questions/red-hat-31/ssh-login-with-normal-user-receive-dev-null-permission-denied-382398/)

mark78301 11-12-2005 07:24 AM

ssh login with normal user, receive: /dev/null: Permission denied
 
Hello All,

I have a dedicated server which was formerly running FreeBSD, but was recently replaced with RedHat 9 (Shrike) after a catastrophic hard drive failure. My ISP that hosts the box is pretty crappy, and would love to charge me about $100/hr to fix this problem, but it should be an easy fix with some guidance.

Anyway, this is a fresh install and I have been the only one on the box so far. The problem is when I SSH in with a normal user account, this is what I am presented with:

mark@'s password:
-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
[mark@]$

Also, after I view a file with 'less' I see:

[mark@]$ less test
/usr/bin/lesspipe.sh: line 50: /dev/null: Permission denied
[mark@]$

When I log in with root, I don't get any of the /dev/null errors. Here is /dev/null:

crw-r--r-- 1 root root 1, 3 Nov 11 18:46 /dev/null

I just can't figure this one out. If anyone could offer a suggestion, it would be greatly appreciated.

Thank you in advance,

Mark

julz_51 11-12-2005 08:19 AM

Set permissions 666 on /dev/null. Non-root users lack writing permissions.

MensaWater 11-12-2005 08:32 AM

The basic answer is you don't have permissions to write to /dev/null :D

Not trying to be facetious - just that the message is telling you the problem.

As root simply type "chmod 666 /dev/null". A subsequent "ls -l /dev/null" should show it now has "crw-rw-rw-" in the left most column. (For more details on the chmod command type "man chmod".)

DETAILED RESPONSE FOLLOWS:

Quote:

crw-r--r-- 1 root root 1, 3 Nov 11 18:46 /dev/null
The left column of this entry is telling you it is a c(haracter) device that has r(ead) and w(rite) for the owner but only r(ead) for group and r(ead) for all other users. the "root root" later in line tells you the owner is called root and the group is also called root. (Despite same name owner and group are two different things - owners in /etc/passwd and groups in /etc/group.) Anyway since owner is root and its writable ONLY by owner it means only root can write to it. Since /dev/null is a bit bucket there's no reason to restrict it that way. It should be writable by all.

Of course what's got me wondering is why the hell its trying to access /dev/null in the first place. Maybe it always has and I just didn't realize it. Typically /dev/null is where you redirect unwanted output so it doesn't appear on your screen or in a log file. For example typing:
'ls -l >/dev/null" would send output to /dev/null so you'd never see it on the screen. Its common in background scripts such as init scripts or cron to redirect unwanted output as follows:
myscript.sh >/dev/null 2>&1

The above says to send standard output (stdout a/k/a file descriptor 1) to /dev/null instead of the default (normally the terminal) then says to redirect standard error (stderr a/k/a file descriptor 2) to file descriptor 1 which has been redefined as /dev/null earlier on the line.

P.S. RedHat 9 is rather old. Unless you have a specific need for it you might want to install the latest RedHat non-commercial Linux which is Fedora Core 4 (or at least Fedora Core 3 - the 2.6 kernel in 4 is still giving folks some issues but Fedora Core 3 is a lot later.) RedHat has split their commercial and non-commercial so that RedHat branded stuff (RedHat EL/AS) is commercial and Fedora is non-commercial

mark78301 11-12-2005 09:20 AM

Problem Solved -- Thanks!
 
julz_51 and jlightner,

Thank you very much for your replies. Changed the permissions like suggested and it's fixed.

-Mark


All times are GMT -5. The time now is 12:01 PM.