zoukankan      html  css  js  c++  java
  • Ubuntu20.10 系统简单优化与配置阿里源

    Ubuntu20.10 系统简单优化与配置阿里源

    一 , 网卡配置

    # 16.04版本的网卡配置
    mpd@ubuntu:~$ cat /etc/network/interfaces
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto ens33
    iface ens33 inet static
    	address 192.168.15.200
    	netmask 255.255.255.0
    	network 192.168.15.0
    	broadcast 192.168.15.255
    	gateway 192.168.15.2
    	# dns-* options are implemented by the resolvconf package, if installed
    	dns-nameservers 223.5.5.5 114.114.114.114
    	
    # 20.10版本的网卡配置
    mpd@ubuntu20:~$ cat /etc/netplan/00-installer-config.yaml 
    # This is the network config written by 'subiquity'
    network:
      ethernets:
        ens33:
          addresses:
          - 192.168.15.200/24
          gateway4: 192.168.15.2
          nameservers:
            addresses:
            - 114.114.114.114
      version: 2
    

    重启网卡

    /etc/init.d/networking restart
    # ifdown enp0s3(关闭网卡ens33) && ifup   enp0s3(启动网卡ens33)
    sudo service network-manager restart  
    # 如果重启网卡不成功 可以重启试试reboot
    

    二,开启远程链接22端口和设置开启支持root用户登录

    1)开启22端口

    由于Ubuntu没有默认开启22端口需要手动打开 才能ssh远程连接

    sudo apt install net-tools
    

    安装后,想通过MobaXterm远程工具连接的时候发现连接失败。

    此时,查看Ubuntu关于22的端口,执行命令如下

    netstat -ntlp|grep 22
        参数解释:
        -n  不以进程的服务名称,以端口号(port number)显示
    	-t  列出tcp网络封包的信息
    	-l  列出目前正在网络监听(listen)服务
    	-p  列出该网络服务的进程
    

    此时若发现无任何关于22端口的进程内容,执行以下命令

    sudo apt-get install openssh-server
    sudo apt-get install ufw
    sudo ufw enable
    sudo ufw allow 22
    

    然后再用xshell连接成功。

    2)设置允许root用户登录
    mpd@ubuntu20:~$ sudo vim /etc/ssh/sshd_config
    [sudo] password for mpd:
    # ssh登录的时候用户没有输入密码时多少秒之后自动退出
    LoginGraceTime 120
    # 允许root用户用密码登录
    # PermitRootLogin prohibit-password 改成PermitRootLogin yes
    # 设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权
    StrictModes yes
    
    # 设置root密码
    mpd@ubuntu:~$ sudo passwd root
    Enter new UNIX password: 1
    Retype new UNIX password: 1
    passwd: password updated successfully
    mpd@ubuntu:~$ su - root
    Password: 1
    root@ubuntu:~#
    
    

    三,配置阿里云源

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    

    四,apt包管理工具

    sudo apt-cache search package           		   #搜索包
    sudo apt-cache show package             		   #获取包的相关信息,如说明、大小、版本等
    sudo apt-get install package       		           #安装包
    sudo apt-get install package --reinstall		   #重新安装包
    sudo apt-get -f install     			           #修复安装”-f = –fix-missing”
    sudo apt-get remove package     			   #删除包
    sudo apt-get remove package --purge     	           #删除包,包括删除配置文件等
    sudo apt-get update     				   #更新源
    sudo apt-get upgrade     				   #更新已安装的包
    sudo apt-get dist-upgrade     			           #升级系统
    sudo` `apt-get dselect-upgrade     		           #使用 dselect 升级
    apt-cache depends package     			           #了解使用依赖
    apt-cache rdepends package     			           #是查看该包被哪些包依赖
    sudo apt-get build-dep package     			   #安装相关的编译环境
    apt-get source package     			           #下载该包的源代码
    sudo apt-get clean && sudo apt-get autoclean               #清理无用的包
    sudo apt-get check     				           #检查是否有损坏的依赖
    sudo apt-get clean     				           #清理所有软件缓存(即缓存在/var/cache/apt/archives目录里的deb包)
    dpkg -L 包名						   #查看安装包的相关所有配置文件
    

    五,查看发行版本

    mpd@ubuntu20:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID:	Ubuntu
    Description:	Ubuntu 20.10
    Release:	20.10
    Codename:	groovy
    
  • 相关阅读:
    Django学习过程中遇到的问题
    代理工具WebScarab安装(转载)
    MongoDB安装之window版本的安装
    QT打包
    小工具--串口
    多线程--信号量
    关于多线程
    QQ界面及简单操作实现
    udp通信
    char *p = "abc";char p[] = "abc";两者之间的区别
  • 原文地址:https://www.cnblogs.com/xiaolang666/p/15318692.html
Copyright © 2011-2022 走看看