16

服务器基本配置(ubuntu)

 3 years ago
source link: http://www.cnblogs.com/xbhog/p/13550579.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

服务器基本配置( ubuntu

学习目标:

  1. 修改初始服务器名字(ubuntu 16.04 )
  2. 修改初始服务器名字(ubuntu 18.04 )
  3. ubuntu换源
  4. 更改默认python版本
  5. 安装软件出现的问题
  6. 阿里服务器控制台创建快照

修改初始服务器名字(ubuntu 16.04 ):

查看当前主机名:

  1. hostname

修改主机名:

  1. vi/vim  /etc/hostname
  2. qw 保存退出

  3. vi/vim  /etc/hosts
  4. # 在第二行添加
    127.0.1.1 ubuntu(ubuntu为你刚才设置的主机名)
  5. sudo reboot ---->重启系统

修改初始服务器名字(ubuntu 18.04 ):

  1. vi/vim /etc/cloud/cloud.cfg
  2. 找到 preserve_hostname: false 将其修改为 preserve_hostname: true

  3. vi/vim /etc/hostname
  4. qw 保存退出

  5. vi/vim /etc/hosts
  6. # 在第二行添加
    127.0.1.1 ubuntu(ubuntu为你刚才设置的主机名)
  7. sudo reboot ---->重启系统

ubuntu换源:

为什么换源,换源的好处:

  • 默认的软件更新源是国外的,在国内使用速度很慢,需要更换成国内的源,这样才能正常安装和更新软件。

服务器换源(ubuntu 16.04 ):

  1. sudo vi/vim/gedit /etc/apt/sources.list
  2. #阿里源
    deb http://mirrors.aliyun.com/ubuntu/ xenial main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
  3. 更新:

    • sudo apt-get update
    • sudo apt-get upgrade
  4. ubuntu16.04以上版本类似于此,网上都有不在赘述。

更改默认python版本:

修改软链接实现

  1. 进入/usr/bin目录,如不进入目录,以后每次对文件操作要写绝对路径

    cd /usr/bin
  2. 查看该目录下与python有关的项

    ls | grep python

    rI7ruaZ.png!mobile

  3. 查看python详细信息

    ls -l python
    #软连接我修改了,未修改的话后面是python2.7

    baIBryr.png!mobile

  4. 删除原软链接、建立新的指向python3的软链接

    sudo rm python
    sudo ln -s python3.5 python
  5. 最后结果:

    qi2YR3Q.png!mobile

安装软件出现的问题:

Ubuntu16.04下,遇到Unmet dependencies. Try 'apt-get -f install' with no packages的解决办法:

sudo apt-get -f install

按照相关提示进行解决。

阿里服务器控制台创建快照:

为什么创建快照:

在配置软件时出现问题,造成系统混乱,或者环境依赖不同造成无法配置成功等。

aAzA7nR.png!mobile

vUbe2e.png!mobile

如果后面遇到问题随时更新或开新帖


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK