Linux启动后自动登录root进入控制台
通过修改 /etc/inittab 文件来实现
1. buildroot 编译出来的 /etc/inittab 文件如下
# # Copyright (C) 2001 Erik Andersen <andersen@codepoet.org> # # Note: BusyBox init doesn't support runlevels. The runlevels field is # completely ignored by BusyBox init. If you want runlevels, use # sysvinit. # # Format for each entry: <id>:<runlevels>:<action>:<process> # # id == tty to run on, or empty for /dev/console # runlevels == ignored # action == one of sysinit, respawn, askfirst, wait, and once # process == program to run # Startup the system ::sysinit:/bin/mount -t proc proc /proc ::sysinit:/bin/mount -o remount,rw / ::sysinit:/bin/mkdir -p /dev/pts /dev/shm ::sysinit:/bin/mount -a ::sysinit:/bin/mkdir -p /run/lock/subsys ::sysinit:/sbin/swapon -a null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr ::sysinit:/bin/hostname -F /etc/hostname # now run any rc scripts ::sysinit:/etc/init.d/rcS # Put a getty on the serial port console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL # Stuff to do for the 3-finger salute #::ctrlaltdel:/sbin/reboot # Stuff to do before rebooting ::shutdown:/etc/init.d/rcK ::shutdown:/sbin/swapoff -a ::shutdown:/bin/umount -a -r
Linux启动后会进入 login 界面,需要 输入root 登录,才能进入控制台。
2. 修改 /etc/inittab 文件如下
1 # /etc/inittab 2 # 3 # Copyright (C) 2001 Erik Andersen <andersen@codepoet.org> 4 # 5 # Note: BusyBox init doesn't support runlevels. The runlevels field is 6 # completely ignored by BusyBox init. If you want runlevels, use 7 # sysvinit. 8 # 9 # Format for each entry: <id>:<runlevels>:<action>:<process> 10 # 11 # id == tty to run on, or empty for /dev/console 12 # runlevels == ignored 13 # action == one of sysinit, respawn, askfirst, wait, and once 14 # process == program to run 15 16 # Startup the system 17 ::sysinit:/bin/mount -t proc proc /proc 18 ::sysinit:/bin/mount -o remount,rw / 19 ::sysinit:/bin/mkdir -p /dev/pts /dev/shm 20 ::sysinit:/bin/mount -a 21 ::sysinit:/bin/mkdir -p /run/lock/subsys 22 ::sysinit:/sbin/swapon -a 23 null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd 24 null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin 25 null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout 26 null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr 27 ::sysinit:/bin/hostname -F /etc/hostname 28 # now run any rc scripts 29 ::sysinit:/etc/init.d/rcS 30 31 # Put a getty on the serial port 32 #console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL 33 ::respawn:-/bin/sh 34 35 # Stuff to do for the 3-finger salute 36 #::ctrlaltdel:/sbin/reboot 37 38 # Stuff to do before rebooting 39 ::shutdown:/etc/init.d/rcK 40 ::shutdown:/sbin/swapoff -a 41 ::shutdown:/bin/umount -a -r 42 #
Linux启动自动登录root,进入控制台,/etc/profile 文件被自动生效。
posted on 2024-09-04 10:09 f1engmin11 阅读(66) 评论(0) 编辑 收藏 举报