Ubuntu 18.04 經常使用設置

Ubuntu 操做簡單方便,我常常在虛擬機中安裝Ubuntu server
做爲個人開發環境服務器。docker

設置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<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        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

修改信息以下:ubuntu

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

官網安裝指導app

相關文章
相關標籤/搜索