linux 系统下 chsh 命令介绍和使用案例
Linux 系统下 chsh 命令用于更改用户的登录 shell
chsh 命令介绍chsh 命令的作用是更改用户的默认登录 shell。语法如下:
textchsh [选项] [用户名]选项是可选的,用于定制命令输出。用户名是要更改登录 shell 的用户账号名,如果省略则默认为当前用户。chsh 命令支持以下选项:
-s, --shell <shell>: 指定新的登录 shell。-l, --list-shells: 列出 /etc/shells 文件中定义的所有可用 shell。-u, --help: 显示帮助信息。-v, --version: 输出版本信息。命令:
root@meng:/opt# which chsh
/usr/bin/chsh
root@meng:/opt# chsh
Changing the login shell for root
Enter the new value, or press ENTER for the default
Login Shell [/bin/bash]:
root@meng:/opt# chsh --help
Usage: chsh [options] [LOGIN]
Options:
-h, --help display this help message and exit
-R, --root CHROOT_DIR directory to chroot into
-s, --shell SHELL new login shell for the user account
案例:
sudo chsh -s /usr/bin/dash mengroot@meng:/opt# echo $SHELL
/bin/bash
root@meng:/opt# cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/usr/bin/sh
/bin/dash
/usr/bin/dash
/usr/bin/tmux
/usr/bin/screen