1. 程式人生 > >[小技巧]Linux的一些信息獲取

[小技巧]Linux的一些信息獲取

系統登錄 dom als plain clas code ack ... ins

1. Linux 系統登錄之後,顯示如下
Last login: Thu Jan 1 00:00:22 UTC 1970 on ttyS0
Linux xxx 4.1.6 #1 PREEMPT Wed Jul 19 13:15:08 CST 2017 armv7l

那麽這些信息是哪裏獲取到的呢,比如Jul19 13:15....

Kernel每次編譯的時間在源碼的什麽位置?

include/generated/compile.h

2. Kernel版本信息存放在源碼什麽位置?

include/generated/utsrelease.h

3. 如何定制自己的登錄前後信息?

/etc/issue, 可以選擇在這裏做登錄提示,或者項目標誌打印, 可以選擇\n \l可以看到hostname和tty登錄信息

/etc/issue – escape code

The issue-file (/etc/issue or the file set with the -f option) may contain certain escape codes to display the system name, date and time etc. All escape codes consist of a backslash (\) immediately followed by one of the letters explained below.

\b : Insert the baudrate of the current line.
\d : Insert the current date.
\s : Insert the system name, the name of the operating system.
\l : Insert the name of the current tty line.
\m : Insert the architecture identifier of the machine, eg. i486
\n : Insert the nodename of the machine, also known 
as the hostname. \o : Insert the domainname of the machine. \r : Insert the release number of the OS, eg. 1.1.9. \t : Insert the current time. \u : Insert the number of current users logged in. \U : Insert the string1 user” or “ users” where is the number of current users logged in. \v : Insert the version of the OS, eg. the build
-date etc.
4. 如何查看系統的登錄信息和一些操作log?

/var/log/auth.log

[小技巧]Linux的一些信息獲取