說明: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/(以上內容部分轉自此篇文章)