Ubuntu的基础配置 对比Centos

一、基本字符集的配置

1.更改字符集

root@ubuntu:~# cat /etc/default/locale 
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
#如果想设置成为中文:
LANG="zh_CN.uft8"
LANGUAGE="zh_CN.utf8"
#重新启动生效:rebbot
#注意:在更改字符集之前首先要查看一下是否有相关语言包 

命令:
#查看当前使用的字符集情况 
root@ubuntu:~# locale 
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
#locate -a 查看当前系统中支持的所有字符集 

二、网络相关的初始化配置

1.配置静态ip

Ubuntu配置网卡的位置:/etc/network/interfaces
Centos配置网卡的位置:/etc/sysconfig/network-scripts/
Ubuntu把所有的网卡配置信息放在/etc/network/interfaces 中 ,而Centos 则把网卡配置在一个目录下

root@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/*
auto lo								//本地的环回网卡 
iface lo inet loopback				

auto ens33							//配置的网卡ens33 采用了redhad命名规则 
iface ens33 inet static 			
address 192.168.209.129
netmask 255.255.255.0
gateway 192.168.209.2 
dns-nameserver 192.168.209.2
#auto:表示开机自动加载网卡
#iface 网卡名 inet 状态 static/dhcp
#address ip地址 
#netmask 掩码 
#gateway 网关地址 
#dns-nameserver dns服务器地址 
:wq  
root@ubuntu:~# /etc/init.d/networking restart
root@ubuntu:~# ifconfig -a 				//查看我们配置的网卡
ens33     Link encap:Ethernet  HWaddr 00:0c:29:8f:ee:b6  
          inet addr:192.168.209.129  Bcast:192.168.209.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8f:eeb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69922 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:45580319 (45.5 MB)  TX bytes:1807995 (1.8 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3730 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3730 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:326440 (326.4 KB)  TX bytes:326440 (326.4 KB)

2.配置虚拟网卡

配置虚拟网卡在这里我指的是在一个网卡上配置两个或者多个ip地址
优点:打破物理接口的数量限制,在一个接口中实现多个VLAN间的路由和通信。
缺点:
由于独立的物理接口无带宽争用现象,与子接口相比,物理接口的性能更好。子接口用于 VLAN 间路由时,被发送的流量会争用单个物理接口的带宽。网络繁忙时,会导致通信瓶颈。为均衡物理接口上的流量负载,可将子接口配置在多个物理接口上,以减轻 VLAN 流量之间竞争带宽的现象

root@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/*
auto lo 
iface lo inet loopback

auto ens33
iface ens33 inet static 
address 192.168.209.129
netmask 255.255.255.0
gateway 192.168.209.2 
dns-nameserver 192.168.209.2

auto ens33:1
iface ens33:1 inet static 
address 192.168.2.129 
netmask 255.255.255.0 
使用ubutu 16.04 不知道什么原因何重启后不生效,需要手动删除ip表 重启
#ip addr flush dev ens33; ifdown enp3s0f0;ifup  ens33 

root@ubuntu:~# ifconfig -a 
ens33     Link encap:Ethernet  HWaddr 00:0c:29:8f:ee:b6  
          inet addr:192.168.209.129  Bcast:192.168.209.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8f:eeb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1787 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1134 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:137038 (137.0 KB)  TX bytes:133270 (133.2 KB)

ens33:1   Link encap:Ethernet  HWaddr 00:0c:29:8f:ee:b6  
          inet addr:192.168.2.129  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4000 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4000 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:296000 (296.0 KB)  TX bytes:296000 (296.0 KB)

3.配置DNS

配置dns有两种方式,两个位置同时起作用:
/etc/network/interface --> dns-nameserver ip
/etc/resolvconf/resolv.conf.d/base --> nameserver ip
/etc/network/interface

root@ubuntu:~# cat /etc/resolvconf/resolv.conf.d/base 
nameserver 8.8.8.8

重启网络服务: /etc/init.d/networking restart

root@ubuntu:~# cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.209.2			//interface配置 
nameserver 8.8.8.8					//base 配置 
//两者同时起作用

4.配置双网卡

配置双网卡的方式和配置子网卡的方式一样,这里不再赘述
注意内网网卡不要配置网关 linux系统中只能有一个默认网关
解决办法:
1.外网网卡设置网关 内网网卡不配置网关 ,内网网卡设置静态路由,配置发送的数据包走内网网卡

#sudo route add -net 192.168.2.0 netmask 255.255.255.0 dev ens38(让对192.168.2.0的访问走ens38网卡,netmask 后面是子网掩码)

三、查看系统版本 以及Linux内核版本的命令

root@ubuntu:~# cat /etc/issue
Ubuntu 16.04.2 LTS \n \l

root@ubuntu:~# uname -r 
4.4.0-62-generic

root@ubuntu:~# uname 
Linux

root@ubuntu:~# uname -a 
Linux ubuntu 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

四、apt源

1.配置apt源

区别于reahad系 rpm yum源 dibian使用apt源
位置 /etc/apt/sourse.list --> 去官方下载清华源或者阿里源

# 这里我配置了清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

2.apt安装软件的命令

apt-get install 软件包 			#安装软件包
apt-get remove 软件包 			#卸载软件包
apt-get update 					#更新缓存
apt-cache search package		#查找软件包 
apt-cache depends package 		#查看软件包的依赖
apt-get clean 					#清理缓存 
cat /etc/apt/sources.list | grep -Ev "^#|^$" 查看当前的apt源 

rpm相对的dpkg

介绍: 使用文本方式作为数据库 通常在/var/lib/dkpg目录下 的status下存储软件状态和控制信息

#dpkg -L   			#查看所有已经安装的软件的文件  对比 rpm -ql
root@ubuntu:~# dpkg -L vim 
/.
/usr
/usr/share
/usr/share/doc
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/vim
/usr/share/bug
/usr/share/bug/vim
/usr/share/bug/vim/script
/usr/share/bug/vim/presubj
/usr/bin
/usr/bin/vim.basic
/usr/share/doc/vim
 
#dpkg -l | grep ansible  #查看ansible的信息 对比 rpm -qa | grep ansible 
#apt list --installed | grep vim #查看已经安装的软件版本信息


root@ubuntu:~# dpkg -l | grep vim 
ii  vim                                2:7.4.1689-3ubuntu1.2              amd64        Vi IMproved -
ii  vim-common                         2:7.4.1689-3ubuntu1.2              amd64        Vi IMproved -
ii  vim-runtime                        2:7.4.1689-3ubuntu1.2              all          Vi IMproved -
ii  vim-tiny                           2:7.4.1689-3ubuntu1.2              amd64        Vi IMproved -sion combination with the other options
root@ubuntu:~# apt list --installed | grep vim 

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

vim/now 2:7.4.1689-3ubuntu1.2 amd64 [installed,upgradable to: 2:7.4.1689-3ubuntu1.5]
vim-common/now 2:7.4.1689-3ubuntu1.2 amd64 [installed,upgradable to: 2:7.4.1689-3ubuntu1.5]
vim-runtime/now 2:7.4.1689-3ubuntu1.2 all [installed,upgradable to: 2:7.4.1689-3ubuntu1.5]
vim-tiny/now 2:7.4.1689-3ubuntu1.2 amd64 [installed,upgradable to: 2:7.4.1689-3ubuntu1.5]

总结:

Ubuntu 是 debian系的操作系统
Centos 是 redhat 系操作系统
在一些基本的配置上会有些许的差别,比如网络配置 dns配置 源配置等等
各有各的优势 希望大家对比着学习,自己感受他们之间的差别 不要仅仅局限于一种系统来学习,比如一些对于图像处理的操作系统多用的是Ubuntu。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值