Users get no bash commands and errors at login

RedHat 7.0
When logging in all users except root get:

sh: id: command not found
sh: id: command not found
sh: id: command not found
[: too many arguments
sh: dircolors: command not found
sh-2.04$

command "ls" gives a "Permission Denied" error

Easy or hard problem? Should I just rebuild system?
LVL 4
victorusAsked:
Who is Participating?
 
jlevieConnect With a Mentor Commented:
It sounds like ordinary users don't have access to things in /usr/bin (where id and dircolors are).

What do you see if you do:

/bin/ls -ld /usr /usr/bin

The correct permissions on those dirs should be 755, owned by root and group root.
0
 
jlevieCommented:
That sounds like a problem with shell init files. Root's shell init files would have been copied to /root when the system was installed and are likely okay. I'm guessing that the contents of /etc/skel got changed after the installation and any users added after that have bad init files.

One simple fix for that would be to copy the .bash* files from /root to one of the user accounts and then try logging in as that user.
0
 
ahoffmannCommented:
check as root (using bash) if following complains:

. /etc/profile
. ~username/.profile
. ~username/.bashrc
. ~username/.bash_profile
# where username is on of the account names which has problems

I assume that one of these files contains syntax errors.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
victorusAuthor Commented:
jlevie, I had already tried this but did it again just now. No change!

ahoffmann - ./etc/profile was not 744 permissions (strange). I changed the permissions to 744 and
/etc/profile username/.profile
/etc/profile username/.bashrc
/etc/profile username/.bash_profile

did not complain at all.

Any other ideas?
0
 
ahoffmannCommented:
and if you try same as user username?

BTW, these files just need read permissions
0
 
victorusAuthor Commented:
If I log in as user "tester1" I get:

/etc/profile: id: command not found
/etc/profile: id: command not found
/etc/profile: id: command not found
/etc/profile [: too many arguments
/etc/profile: dircolors: command not found
/etc/profile: id: command not found
0
 
ahoffmannCommented:
shure, we know.
but then, can you do
     . /tc/profile
     . .profile
     . .bashrc
     . .bash_profile
0
 
victorusAuthor Commented:
Right! That's what I get for each of the /etc/profile commands, .profile, .bashrc, and .bash_profile.
0
 
ahoffmannCommented:
??
What did you get? The errors of your qestion?
Then someone edeted these files, making typos or errors.
You need to fix it.
0
 
jlevieCommented:
What is the result of doing:

/usr/bin/id root
/usr/bin/id some-user

and what does '/bin/ls -l /usr/bin/id' return?
0
 
victorusAuthor Commented:
to: ahoffmann
When I issue the command:
/etc/profile /tester1/.profile

I get:
/etc/profile: id: command not found
/etc/profile: id: command not found
/etc/profile: id: command not found
/etc/profile [: too many arguments
/etc/profile: dircolors: command not found
/etc/profile: id: command not found

same result for:
/etc/profile /tester1/.bashrc
/etc/profile /tester1/.bash_profile

------------
To: jlevie
/usr/bin/id root
gives me:
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

/usr/bin/id some-user
gives me:
uid=547(tester1) gid=547(tester1) groups=547(tester1)

/bin/ls -l /usr/bin/id
gives me:
-rwxr-xr-x    1 root     root         9252 Jul 12  2000 /usr/bin/id

Doesn't look good, huh?
0
 
jlevieCommented:
Okay, that says that id is sane and produces the correct results, so it pretty much looks to be a shell or shell init problem. Let's see if we can figure out which and what...

What shell is tester1 using? You can tell by looking at the last field of /etc/passwd. For example:

postgres:x:900:900::/opt/Postgres:/bin/bash

shows that the postgres user has /bin/bash as their shell. I can also tell that the home dir is /opt/Postgres and it would be nice to know what the user's directory permissions are, per the above example:

> ls -ld /opt/Postgres
0
 
ahoffmannCommented:
> /etc/profile: id: command not found
and
> /usr/bin/id root
> gives me:
> uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

sounds like you have not set PATH environment variable properly in the shell resource file (like /etc/profile)

As jlevie said, please post more details, like:

   echo $SHELL; /bin/awk -F: '/^tester1/{print $NF}' /etc/passwd
   /bin/ls -ld `awk -F: '/^ah/{print $(NF-1)}' /etc/passwd`/.*
0
 
victorusAuthor Commented:
From /etc/passwd:
tester1:x:547:547::/home/tester1:/bin/bash

from ls -ld /home/tester1:
drwx------    4 tester1  tester1      4096 Apr  8 11:43 /home/tester1

from ls -ld /bin/bash:
-rwxr-xr-x    1 root     root       512540 Aug 22  2000 /bin/bash

Thanks for hanging in there guys!
0
 
victorusAuthor Commented:
BINGO!
Who did that?
It was just that the dirs permissions had been set to 750!

I smell a hack!
Thanks a million. Changing the permissions got everything working fine.
0
 
victorusAuthor Commented:
ANOTHER great answer. You saved me a lot of trouble.
0
 
jlevieCommented:
Hmm, it could have been accidental (how many people have root privs?) or it could have been the result of a botched root kit. It would be good to run 'rpm -Va' and see any other important things (like ps, login, etc) differ from what was installed.
0
 
ahoffmannCommented:
gain, as in mentioned in another question, get chkrootkit from http://www.chkrootkit.org/ and see if it prooves jlevie's last assumtion.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.