FactorPad
Faster Learning Tutorials

Linux chsh command summary with examples

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.
Paul Alan Davis, CFA, November 1, 2016
Updated: August 4, 2018
In this tutorial, 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 Next

~/ home  / tech  / linux essentials  / chsh command


The Linux chsh command

Beginner

Learn to change shell programs at the Linux command line.

Video Tutorial

Linux chsh command summary with examples (3:23)

Videos can also be accessed from the YouTube Playlist.

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.

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. Click here to subscribe to our YouTube Channel.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the bg command, hit Back.
  • Do you know how to quickly look up the Linux kernel version, operating system, hardware and processor type? To see how easy it is with the uname command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / chsh command



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