LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 02-28-2011, 10:34 AM   #1
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Rep: Reputation: 2
How to get bash prompt right after logging into a server?


Hi,

Everytime I log into the linux server at my workplace (I use putty), I don't get the bash prompt right away. I need to execute the command 'bash' to get it. Anyway to make this automatic?

e.g.

Code:
host:1>
host:1> bash
user@host:~$
Thanks,
Arun
 
Old 02-28-2011, 10:59 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,078

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
Quote:
Originally Posted by chekhov_neo View Post
Hi,
Everytime I log into the linux server at my workplace (I use putty), I don't get the bash prompt right away. I need to execute the command 'bash' to get it. Anyway to make this automatic?

e.g.
Code:
host:1>
host:1> bash
user@host:~$
Have the administrator change your shell to be bash. You're getting a prompt, but it's for a different shell.
 
Old 02-28-2011, 10:59 AM   #3
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
chsh -s bash
 
Old 02-28-2011, 11:27 AM   #4
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 2
more trouble

Quote:
Originally Posted by AlucardZero View Post
chsh -s bash
Well sir, I'm in a quandary now. I tried changing the shell using chsh -s bash when I was logged in as 'user' and got the following output:

Code:
user@host:~$ chsh -s bash
Password:
bash is an invalid shell.
user@host:~$
I should have stopped with that but I logged in as root and executed the same command. Now when I try to login as root I get the following error:

Code:
host:21> su root
Password:
No shell
host:22>
I don't know why it is saying bash is an invalid shell. The following are the contents of /etc/shells

Code:
user@host:~$ cat /etc/shells
# /etc/shells: valid login shells
/bin/ash
/bin/bash
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/zsh
/bin/sash
/bin/zsh
/usr/bin/esh
/bin/rbash
/bin/dash
/usr/bin/screen
user@host:~$
Then I tried the following in vain:

Code:
user@host:~$ chsh root
You may not change the shell for root.
user@host:~$
I'm unable to login to the server as root. Please help...!
 
Old 02-28-2011, 11:30 AM   #5
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,032

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by chekhov_neo View Post
I don't know why it is saying bash is an invalid shell. The following are the contents of /etc/shells

And that list of shells doesn't include bash. It does include /bin/bash though...
 
Old 02-28-2011, 11:32 AM   #6
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by arizonagroovejet View Post
And that list of shells doesn't include bash. It does include /bin/bash though...
Aren't they both the same thing?
 
Old 02-28-2011, 12:07 PM   #7
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 2
Lightbulb got root access!

Ok, after doing some googling I resolved my current problem(phew!) by doing the following:

Code:
host:32> env | grep SHELL
SHELL=/bin/csh
host:32> su -c 'chsh -s /bin/csh root'
Password:
host:33>
host:33> su root
Password:
host:/bin#
host:/bin#
I'm able to login as root. Now my thought is this, "Don't screw up any more. Let your administrator handle it"
 
Old 02-28-2011, 01:00 PM   #8
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,032

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by chekhov_neo View Post
Aren't they both the same thing?
OK, I'll spell it out: Change your shell to /bin/bash, not bash.
 
Old 02-28-2011, 01:22 PM   #9
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 2
Ok, I tried with "/bin/bash/" and I'm getting this now:

Code:
user@host:~$ chsh -s /bin/bash
Password:
chsh: user not found in /etc/passwd
user@host:~$
Should I add my username in /etc/passwd file?

And one quick question. Why didn't "chsh -s bash" work when the directory "/bin" is present in my PATH environment variable?
 
Old 02-28-2011, 02:43 PM   #10
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 557

Rep: Reputation: 46
/etc/shells is a file that contains shells which are generally found in /bin as shown here:

Command: 1

Code:
-bash-2.05b# ls -l /etc/shells
-rw-r--r--  1 root root 80 Jul 22  2004 /etc/shells
Command: 2

Code:
-bash-2.05b# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh
-bash-2.05b#
This will also do the same thing as above:

Code:
-bash-2.05b# chsh --list-shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh
-bash-2.05b#
Command: 4

Code:
-bash-2.05b# for Shell in `cat /etc/shells`; do ls -l $Shell; done
lrwxrwxrwx  1 root root 4 Jul 27  2004 /bin/sh -> bash
-rwxr-xr-x  1 root root 593304 Mar 11  2004 /bin/bash
-rwxr-xr-x  1 root root 4636 May  4  2004 /sbin/nologin
lrwxrwxrwx  1 root root 4 Jul 27  2004 /bin/bash2 -> bash
-rwxr-xr-x  1 root root 98388 Feb 16  2004 /bin/ash
lrwxrwxrwx  1 root root 3 Jul 27  2004 /bin/bsh -> ash
-rwxr-xr-x  1 root root 319520 Feb 17  2004 /bin/tcsh
lrwxrwxrwx  1 root root 4 Jul 27  2004 /bin/csh -> tcsh
-bash-2.05b#
We need to specify the complete path for the named shell even if the /bin directory is included in the $PATH variable:

Code:
-bash-2.05b# chsh -s sh
Changing shell for root.
chsh: shell must be a full path name.
-bash-2.05b#
But to change your Shell temporarily, you can simply type its name and hit the enter key:

Code:
-bash-2.05b# sh
sh-2.05b#
Without changing your login shell permanently either by executing the chsh -s command or by asking your system admin to make change sin the /etc/passwd file, you can simply put this line of code in your csh (if that is the default shell) or bash (if this is the default shell) profile file. For example, my default login shell is bash. But to get sh every time I login to the server, I can do the following:

Code:
sh-2.05b# cat .bash_profile
PATH=$PATH:$HOME/bin:.
export PATH
echo "Welcome, Dev! Have happy working hours!"
/bin/sh
sh-2.05b#
Even if my default login shell is /bin/bash:

Code:
sh-2.05b# grep ^$USER /etc/passwd
root:x:0:0:root:/root:/bin/bash
sh-2.05b#
I still get the sh shell.

So, you should see which profile file is being called upon when you login. Just add that line (at the bottom, if you would like to) and you can make your life easy!
 
  


Reply

Tags
bash, login, prompt


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Resolved]freesshd- after logging, could not type any letter on prompt windstory General 5 11-16-2009 01:41 AM
How to change .bashrc prompt for logging in via SSH. Amckin Linux - Laptop and Netbook 1 11-04-2009 01:48 PM
Bash Prompt mandraketux Mandriva 2 11-28-2003 11:05 PM
Logging in and getting login prompt again dkaplowitz Red Hat 5 11-21-2003 04:43 PM


All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration