几种查看CentOS版本信息的方法
1. 查看CentOS的kernel版本
[root@localhost ~]# cat /proc/version
Linux version 2.6.32-279.el6.i686 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 10:59:55 UTC 2012
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
2. 查看CentOS系统版本
[root@localhost ~]# cat /etc/centos-release
CentOS release 6.3 (Final)
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.3 (Final)
LSB是Linux Standard Base的缩写,lsb_release命令用来显示LSB和特定版本的相关信息。
这个命令适用于所有的linux,包括Redhat、SuSE、Debian、Centos等发行版。
-a, --all 就是显示所有信息,显示包括版本信息、发行版的ID、发行版的描述信息、具体版本号、发行版代号的信息。
[root@localhost ~]# lsb_release -d
Description: CentOS release 6.3 (Final)
[root@localhost ~]# lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.3 (Final)
Release: 6.3
Codename: Final
3. 查看系统是64位还是32位
x86_64 是 64位
i386 i686 都是32位
[root@localhost ~]# uname -i
i386
[root@localhost ~]# file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
CentOS5 CentOS6 CentOS7的root密码重置
1.CentOS7的root密码重置
与之前的5,6不同的是,当忘记root密码,并采用GRUB2为启动器时,将无法通过单用户模式重置root密码。
重置密码步骤:
1. 启动系统,并在GRUB2启动屏显时,按下e
键进入编辑模式。(上下箭头键可以选择要修改的启动kernel)
2. 把linux16 /vmlinuz...
所在参数行的ro
改为rw
,以读写
方式挂载root分区
3. 在linux16 /vmlinuz...
所在参数行尾添加init=/bin/bash
4. 按ctrl+x
启动到bash shell
5. 如果第2步没有做,需要手工挂载/
分区为可读写模式,mount -o remount,rw /
6. 使用passwd root
修改root密码
7. 如果系统启用了SELinux,如要重新打标签(否则无法正常启动),touch /.autorelabel
8. 重启系统exec /sbin/init 6
或者exec /sbin/reboot
至此,重置CentOS7的root密码完成。
2.CentOS5和CentOS6的root密码重置
1、开机按Esc
进入centos 6启动选择目录
2、选中要进入的内核,按e
进入grub
3、选择kernel那一项,按e
进入
4、在行尾输入一个空格键,然后在输入数字1
或者singal
,回车
5、选择kernel那一项,按b
,系统自动重启
6、重设root密码,passwd root
,回车
7、输入新密码:newpasswd 回车
8、再次输入新密码:newpasswd 回车
此时看到passwd:all authentication tokens updated successfully.一行,说明密码修改成功。
参考链接:https://www.cnblogs.com/seerjk/p/5103967.html
https://www.cnblogs.com/seerjk/p/5103889.html