Ubuntu 18.04 常用设置

Ubuntu 操作简单方便,我经常在虚拟机中安装Ubuntu server
作为我的开发环境服务器。

设置root用户密码

$ sudo passwd

Password: <--- 输入你当前用户的密码

Enter new UNIX password: <--- 新的Root用户密码

Retype new UNIX password: <--- 重复新的Root用户密码

passwd:password updated successfully

设置静态IP

  • 查询ubuntu当前ip
$ ifconfig
ens32: flags=4163  mtu 1500
        inet 192.168.157.128  netmask 255.255.255.0  broadcast 192.168.157.255
        inet6 fe80::5159:3851:b556:44b2  prefixlen 64  scopeid 0x20
        ether 00:0c:29:9d:7a:8e  txqueuelen 1000  (以太网)
        RX packets 52782  bytes 76246654 (76.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9214  bytes 621798 (621.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (本地环回)
        RX packets 276  bytes 24057 (24.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 276  bytes 24057 (24.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 编辑 /etc/netplan/50-cloud-init.yaml 文件
sudo nano /etc/netplan/50-cloud-init.yaml

修改信息如下:

network:
    ethernets:
        ens33:
            addresses: [192.168.157.128/24]
         #   dhcp4: false
         #   optional: true
            dhcp4: no
            dhcp6: no
            gateway4:  192.168.157.0
            nameservers:
                addresses: [8.8.8.8, 9.9.9.9, 1.1.1.1]
    version: 2
  • 重启网卡
sudo netplan apply
  • 查询网卡信息
ifconfig

设置国内源

  • 备份/etc/apt/sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak
  • 修改/etc/apt/sources.list为如下条目
#阿里源  
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  • 更新源
sudo apt-get update  
sudo apt-get upgrade
  • 其他国内源
##中科大源  
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse  
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse  
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse  
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse  
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse  
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse  
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse  
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse  
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse  
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse


##163源  
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse  
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse  
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse  
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse  
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse  
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse  
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse  
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse  
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse  
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

##清华源  
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse  
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse  
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse  
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse  
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse  
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse  
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse  
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse  
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse  
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

安装docker

官网安装指导

安装docker-compose

官网安装指导

你可能感兴趣的:(ubuntu18.04)