What
is Shell & Ways to Change a User’s Default Shell in Linux?
In this article, we
will describe how to change a user’s shell in Linux. The shell is a program
that accepts and interprets commands; there are several shells such as bash,
sh, ksh, zsh, fish and many other lesser known shells available on Linux.
Bash (/bin/bash) is a popular shell on most if not all Linux
systems, and it’s normally the default shell for user accounts.
The
bash shell
A command line is a text-based interface which can be used to
input instructions to a computer system. The Linux command line is provided by a program called
the shell. Over the long history of UNIX - like systems, many shells have been
developed. The default shell for users in Linux is the GNU Bourn e-Again Shell
(bash). Bash is an improved version of one of the most successful shells used
on UNIX-like systems, the Bourne Shell (sh).
There are several
reasons for changing a user’s shell in Linux including the following:
§
To block or
disable normal user logins in Linux using a nologin shell.
§
Use a shell wrapper
script or program to login user commands before they are sent to a shell for
execution. Here, you specify the shell wrapper as a user’s login shell.
§
To meet a user’s
demands (wants to use a specific shell), especially those with administrative
rights.
When creating user accounts with the useradd or
adduser utilities, the --shell flag can be used to specify the name of a user’s login
shell other than that specified in the respective configuration files.
A login shell can be accessed from a text based interface or via
a SSH from remote Linux machine. However, if you login via a graphical user
interface (GUI), you can access the shell from a terminal emulators like xterm, konsole and many more.
Let’s first list all
available shells on your Linux system, type.
# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/dash
Before you proceed any
further, note that:
§
A user can change
their own shell to any thing: which, however must be listed in the /etc/shells file.
§
Only root can run a
shell not listed in /etc/shells file.
§
If an account has a
restricted login shell, then only root can change that user’s shell.
Now let’s discuss
three different ways to change Linux user shell.
How to check current
Shell in Linux
# echo $$SHELL
chsh command
chsh is a command line utility for changing a
login shell with the -s or –shell option like
this.
# chsh --shell /bin/sh tecmint
#exec bash {without restart
execute shell in user mode}
No comments:
Post a Comment