45 如何在Linux下查看和切换shell

1、可以使用echo $SHELL来查看当前使用的shell

alloy@alloy:~$ echo $SHELL
/bin/bash

alloy@alloy:~$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4  3月 15 10:13 /bin/sh -> dash

2、通过对/etc/shells的查看可以看到当前系统中安装的shell

alloy@alloy:~$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash

3、使用chsh可以在shell之间进行切换

alloy@raspberrypi:~/linuxshell/chapter9$ chsh
Password:
Changing the login shell for alloy
Enter the new value, or press ENTER for the default
        Login Shell [/bin/bash]: /bin/dash
alloy@raspberrypi:~/linuxshell/chapter9$ echo $SHELL
/bin/bash


alloy@raspberrypi:~/linuxshell/chapter9$ chsh
Password:
Changing the login shell for alloy
Enter the new value, or press ENTER for the default
        Login Shell [/bin/dash]: /bin/bash
alloy@raspberrypi:~/linuxshell/chapter9$

你可能感兴趣的:(Ubuntu,相关应用,Linux,Shell编程)