Solved

Users get no bash commands and errors at login

Posted on 2002-04-05
18
259 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
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 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
 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

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…
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

809 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