Ubuntu

系统镜像

Ubuntu桌面系统 👉 https://cn.ubuntu.com/download/desktop

常用操作

查询版本

lsb_release -a

开启 root 账户

  1. 登录一个普通账户,修改root密码,按提示输入

    sudo passwd root
  2. 修改 50-ubuntu.conf 配置

    # vi操作文件
    sudo vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
    
    # 增加 greeter-show-manual-login = true
    # 50-ubuntu.conf 配置修改,如下
    greeter-show-manual-login = true
    [Seat:*]
    user-session=ubuntu
  3. 修改 gdm-autologingdm-password

    # 分别注释 gdm-autologin 和 gdm-password 的 auth required pam_succeed_if.so user != root quiet_success 这行
    
    # vi操作文件
    sudo vi /etc/pam.d/gdm-autologin
    sudo vi /etc/pam.d/gdm-password
    
    # 要注释的地方在文件的第三行,auth required pam_succeed_if.so user != root quiet_success 这行
  4. 修改 /root/.profile

    sudo vi /root/.profile
    # 添加如下代码
    tty -s && mesg n || true
    mesg n || true
    
    # 修改结果如下
    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
        . ~/.bashrc
      fi
    fi
    tty -s && medh n || true
    mesg n || true
    mesg n 2> /dev/null || true
  5. 重启生效 reboot

开启远程SSH

  1. 登录 root 账号,安装SSH

    apt-get install openssh-server
  2. 修改 sshd_config 配置

    # 也可以安装vim修改,apt-get install vim
    vi /etc/ssh/sshd_config
    
    # 在 sshd_config (不是 ssh_config)的 #PermitRootLogin prohibit-password 的下面,增加这行
    PermitRootLogin yes
  3. 重启

    service ssh start
    # 上面不好使的话就用 reboot

防火墙设置

# 检查 UFW 防火墙状态
ufw status
ufw status verbose

# 启用 UFW 防火墙
ufw enable

# 允许SSH服务
ufw allow ssh

# 禁用 UFW 防火墙
ufw disable

# 安装 UFW 防火墙 GUI
apt install gufw -y

Docker安装

  1. 更新源

    apt update
    apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  2. 导入源仓库的 GPG key、添加 Docker APT 软件源

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    
    # 或使用 中国科技大学的 Docker-ce 的源
    curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
    $(lsb_release -cs) stable"
  3. 更新软件包缓存、安装Docker

    apt update
    apt install docker-ce docker-ce-cli containerd.io
  4. 安装完成后测试,docker version

  5. 配置国内的docker源

    mkdir -p /etc/docker
    tee /etc/docker/daemon.json <<EOF
    {
      "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
      "registry-mirrors": ["https://mirror.ccs.tencentyun.com"],
      "registry-mirrors": ["https://registry.docker-cn.com"],
      "registry-mirrors": ["http://hub-mirror.c.163.com"]
    }
    EOF
    
    # 重载配置并重启docker
    systemctl daemon-reload
    systemctl restart docker

Ubuntu
https://元气码农少女酱.我爱你/ea6466f250b7/
作者
元气码农少女酱
发布于
2023年5月2日
许可协议