Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Linux Login Shell Tips

Expert Oracle Database Tips by Donald BurlesonMarch 22, 2015

Working with a User's Login Shell

Customizing the User Environment

A tremendous amount of customization is possible within the command line environment.  Some changes will be made to accommodate Oracle; others will make it easier to use the system.

As you customize the shell to suit your needs, it is important to consider all users who will be using a given login.   When accounts like Oracle need to be shared, consider if these customizationswill help or hinder other users who need to use the account.  Another consideration is whether you will become dependent on the customizations and therefore, be seriously handicapped if your customizations are not available for some reason, e.g. on a new system.

Most of these customizations are made on a user-by-user basis in files that are read when a command line session is started.  Since the files that are read may depend on what shell a login is using, this chapter will start with how to change a user's login shell.

The Login Shell

The login shellcontrols much of how you interact with the system.  Several shells are available for use, and at first, they all seem very similar.  They do, in fact, all provide basically the same functionality, but as you become a more advanced shell user, the differences will quickly become apparent.

The default login shell on Linux is the Bourne-Again Shell (bash)which combines many desirable features while maintaining compatibility with the popular Bourne shell (sh).Most users find bash to have a desirable combination of flexibility, features and compatibility, but if you are more comfortable with another shell or if you have software which requires another shell, Linux allows you to easily change your login shell.

A list of the valid shells on a system is maintained in the /etc/shells file.  The file can be viewed with the more command or any text editor.


Some applications, like ftp daemons, will only allow access if a user's login shell is listed in this file.  If new shells are added, it is important to list them in this file.

Regardless of which shell you choose as your login shell, I strongly recommend using the same login shell on all your accounts, if possible.  This will assure that you have the commands and tools you are comfortable with in each of your accounts.

What Shell Am I Using?

When you start a command line session, the variable SHELLis set to the login shell.  This variable can be echoed to check the current login shell.

$ echo $SHELL

This variable is only set when a command line session is started, e.g. at initial login, or when su - is called to invoke a login shell as another user, so it will not be updated if shells are temporarily switched as described in the next section.

To check what shell is currently being run, regardless of whether it was invoked at login or not or if it was switched into after, check another shell variable, 0.

$ echo $0

This variable returns the name of the current running program.  It can be used within shell scripts to print the name of the script, but in a shell session, it will return the name of the shell.

Switching Shells Temporarily

Sometimes you may want to run in a different shell temporarily.  To accomplish that, just give the command for the shell you want to enter.  When you are done, type exit to return to your original shell.

$ ksh
$ echo $0
$ exit
$ echo $0

This is useful if a command or script must be run in a certain shell, but do not permanently change the user's login shell.

Changing a User's Login Shell

The login shell for a user is set when the user is created.  If one is not specified, Linux will use the default bash shell.  The usermod commandallows the root user to change a user's login shell after user creation.

# usermod -s /bin/ksh jemmons

Note: The usermod command does not confirm that the given shell is a valid command or in the /etc/shells file.  Make sure to give a valid shell exactly as it appears in the /etc/shells file.




The usermod command changes the /etc/passwdfile to reflect the new shell.  This shell will now be used at login for the user jemmons.

Linux provides another method of changing the login shell which does not require root privileges.  The chsh commandcan be run by any user to change that user's login shell.

$ chsh

Changing shell for jemmons.
Password: password
New shell [/bin/ksh]: /bin/bash
Shell changed.

The chsh command uses special setuid permissions to update the /etc/passwd file which normally can only be edited by root.  Unlike usermod, chsh verifies that a shell is in the /etc/shells file before changing the user's login shell.  If a user is not sure what shells are available, the chsh command can be called with the -l option to view valid shells.

The Nologin Shell

There is an entry in the /etc/shells file for /sbin/nologin.  This entry is not a shell, but rather, is intended as a place keeper for use with accounts that are disabled.  Setting a user's shell to nologin prevents them from being able to start a command line session on the system but preserves the account for other purposes.  If an account needs to be completely disabled, it should be locked using the usermod command as described in the previous chapter.

A common use of the nologin shell is to assign it to a user who needs only ftp access to a system.  The user's account and password remain valid for FTP and possibly other services, but if they try to connect to the system via SSH, they receive a message that 'This account is currently not available.'??



Get the Complete Details on
Linux System Management for Oracle DBAs  

The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.



Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster