Solved

Users get no bash commands and errors at login

Posted on 2002-04-05
18
258 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Guacamole and browser performance 1 64
Virtual Box issue 6 85
Remove a folder in Linux 9 91
Can't ping New Linux Servers 40 25
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

895 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

13 Experts available now in Live!

Get 1:1 Help Now