16
服务器基本配置(ubuntu)
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
)
学习目标:
- 修改初始服务器名字(ubuntu 16.04 )
- 修改初始服务器名字(ubuntu 18.04 )
- ubuntu换源
- 更改默认python版本
- 安装软件出现的问题
- 阿里服务器控制台创建快照
修改初始服务器名字(ubuntu 16.04 ):
查看当前主机名:
-
hostname
修改主机名:
-
vi/vim /etc/hostname
-
qw
保存退出 -
vi/vim /etc/hosts
-
# 在第二行添加 127.0.1.1 ubuntu(ubuntu为你刚才设置的主机名)
-
sudo reboot ---->重启系统
修改初始服务器名字(ubuntu 18.04 ):
-
vi/vim /etc/cloud/cloud.cfg
-
找到
preserve_hostname: false
将其修改为preserve_hostname: true
-
vi/vim /etc/hostname
-
qw
保存退出 -
vi/vim /etc/hosts
-
# 在第二行添加 127.0.1.1 ubuntu(ubuntu为你刚才设置的主机名)
-
sudo reboot ---->重启系统
ubuntu换源:
为什么换源,换源的好处:
- 默认的软件更新源是国外的,在国内使用速度很慢,需要更换成国内的源,这样才能正常安装和更新软件。
服务器换源(ubuntu 16.04 ):
-
sudo vi/vim/gedit /etc/apt/sources.list
-
#阿里源 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
-
更新:
- sudo apt-get update
- sudo apt-get upgrade
-
ubuntu16.04以上版本类似于此,网上都有不在赘述。
更改默认python版本:
修改软链接实现
-
进入/usr/bin目录,如不进入目录,以后每次对文件操作要写绝对路径
cd /usr/bin
-
查看该目录下与python有关的项
ls | grep python
-
查看python详细信息
ls -l python #软连接我修改了,未修改的话后面是python2.7
-
删除原软链接、建立新的指向python3的软链接
sudo rm python sudo ln -s python3.5 python
-
最后结果:
安装软件出现的问题:
Ubuntu16.04下,遇到Unmet dependencies. Try 'apt-get -f install' with no packages的解决办法:
sudo apt-get -f install
按照相关提示进行解决。
阿里服务器控制台创建快照:
为什么创建快照:
在配置软件时出现问题,造成系统混乱,或者环境依赖不同造成无法配置成功等。
如果后面遇到问题随时更新或开新帖
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK