arm linux 终端自动登录
/etc/profile 环境变量文件,这个是在用户登录后执行的,所以要想profile里面的开机启动程序自动运行,则必须要登录。当然也可以提前执行而不必等到登录,在/etc/init.d/ 下新建S99等级文件,在其中启动用户程序。另一种则采用自动登录,当然作为产品应用肯定前一种会更好,参考正点原子的S99等级文件
自动登录
默认linux是需要手动登录的,登录部分是在/etc/inittab中 console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIA 这行,
该行的格式id:runlevels:action process,这部分在inittab文件中是有说明的,具体可以参考https://www.cnblogs.com/yfz0/p/5853826.html#:~:text=1%29respaw,%EF%BC%8C%E5%88%99%E4%BB%80%E4%B9%88%E4%B9%9F%E4%B8%8D%E5%81%9A%E3%80%82
# 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
这行重点是/sbin/getty ,至于getty的详细介绍不深入,这里只说他的作用,具备两个作用,打开终端并提示用户登录,默认的是调用/bin/login执行登录,这里要实现自动登录只需要替换掉后边部分即可,console::respawn:/sbin/getty ttymxc0 115200 vt100 -n -l /bin/sh。至于意思可以对照busybox 的getty help的说明进行理解.采用这这方式,需要手动调用/etc/profile
BusyBox v1.29.3 (2020-12-18 19:52:32 CST) multi-call binary.
Usage: getty [OPTIONS] BAUD_RATE[,BAUD_RATE]... TTY [TERMTYPE]
Open TTY, prompt for login name, then invoke /bin/login
-h Enable hardware RTS/CTS flow control
-L Set CLOCAL (ignore Carrier Detect state)
-m Get baud rate from modem's CONNECT status message
-n Don't prompt for login name
-w Wait for CR or LF before sending /etc/issue
-i Don't display /etc/issue
-f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue
-l LOGIN Invoke LOGIN instead of /bin/login
-t SEC Terminate after SEC if no login name is read
-I INITSTR Send INITSTR before anything else
-H HOST Log HOST into the utmp file as the hostname
BAUD_RATE of 0 leaves it unchanged

浙公网安备 33010602011771号