Ubuntu Server 配置

164 阅读1分钟

配置

系统设置

  • wifi

    # 找到无线网卡名称
    ip addr 
    
    # vim /etc/netplan/00-installer-config-wifi.yaml
    network:  
        version: 2  
        wifis:  
            上面查到的网卡名称:  
                dhcp4: true  
                dhcp6: true  
                access-points:  
                    "wifi名称":  
                        password: "wifi密码"
    
    # 重启网络服务
    sudo netplan apply
    
  • 5s 关闭屏显

    # vim /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=5"
    
    # 更新 GRUB 配置 
    sudo update-grub
    
    # 重启系统
    sudo reboot
    
  • 笔记本合盖不睡眠

    # vim /etc/systemd/logind.conf
    
    HandleLidSwitch=ignore  
    HandleListSwitchExternalPower=ignore  
    HandleLidSwitchDocked=ignore  
    LidSwitchIgnoreInhibited=no  
    

ssh

  • 配置 SSH 连接 (让别的机器连接自己)

    #把github公钥拉下来  
    ssh-import-id gh:githubusername
    
  • 生成 ssh 密钥 (让自己访问别的机器)

    ssh-keygen
    
    # 获取自己的公钥
    cat ~/.ssh/id_rsa.pub
    
  • 关闭密码登录

    # vim /etc/ssh/sshd_config
    # 记得先设置好
    PasswordAuthentication no
    

软件

docker

  • shell脚本地址
    curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
    
  • 把当前用户加入 docker 组
    # id 、 groups 可查看当前用户所在组
    # 把用户加入 docker 组
    sudo usermod -aG docker ${USER}
    
    # 重启 docker 服务 
    # sudo systemctl restart docker
    
    # 重新登录
    logout 
    
    
  • 配置 镜像加速(或者专属加速地址)
    # vim /etc/docker/daemon.json
    {
      "registry-mirrors": [
          "http://hub-mirror.c.163.com",
          "https://docker.mirrors.ustc.edu.cn",
          "https://registry.docker-cn.com"
      ]
    }
    
    # 重启 docker
    service docker restart
    
    # 查看配置
    docker info
    
    # 测试
    docker run hello-world
    

内网 frp

安装新版 LTS nodejs (以 24x 为例)

# 向系统添加 NodeSource 的软件源
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -


# 安装
sudo apt install -y nodejs