LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2009, 08:59 AM   #1
mannclay
Member
 
Registered: Nov 2007
Location: Brooklyn, NY
Distribution: eeeMint
Posts: 52

Rep: Reputation: 15
setting env variables.


When I open a terminal, I get get bash. When I use su and go to root I get sh.

How do I change what shell is used in root?

Thanks...
 
Old 03-27-2009, 09:45 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It is set in /etc/passwd.
--- rod.
 
Old 03-27-2009, 09:54 AM   #3
mannclay
Member
 
Registered: Nov 2007
Location: Brooklyn, NY
Distribution: eeeMint
Posts: 52

Original Poster
Rep: Reputation: 15
I found it! Thanks.
now, how do I change it to bash? I don't think 'nano passwd' will do anything.
Is there any reason why it is set to sh?
 
Old 03-27-2009, 10:00 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
As root, you can edit it to whatever you choose.
--- rod.
 
Old 03-27-2009, 10:04 AM   #5
mannclay
Member
 
Registered: Nov 2007
Location: Brooklyn, NY
Distribution: eeeMint
Posts: 52

Original Poster
Rep: Reputation: 15
thanks.
By the way, how can I permanently keep the -G option for ls??
 
Old 03-27-2009, 10:07 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by mannclay View Post
now, how do I change it to bash? I don't think 'nano passwd' will do anything.
Actually, editing /etc/passwd with nano (while being root of course) and change /bin/sh to /bin/bash would do the trick. You do need to re-login though to feel the effect. Also, take good care editing /etc/passwd. If you make a mistake, you may well lock yourself out, i.e. not be able to log in anymore.

A cleaner way is to run the "chsh" command. It will ask you for the new shell. Press enter and your dropped in your new shell right away. And there no risk of making dangerous mistakes. Also, non-root users can use "chsh" to change their own shell.
 
Old 03-27-2009, 10:28 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You could use an alias (assumes bash shell)
Code:
alias ls='ls -G'
Put this in a bash startup script, such as your local .bashrc and subsequent logins will acquire that alias. Without logging in, such as immediately after editing the file:
Code:
source ~/.bashrc
This will pull in whatever settings are effected in the startup script.
--- rod.
 
Old 03-27-2009, 10:39 AM   #8
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
I think it's far safer to use the chsh program to change your shell, rather than editing /etc/passwd directly. (Just become root and then enter chsh.)

I would go further and say you should never edit that file directly if you can avoid it. (Maybe I'm being overly cautious.)

Apologies - Hko got there first. I should have read more slowly.

Last edited by Telemachos; 03-27-2009 at 10:41 AM.
 
Old 03-27-2009, 10:55 AM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Telemachos View Post
I think it's far safer to use the chsh program to change your shell, rather than editing /etc/passwd directly. (Just become root and then enter chsh.)

I would go further and say you should never edit that file directly if you can avoid it. (Maybe I'm being overly cautious.)
Not necessarily disagreeing, but what makes chsh fundamentally safer? As I see it, either tool is simply editing a system file. I guess you could ague that it is more convenient...
--- rod.
 
Old 03-27-2009, 11:35 AM   #10
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by theNbomr View Post
Not necessarily disagreeing, but what makes chsh fundamentally safer? As I see it, either tool is simply editing a system file. I guess you could ague that it is more convenient...
The fields in /etc/passwd are seperated by colons. Imagine you accidentally delete or overwrite one of those. Or you make a typo in the shell-field (eg. "bash" instead of "/bin/bash).

"chsh" checks if your entry is valid as shell and thus protects you from all typos (eg. /bin/bosh).
 
Old 03-27-2009, 07:51 PM   #11
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
Quote:
Originally Posted by theNbomr View Post
Not necessarily disagreeing, but what makes chsh fundamentally safer? As I see it, either tool is simply editing a system file.
I should have made myself clearer, but as Hko said (again, he's ahead of me), the advantage to chsh is that it doesn't allow the changes to be saved unless they are sane. (The danger of an error is significant. If you mess up badly enough, you lock yourself out of the relevant account.) Another example is to use visudo to work on your /etc/sudoers file, again rather than editing it directly.

Now I'm curious: does anyone know of other similar examples?

Last edited by Telemachos; 03-27-2009 at 07:54 PM.
 
Old 03-27-2009, 08:14 PM   #12
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by Telemachos View Post
Now I'm curious: does anyone know of other similar examples?
I can only think of one at the moment: crontab -e
Though this does not write in /etc but somewhere in /var/spool/...

And of course using the command passwd instead of typing your root password into /etc/passwd with an editor. :-)
 
  


Reply



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
.tcshrc error and setting env. variables leblebi Linux - Newbie 1 04-14-2008 02:02 AM
setting env. variables arunsri Slackware 3 03-26-2005 05:49 AM
Suse ent 9.0 setting Env variables not staying. suncloud Linux - Enterprise 1 03-13-2005 03:13 AM
Setting perm env. variables for a super user. Tarts Slackware 7 08-02-2003 09:21 PM
setting env variables globally raven Linux - General 6 02-21-2003 08:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:44 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
Open Source Consulting | Domain Registration