• MainMenu
  • Home
  • Cheap VPS
  • Site Tree

Life of a webmaster

Another web-master's blog

  • Home
  • Cheap VPS
  • Site Tree
Loading...
X

Life of a webmaster

How to change the login shell in Linux. chsh instruction

February 20, 2021

What is a login shell for?

In practical terms, the selected login shell determines the default shell for the user. Although, of course, nothing prevents you from running any other shell installed on your system.

How to find out what shells are installed on the system

To change the default shell for a user, you need to know which shells are available and what they are named correctly.

One way to find out the correct shell names and paths to executable files is to run the following command:

chsh -l

But the previous command does not work on all distributions (works on Arch Linux, but does not work on Debian derivatives).

Therefore, you can use the universal method - look at the contents of the /etc/shells file:

cat /etc/shells

The shells file contains the paths to the active login shells.

/etc/shells is a text file that contains the full paths to valid login shells. This file is viewed by chsh and can be requested by other programs.

Keep in mind that there are programs that access this file to find out if the user is a regular user; for example, FTP daemons have traditionally denied access to users with shells not included in this file.

Program for changing default user shell - chsh

chsh - Change the user's login shell permanently.

If you want to temporarily change the shell, then install it and run it. Examples of commands for launching various shells:

sh
bash
pwsh
dash
zsh

chsh is used to change the login shell. If shell is not listed on the command line, chsh prompts for it.

chsh supports non-local entries (kerberos, LDAP, etc.) if linked to libuser, otherwise use ypchsh, lchsh, or any other implementation for non-local entries.

Command syntax:

sudo chsh -s SHELL

As the SHELL, you need to specify one of the shells, as they are listed in the /etc/shells file.

chsh will accept the full path to any executable file on the system.

The default behavior for non-root users is to accept only shells listed in the /etc/shells file and issue a warning to the root user. It can also be configured at compile time to only issue a warning to all users.

Changing shell with usermod

The usermod utility with the -s option changes the shell for the specified user.

For example, to block the root user, use the following command:

sudo usermod -s /usr/sbin/nologin root

To assign a Bash shell to the root user:

sudo usermod -s /usr/bin/bash root

To assign a ZSH shell to the root user:

sudo usermod -s /usr/bin/zsh root

Related articles:

  • How to find out which shell is in use in Linux (84.9%)
  • Linux PowerShell Basics (Beginner's Guide) (65.1%)
  • How to convert a string to uppercase in Bash (64.8%)
  • How to convert a string to lowercase in Bash (64.8%)
  • How to disable “did you mean...” feature in Linux shell (64.8%)
  • Error “error: failed to commit transaction (invalid or corrupted package)” (SOLVED) (RANDOM - 50%)

This entry was posted in Linux and tagged in /etc/shells, Bash, chsh, dash, Linux user information, Linux users / accounts, Login shell, pwsh, sh, shell, system administration, usermod, zsh.

Alex

View more posts from this author
« What program to open .docbook files (DocBook)
How to run “bundle install” as root »

Leave Your Observation Cancel observation

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to increase the size of the partition and file system after increasing the physical size of the disk
  • How to prevent money loss in international roaming. Setting up your phone for international roaming
  • How to update the GRUB bootloader on Debian and derivative distributions (Kali Linux, Ubuntu, Linux Mint)
  • Updating packages: whether to update the config file
  • How to update the GRUB bootloader in Arch Linux and derivatives (Manjaro, BlackArch)

Recent Comments

  • Stash on Error “convert: cache resources exhausted” (SOLVED)
  • WildWanderer on Windows stopped booting in Virtual Machine after upgrading to VirtualBox 7 (SOLVED)
  • Bev Landon on All the ‘tips of the day’ LibreOffice
  • Varaskkar on PostgreSQL error “An old version of the database format was found” (SOLVED)
  • Joe on Error “convert: cache resources exhausted” (SOLVED)

Search

Tags

Android anonymity Apache Arch Linux BlackArch BlackArch / Arch Linux computer network computer performance confidentiality convert data encryption Debian file conversion file systems hardware ImageMagick Information Security Internet access and telephony services IP Kali Linux Linux Linux boot Linux Mint magick Manjaro mobile phones money and banking issues multimedia package managers pacman PHP phpMyAdmin pictures PowerShell software errors / problem solutions Ubuntu video VirtualBox webmaster notes webmaster tools Web Server Wi-Fi Windows Windows 11 WordPress

Categories

  • Blog
  • Linux
  • Money and job
  • Notes
  • Software, hardware and other IT
  • Thailand

Copyright © 2023 Life of a webmaster. All Rights Reserved. Capture by Slocum Studio

Scroll Up