Avatar

Organizations

2 results for Bash
  • Alpine Linux 原始安装的是 busybox,小巧精干,但毕竟与主流的 Bash 还是有区别,特别是与其它系统联动时会比较麻烦,所以还是安装 Bash,统一 Shell 环境,方便日后使用。

    而且基本网上的安装教程都有问题,所以这里给出正确的安装步骤。

    安装

    $ apk add bash libuser
    

    配置

    $ touch /etc/login.defs
    $ mkdir /etc/default
    $ touch /etc/default/useradd
    $ lchsh <root>
    Changing shell for root.
    Password: <root password>
    New Shell [/bin/ash]: /bin/bash
    Shell changed.
    

    参考文档:

    linux bash alpine linux Created Tue, 03 Jan 2023 20:08:42 +0800
  • 初始化配置

    # 配置时区
    timedatectl set-timezone Asia/Shanghai
    
    # 关闭邮件服务
    systemctl stop [email protected] \
    ; systemctl disable [email protected]
    
    # 配置Shell提示符
    echo "PS1='\[\e[36;40m\][\D{%Y-%m-%d} \A] \[\e[0m\] \[\e[35;40m\]\w\[\e[0m\]\n\[\e[33;40m\][\u@\H]\[\e[0m\] \\$ '" >> ~/.bashrc
    # 打开自定义命令
    sed -E -i.bak \
        -e '/(export|eval|alias (ls|ll|l|rm|cp|mv))/s/^# //' ~/.bashrc \
        && . ~/.bashrc
    
    # 配置 sshd
    # 允许root密码登录
    # 允许密码登录
    # 解决SSH自动断开问题
    sed -E -i.bak \
        -e 's/#(Port 22)/\1/' \
        -e 's/#(PermitRootLogin) prohibit-password/\1 yes/' \
        -e 's/#(PubkeyAuthentication yes)/\1/' \
        -e 's/#(PasswordAuthentication yes)/\1/' \
        -e 's/#(AllowTcpForwarding yes)/\1/' \
        -e 's/(X11Forwarding yes)/#\1/' \
        -e 's/#(Compression delayed)/\1/' \
        -e 's/#(ClientAliveInterval) 0/\1 60/' \
        -e 's/#(ClientAliveCountMax) 3/\1 3/' \
        /etc/ssh/sshd_config \
        && systemctl restart sshd.service
    

    软件更新

    软件库管理

    CLI bash ssh top linux Created Mon, 17 Jan 2022 11:07:07 +0800