InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
Bash
Setting bash As Your Default Shell in bash
Bash

Setting bash As Your Default Shell in bash

InfinityCoder January 11, 2017

You’re using a BSD system, Solaris, or some other Unix variant for which bash isn’t the default shell.

You’re tired of starting bash explicitly all the time, and want to make bash your default shell.

First, make sure bash is installed. Try typing bash –version at a command line. If you get a version, it’s installed:

1
2
3
$ bash --version
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.

If you don’t see a version number, you may be missing a directory from your path. chsh -l or cat /etc/shells may give you a list of valid shells on some systems.

Otherwise,  ask your system administrator where bash is, or if it can be installed. chsh -l provides a list of valid shells on Linux, but opens an editor and allows you to change settings on BSD.

-l is not a valid option to chsh on Mac OS X, but just running chsh will open an editor to allow you to change settings, and chpass -s shell will change your shell.
If bash is installed, use the chsh -s command to change your default shell. For example, chsh -s /bin/bash.

If for any reason that fails try chsh, passwd -e, passwd -l chpass, or usermod -s /usr/bin/bash.

If you still can’t change your shell ask your system administrator, who may need to edit the /etc/passwd file.

On most systems, /etc/ passwd will have lines of the form:

1
2
cam:pK1Z9BCJbzCrBNrkjRUdUiTtFOh/:501:100:Cameron Newham:/home/cam:/bin/bash
cc:kfDKDjfkeDJKJySFgJFWErrElpe/:502:100:Cheshire Cat:/home/cc:/bin/bash

As root, you can just edit the last field of the lines in the password file to the full pathname of whatever shell you choose.

If your system has a vipw command, you should use it to ensure password file consistency.

Some operating systems, notably the BSD Unixes, typically place bash in the /usr partition.
You may want to think twice about changing root’s shell on such systems.

If the system runs into trouble while booting, and you have to work on it before /usr is mounted, you’ve got a real problem: there isn’t a shell for root to use.

Therefore, it’s best to leave the default shell for root unchanged. However, there’s no reason not to make bash the default shell for regular user accounts.

And it goes without saying that it’s bad practice to use the root account unless it’s absolutely necessary. Use your
regular (user) account whenever possible.

With commands like sudo, you should very rarely need a root shell.
If all else fails, you can probably replace your existing login shell with bash using exec, but this is not for the faint of heart.

How can I make bash my login shell?” in the bash FAQ at ftp://ftp.cwru.edu/pub/bash/FAQ.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Keeping a Private Stash of Utilities by Adding ~/bin in bash
You have a stash of personal utilities you like to …

Keeping a Private Stash of Utilities by Adding ~/bin in bash

Using chroot Jails in bash
You have to use a script or application that you …

Using chroot Jails in bash

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap