Linux 下的 Shell

Refers:

1
2
    sudo chsh -s /bin/bash $USERNAME
    sudo chsh -s /bin/bash user

查看用户的默认 Shell:

1
2
3
4
5
6
7
8
9
    $ grep user /etc/passwd
    user:x:1000:1000::/home/user:/bin/bash
    # 或者
    $ ps -p $$
    PID TTY          TIME CMD
    22572 pts/1    00:00:00 bash
    # 或者
    $ echo "$0"
    bash

查看系统可用 Shell:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    $ 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

通过 type -a bash 找到 bash 的所有位置。

chsh

更改当前用户 Shell

    chsh -s /bin/zsh
    echo $SHELL

列出所有 Shell

    chsh -l

useradd

新建用户(有家目录)

refer https://wiki.archlinux.org/title/Users_and_groups

    useradd -m example
    passwd example

adduser

adduser provides a high level interface for adding new users, and useradd provides a low level interface.

Quickly set up an SSH agent:

Layout of comment panels