FactorPad
Build a Better Process

Linux chsh Command Summary with Examples

Linux chsh allows you to change login shell programs.
  1. Purpose - Learn what chsh is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with chsh.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux chsh, 61 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / chsh-command.html


An ad-free and cookie-free website.


Examples of the Linux chsh Command

Beginner

Learn to change shell programs at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux chsh Command Summary with Examples (3:23)

Video Script

The Command and Why You Need It

Our sixty-first word, or command to memorize is chsh from our category System.

chsh allows you to change login shell programs.

Common Linux chsh Options
-options description
-h, --help Display help screen
-s, --shell SHELL_PATH Select the new SHELL_PATH to program for login

Recall from back in video 10 on cat, we viewed a file listing shell programs available on the system? Here, we'll explore that further.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The chsh command has 3 options and the argument is the user you'd like the change to apply to, if you're an administrator, or the path to the login shell program.

Like most commands, help is available with double-dash --help. The -s option followed by the full path to the shell program is what is required. While this is more of an administrator-level program, I wanted to mention it because it illustrates a point. We've been using the bash shell throughout, but others are available.

So why is chsh an important command? Well, the Linux operating system is very flexible and offers each user the ability to choose her own shell program. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. So let's look at that line from video 10, where we used cat to print a file called /etc/shells.

$ cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash /usr/bin/tmux

And here, on my system at least, I have five choices: sh, dash, bash, which we've been using, rbash, and tmux.

$ whatis sh, dash, bash, rbash, tmux sh (1) - command interpreter (shell) dash (1) - command intrepreter (shell) bash (1) - GNU Bourne-Again SHell rbash (1) - restricted bash, see bash (1) tmux (1) - terminal multiplexer

So a discussion of the pros and cons of each one is beyond our scope here and last, since we haven't covered permissions yet, I'm reluctant to dive in any deeper at this time, so consider this an easy session.

$ echo "Yay!" Yay!

Very good.

A Final Tip

Okay now you know how to use chsh. And you know the syntax for commands, options and arguments.

One last tip about the chsh command. So Wikipedia offers a good comparison of shell programs, so there's a link in the Description (YouTube).

Okay, thanks for visiting today. I hope this was a helpful introduction to the chsh command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

This was a short Terminal session, but they get longer and more difficult, especially as we approach shell scripting. Subscribe at YouTube to catch new videos.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / chsh-command.html


linux chsh command
linux chsh
chsh linux
linux chsh examples
chsh command
bash switch
chsh bash
change shell linux
change shell
what shell am i using
which shell
linux change login shell
etc shells
switch shell
chsh tutorial
linux chsh examples
man chsh

A newly-updated free resource. Connect and refer a friend today.