Redhat OS界面切换与自动登录
1、Redhat6 OS
1.1、图形界面和文字界面切换
打开/etc/inittab文件,更改最后一行id后的数字, 然后保存退出。3 表示文件界面 5 表示图形界面
# vim /etc/inittab
id:5:initdefault:
1.2、文字界面自动登录
打开/etc/init/tty.conf文件,在$TTY后面添加–autologin root,然后报错退出。切换成文字界面,重启实现自动登录
# vim /etc/init/tty.conf
stop on runlevel [S016]
respawn
instance $TTY
exec /sbin/mingetty $TTY --autologin root
usage 'tty TTY=/dev/ttyx - where X is console id'
1.3、图形界面自动登录
在/etc/gdm/custom.conf文件,在daemon后面添加如下两行内容
# vim /etc/gdm/custom.conf
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=root
2、Redhat7.1 OS
2.1、图形界面和文字界面切换
-
设置默认登录图形界面
# systemctl set-default graphical.target
-
设置默认登录文字界面
# systemctl set-default multi-user.target
2.2、 文字界面自动登录
打开/etc/systemd/system/getty.target.wants/getty@tty1.service,在¥TERM后面添加–autologin root,然后报存退出。切换文字界面,重启实现自动登录。
# vim /etc/systemd/system/getty.target.wants/getty@tty1.service
[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM --autologin root
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
WantedBy=getty.target
DefaultInstance=tty1
2.3、图形界面自动登录
打开/etc/gdm/custom.conf文件,在daemon后面添加如下两行内容
# vim /etc/gdm/custom.conf
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=root