linux change linux login shell

折月煮酒 提交于 2020-05-03 21:13:04

A. You don’t have to edit /etc/passwd file to change your shell. You need to use chsh command. It changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for his/her own account, the super user i.e. root user may change the login shell for any account. Following is syntax of chsh command:
chsh -s {shell-name} {user-name}

Where,

  • -s {shell-name} : Specify your login shell name. You can obtained list of avialble shell from /etc/shells file.
  • User-name: It is optional, useful if you are a root user.

First, find out available shell list:
$ less /etc/shells

Output:

/bin/ash
/bin/csh
/bin/sh
/usr/bin/es
/bin/ksh
/bin/tcsh
/bin/sash
/bin/zsh
/bin/dash
/usr/bin/screen
/bin/bash
/bin/rbash

Now change your shell name to /bin/tcsh:
$ chsh -s /bin/tcsh
Password:

When promoted for password, type your own password. If you just type chsh command, it will prompt for shell name interactively:
$ chsh

Output:

Password:
Changing the login shell for tv
Enter the new value, or press ENTER for the default
       Login Shell [/bin/bash]:
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!