Solved

Users get no bash commands and errors at login

Posted on 2002-04-05
18
254 Views
Last Modified: 2013-12-16
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?
0
Comment
Question by:victorus
  • 7
  • 6
  • 5
18 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6922186
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6922620
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
 
LVL 4

Author Comment

by:victorus
ID: 6925465
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6925893
and if you try same as user username?

BTW, these files just need read permissions
0
 
LVL 4

Author Comment

by:victorus
ID: 6928469
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6928556
shure, we know.
but then, can you do
     . /tc/profile
     . .profile
     . .bashrc
     . .bash_profile
0
 
LVL 4

Author Comment

by:victorus
ID: 6928581
Right! That's what I get for each of the /etc/profile commands, .profile, .bashrc, and .bash_profile.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6928640
??
What did you get? The errors of your qestion?
Then someone edeted these files, making typos or errors.
You need to fix it.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6928703
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Author Comment

by:victorus
ID: 6929005
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
 
LVL 40

Expert Comment

by:jlevie
ID: 6929152
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6929369
> /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
 
LVL 4

Author Comment

by:victorus
ID: 6929439
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
 
LVL 40

Accepted Solution

by:
jlevie earned 150 total points
ID: 6929542
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
 
LVL 4

Author Comment

by:victorus
ID: 6929584
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
 
LVL 4

Author Comment

by:victorus
ID: 6929592
ANOTHER great answer. You saved me a lot of trouble.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6929859
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6930524
gain, as in mentioned in another question, get chkrootkit from http://www.chkrootkit.org/ and see if it prooves jlevie's last assumtion.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now