Forrest logo
tool overview
On this page you find all important commands for the CLI tool chsh. If the command you are looking for is missing please ask our AI.

chsh

The chsh command line tool, or "change shell," is used in Unix-like operating systems to change the default login shell for a user. It allows users to specify their preferred shell by modifying the user entry in the system's user database.

Here are some key points about the chsh command:

  1. Syntax: The general syntax of the chsh command is as follows:

    chsh [options] [username]
  2. User permission: Only the user or the root user can change the shell using chsh. Regular user accounts can use chsh to modify their shell, while the root user can change the shell for any user.

  3. Shell selection: The chsh command prompts the user to enter the path of the desired shell. It validates the input, ensuring that the specified shell exists in the system's shell directory (usually /bin, /usr/bin, or /usr/local/bin).

  4. Available shells: The available shells can vary depending on the operating system, but common examples include bash (Bourne Again SHell), sh (Bourne SHell), csh (C SHell), tcsh (Enhanced C SHell), zsh (Z SHell), and more.

  5. User database modification: The chsh command updates the user's entry in the system's user database (e.g., /etc/passwd or a directory service like LDAP). By modifying the shell field for the specific user, it sets the chosen shell as the user's default login shell.

  6. Security considerations: Changing the login shell can impact system security, as different shells have varying levels of security features and vulnerabilities. It is important to consider the implications and potential risks before changing a user's default shell.

Overall, the chsh command is a versatile tool that enables users to modify their default login shell, providing flexibility and customization options in Unix-like systems.

List of commands for chsh:

  • chsh:tldr:74ed3 chsh: Set a specific login shell for the current user interactively.
    $ chsh
    try on your machine
    explain this command
  • chsh:tldr:c9b8c chsh: Set a specific login [s]hell for the current user.
    $ chsh -s ${path-to-shell}
    try on your machine
    explain this command
  • chsh:tldr:d16e2 chsh: [l]ist available shells.
    $ chsh -l
    try on your machine
    explain this command
  • chsh:tldr:dbb9f chsh: Set a login [s]hell for a specific user.
    $ chsh -s ${path-to-shell} ${username}
    try on your machine
    explain this command
  • nologin:tldr:73db6 nologin: Set a user's login shell to `nologin` to prevent the user from logging in.
    $ chsh -s ${user} nologin
    try on your machine
    explain this command
tool overview