Tianhe Gao

Linux 下的 Shell

Refers:

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

查看用户的默认 Shell:

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

查看系统可用 Shell:

 1    $ cat /etc/shells
 2    # /etc/shells: valid login shells
 3    /bin/sh
 4    /bin/bash
 5    /usr/bin/bash
 6    /bin/rbash
 7    /usr/bin/rbash
 8    /usr/bin/sh
 9    /bin/dash
10    /usr/bin/dash
11    /usr/bin/tmux
12    /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:

使用 shellcheck 进行语法检查

检查文件权限数字

1stat -c '%a' /file/path/
2# 也可以是目录

No notes link to this note

Welcome to tell me your thoughts via "email"
UP