說明:
1、CentOS與Ubuntu沒有什么可比性,底層都是Linux,並且Ubuntu在YY廣泛的使用,這些並不能說明那個強大哪個不行,只要能解決問題的都是好家伙。
2、市面上教程基本都是基於6,而7的比較少,如果想要練手可以直接上6,大把解決方案;但建議用最新的7,性能和兼容性都得到很好的解決;這一點和用JDK 7和JDK 8有點相像,在Java來說,JDK永遠兼容低版本,並且越高的版本修復的BUG和性能上都有明顯的改善,所以,有最新的版本就用最新的版本。
命令區別:

(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
底層區別:
0.前言
CentOS7與6之間最大的差別就是初始化技術的不同,7采用的初始化技術是Systemd,並行的運行方式,除了這一點之外,服務啟動、開機啟動文件、網絡命令方面等等
1.系統初始化技術
- Sysvinit技術
- Upstart技術
- Systemd技術
Sysvinit技術
特點:
- 1.系統第1個進程為init;
- 2.init進程是所有進程的父進程,不可kill;
- 3.大多數Linux發行版的init系統是和SystemV相兼容的,被稱為sysvinti
- 4.代表系統:CentOS5 CentOS6
優點:
- sysvinit運行非常良好,概念簡單清晰。它主要依賴於shell腳本。
缺點:
- 1.按照一定順序執行——>啟動太慢。
- 2.很容易hang住,fstab與nfs掛載問題
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
https://www.cnblogs.com/can-H/p/6749127.html
http://blog.51cto.com/pengjiezhang/1868140
http://www.hostloc.com/thread-299433-1-1.html
https://www.cnblogs.com/can-H/p/6749127.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
https://www.cnblogs.com/Csir/p/6746667.html(以上內容部分轉自此篇文章)
https://www.t4x.org/basic/centos6x-diff-centos7x/(以上內容部分轉自此篇文章)