Avatar

Organizations

12 results for CLI
  • 初始化配置

    # 配置时区
    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
  • 镜像列表

    [docker|podman] image ls -a
    # or
    [docker|podman] images
    

    容器列表

    [docker|podman] container ls -a
    # or
    [docker|podman] ps
    

    查看输出

    [docker|podman] compose -f <yaml_file> logs [-f] [service name]
    # or
    [docker|podman] logs [-f] [container id]
    

    验证配置文件

    [docker|podman] compose -f <yaml_file> config
    

    删除冗余镜像

    echo 'y' | [docker|podman] system prune
    

    导入导出镜像

    # 导出
    [docker|podman] save -o <image>.tar <image_name:label | image_id>
    # 导入
    # 使用image_id导出的镜像,导入时也没有名字
    [docker|podman] load -i <image>.tar
    

    不启动镜像,查看镜像内的文件

    # 创建临时容器
    [docker|podman] conatiner create --name <container_name> <image_name>
    # 从容器复制文件到宿主机
    [docker|podman] conatiner cp <container_name>:<file_path> <dest_path>
    # 清理临时窗口
    [docker|podman] container rm <container_name>
    

    创建桥接网络

    [docker|podman] network create [name]
    

    [docker|podman]快捷命令

    echo "alias d-ll='[docker|podman] image ls -a; echo; [docker|podman] container ls -a'" >> ~/.bashrc \
        && echo "alias d-ps='[docker|podman] ps'" >> ~/.bashrc \
        && echo "alias d-clean='[docker|podman] system prune -f'" >> ~/.bashrc \
        && echo "alias d-rm='_a(){ [docker|podman] image rm $1; echo; [docker|podman] container rm $1; }; _a'" >> ~/.bashrc \
        && echo "alias d-exec='_a(){ [docker|podman] exec -it $1 /bin/bash; }; _a'" >> ~/.bashrc \
        && echo "alias d-stop='_a(){ [docker|podman] container stop $1; }; _a'" >> ~/.bashrc \
        && echo "alias d-kill='_a(){ [docker|podman] container kill $1; }; _a'" >> ~/.bashrc
        
    source ~/.bashrc
    
    CLI docker podman container Created Thu, 13 Jan 2022 22:20:52 +0800