说明:html
一、CentOS与Ubuntu没有什么可比性,底层都是Linux,而且Ubuntu在YY普遍的使用,这些并不能说明那个强大哪一个不行,只要能解决问题的都是好家伙。shell
二、市面上教程基本都是基于6,而7的比较少,若是想要练手能够直接上6,大把解决方案;但建议用最新的7,性能和兼容性都获得很好的解决;这一点和用JDK 7和JDK 8有点相像,在Java来讲,JDK永远兼容低版本,而且越高的版本修复的BUG和性能上都有明显的改善,因此,有最新的版本就用最新的版本。数据库
命令区别:ubuntu
(1)桌面系统 [CentOS6] GNOME 2.x [CentOS7] GNOME 3.x(GNOME Shell) (2)文件系统 [CentOS6] ext4 [CentOS7] xfs (3)内核版本 [CentOS6] 2.6.x-x [CentOS7] 3.10.x-x (4)启动加载器 [CentOS6] GRUB Legacy (+efibootmgr) [CentOS7] GRUB2 (5)防火墙 [CentOS6] iptables [CentOS7] firewalld (6)默认数据库 [CentOS6] MySQL [CentOS7] MariaDB (7)文件结构 [CentOS6] /bin, /sbin, /lib, and /lib64在/下 [CentOS7] /bin, /sbin, /lib, and /lib64移到/usr下 (8)主机名 [CentOS6] /etc/sysconfig/network [CentOS7] /etc/hostname (9)时间同步 [CentOS6] ntp ntpq -p [CentOS7] chrony chronyc sources (10)修改时间 [CentOS6] vim /etc/sysconfig/clock ZONE="Asia/Tokyo" UTC=fales sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime [CentOS7] timedatectl set-timezone Asia/Tokyo timedatectl status (11)修改地区 [CentOS6] vim /etc/sysconfig/i18n LANG="ja_JP.utf8"/etc/sysconfig/i18n locale [CentOS7] localectl set-locale LANG=ja_JP.utf8 localectl status (12)服务相关 启动中止 [CentOS6] service service_name start service service_name stop service sshd restart/status/reload [CentOS7] systemctl start service_name systemctl stop service_name systemctl restart/status/reload sshd 自启动 [CentOS6] chkconfig service_name on/off [CentOS7] systemctl enable service_name systemctl disable service_name 服务一览 [CentOS6] chkconfig --list [CentOS7] systemctl list-unit-files systemctl --type service 强制中止 [CentOS6] kill -9 <PID> [CentOS7] systemctl kill --signal=9 sshd (13)网络 网络信息 [CentOS6] netstat netstat -I netstat -n [CentOS7] ip n ip -s l ss IP地址MAC地址 [CentOS6] ifconfig -a [CentOS7] ip address show 路由 [CentOS6] route -n route -A inet6 -n [CentOS7] ip route show ip -6 route show (14)重启关闭 关闭 [CentOS6] shutdown -h now [CentOS7] poweroff systemctl poweroff 重启 [CentOS6] reboot shutdown -r now [CentOS7] reboot systemctl reboot 单用户模式 [CentOS6] init S [CentOS7] systemctl rescue 启动模式 [CentOS6] [GUICUI] vim /etc/inittab id:3:initdefault: [CUIGUI] startx [CentOS7] [GUICUI] systemctl isolate multi-user.target [CUIGUI] systemctl isolate graphical.target 默认 systemctl set-default graphical.target systemctl set-default multi-user.target 当前 systemctl get-default
底层区别:vim
0.前言centos
CentOS7与6之间最大的差异就是初始化技术的不一样,7采用的初始化技术是Systemd,并行的运行方式,除了这一点以外,服务启动、开机启动文件、网络命令方面等等sublime-text
1.系统初始化技术bash
Sysvinit技术网络
特色:app
优势:
缺点:
Upstart技术
CentOS6采用了upstart技术代替sysVinit进行引导,Upstart对rc.sysinit脚本作了大量的优化,缩短了系统初始化的启动时间。可是CentOS6为了简便管理员的操做,upstart的不少特性并无凸显或直接不支持。
表明系统:CentOS6, Ubuntu14, 从CentOS7, Ubuntu15开始使用systemd
Systemd技术
新系统都会采用的技术(RedHat7,CentOS7,Ubuntu15等);
设计目标是克服sysvinit固有的缺点,提升系统的启动速度;
和Sysvinit兼容,下降迁移成本;
最主要优势:并行启动
Pid为1的进程
2.在yum源上的优化
在CentOS的时候,默认是从官方源下载rpm包的,因为是国外的yum源很慢不能用,CentOS7在这里作了优化,当咱们使用yum安装软件的时候,默认不会再从官方下载,而是自动寻找离本身地理位置最近的yum源开始下载。
3.命令
若是在安装系统的时候选择minimal,会比以前6的时候以更小的包来安装,好比:vim、ifconfig、route、setup、netstat等等不少命令都没有了。在安装系统后可加入如下软件包:
yum install lrzsz tree net-tools nmap vim bash-completion lsof dos2unix nc telnet ntp wget rng-tools psmisc screen -y
4.字符集修改
/etc/locale.conf #字符集配置文件 localectl set-locale LANG=zh_CN.UTF-8 # 命令行一步到位 [root@CentOS7 ~]# localectl set-locale LANG=zh_CN.UTF-8 [root@CentOS7 ~]# localectl status System Locale: LANG=zh_CN.UTF-8 VC Keymap: us X11 Layout: us
5.开机启动管理
/etc/rc.local # 这个文件仍是存在,不过若是咱们还想继续使用这种方式须要给它加执行权限chmod +x /etc/rc.d/rc.local # system一统天下 snapshot(支持快照) systemctl status cron.service #查看定时任务状态 systemctl stop cron.service #关闭定时任务 systemctl status cron.service #查看操做状况 systemctl list-unit-files|grep enable #查看当前正在运行的服务 systemctl disable postfix.service #关闭邮件服务 systemctl list-unit-files|grep postfix #查看邮件服务是否开启 systemctl stop firewalld.service #关闭防火墙 systemctl is-enable #开启的服务 systemctl disable #关闭的服务 #经过/etc/rc.d/rc.local/开机自启动 #CentOS7中/etc/rc.d/rc.local须要执行以下命令赋予可执行权限 chmod +x /etc/rc.d/rc.local
6.运行级别runlevel
/etc/inittab 是无效的 system target 替代 ##永久生效下次登陆生效 systemctl get-default graphical.target 切换到5 systemctl get-default multi-user.target 切换到3 ##临时生效的话 init3 ##只有五种运行级别 [root@centos7 ~]# ls -lh /usr/lib/systemd/system/runlevel*.target lrwxrwxrwx. 1 root root 15 Apr 20 22:31 /usr/lib/systemd/system/runlevel0.target -> poweroff.target lrwxrwxrwx. 1 root root 13 Apr 20 22:31 /usr/lib/systemd/system/runlevel1.target -> rescue.target lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel2.target -> multi-user.target lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel3.target -> multi-user.target lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel4.target -> multi-user.target lrwxrwxrwx. 1 root root 16 Apr 20 22:31 /usr/lib/systemd/system/runlevel5.target -> graphical.target lrwxrwxrwx. 1 root root 13 Apr 20 22:31 /usr/lib/systemd/system/runlevel6.target -> reboot.target
7.配置yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #官方epel源 wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -ivh epel-release-latest-7.noarch.rpm
8.网卡名称
没有eth0,采用很长的名称。不过能够修改回来。
9.man
CentOS6
[root@Centos6 ~]# whatis man man: nothing appropriate [root@Centos6 ~]# makewhatis [root@Centos6 ~]# man -f man man (1) - format and display the on-line manual pages man.config [man] (5) - configuration data for man man [manpath] (1) - format and display the on-line manual pages
CentOS7
[root@Centos7 ~]# man -f man man: nothing appropriate. [root@Centos7 ~]# makewhatis -bash: makewhatis: command not found [root@Centos7 ~]# mandb [root@Centos7 ~]# man -f man man (1) - an interface to the on-line reference manuals
10.服务启动
CentOS6
[root@Centos6 ~]# /etc/init.d/sshd status #查询sshd服务状态 openssh-daemon (pid 1183) is running... [root@Centos6 ~]# /etc/init.d/sshd restart #从新启动sshd服务 Stopping sshd: [ OK ] Starting sshd: [ OK ] [root@Centos6 ~]# service sshd restart #从新启动sshd服务 [root@Centos6 ~]# chkconfig --list|grep 3:on #启动服务
[root@Centos7 ~]# systemctl status sshd.service #查询sshd服务状态 sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Tue 2016-01-12 16:04:22 CST; 5min ago Process: 2018 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS) Main PID: 2019 (sshd) CGroup: /system.slice/sshd.service └─2019 /usr/sbin/sshd -D [root@Centos7 ~]# systemctl restart sshd.service #从新启动sshd服务 [root@Centos7 ~]# systemctl list-unit-files|grep enabled #查询全部启动服务
11.防火墙
CentOS6(默认是iptables):
[root@Centos6 ~]# iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT #容许22端口,默认sshd服务
CentOS7(默认是firewalld):
[root@Centos7 ~]# firewall-cmd --permanent --zone=public --add-port=22/tcp #容许22端口,默认sshd服务
12.语言
CentOS6
[root@centos6 /]# cat /etc/sysconfig/i18n LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
CentOS7
[root@centos7 ~]$ cat /etc/locale.conf LANG="en_US.UTF-8" SYSFONT="latarcyrheb-sun16"
13.man page转换纯文本
CentOS6
[root@centos6 /]# man test | col -b > 1.txt #内容中有反斜杠,保留后面的内容
CentOS7
[root@centos6 /]# man test >1.txt #7貌似过滤了
参考:
https://www.t4x.org/basic/centos6x-diff-centos7x/
http://blog.51cto.com/cuidehua/1858374
http://www.javashuo.com/article/p-kasxpgfh-bu.html
http://blog.51cto.com/pengjiezhang/1868140
http://www.hostloc.com/thread-299433-1-1.html
http://www.javashuo.com/article/p-kasxpgfh-bu.html
https://www.t4x.org/basic/centos6x-diff-centos7x/
http://www.cnblogs.com/bethal/p/5945026.html(以上内容部分转自此篇文章)
http://blog.csdn.net/qq_21439971/article/details/54585639
http://www.javashuo.com/article/p-qanbzpyg-ct.html(以上内容部分转自此篇文章)
https://www.t4x.org/basic/centos6x-diff-centos7x/(以上内容部分转自此篇文章)