Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have my root user and another user testuser. Now in the .bashrc of testuser, there are some aliases like la for ls -a. But when I login to testuser and try running la, it gives me the error: -sh: la: not found

Even when I try to find $HOME, it says Permission denied (?)

This is slowing down my work!! Help!

share|improve this question
    
sh is not bash. Check the login shell setting of testuser. –  jw013 Aug 2 '12 at 1:13
    
look at the error message, make sure .bashrc file owned by testuser. –  sfgroups Aug 2 '12 at 3:01
    
testuser is owner of .bashrc –  cindy Aug 2 '12 at 3:41
    
by the way, i am using SSH –  cindy Aug 2 '12 at 3:52

2 Answers 2

You can check your system wide /etc/bashrc and/or /etc/profile files. Also you can add something like this to the files:

if [ `whoami` == "testuser" ] 
then  
   alias x='echo x' # alias list..
fi
share|improve this answer

The message from the shell begins with -sh. This gives two important clues:

  • The leading - indicates that this is a login shell. By convention, the login program (the program where you type your user name and password, which can be login, gdm, sshd, …) starts a shell with the program name set to begin with an extra -. This way, the shell knows that it's a login shell and reads ~/.profile or other session startup file.
  • The shell's name is sh. So the user's login shell is set to /bin/sh, and not to bash. Either /bin/sh is a symbolic link to bash, or it's some other shell such as dash. When bash is invoked under the name sh, it doesn't read its configuration files, only the standard files (~/.profile and /etc/profile in login shells, nothing in non-login shells), for compatibility. So either way ~/.bashrc is not read.

If you explicitly invoke bash, it will read .bashrc. You'll need to pass the -t flag to ssh to tell it to open a terminal even though you've specified a command.

ssh -t testuser@nameofhost bash

You may want to switch the user's login shell to be bash instead of /bin/sh. As testuser, run the command

chsh -s /bin/bash

Change the path to /usr/local/bin/bash or wherever bash is located. If you invoke chsh without arguments, you'll get a menu showing what shells you're allowed to select.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.