ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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).
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.