猜测如何简单快速地获得它,我确实写下了一个小的 BASH 批处理程序。要使用它,只需复制下面的代码并将其粘贴到文本编辑器中,将其保存到您喜欢的文件中〜/箱文件夹,别忘了制作它可执行文件。
它首先从几个命令(uname
、、lsblk
等等)输出收集信息,然后组织它们显示在终端窗口中。
如果从终端窗口启动,它还可以将这些信息获取到文本文件中,以供进一步使用,而不是从 ALT+F2 对话框启动。
请注意,对于 XDG_CURRENT_DESKTOP env varianle 和xfce4-about
,您可能需要用您自己的桌面环境的命令来替换它。
希望这对大家有帮助。
答案1
以下是代码:
#!/bin/bash
# ---------------- clear window
clear
# ----------------set color vars
export CYoGY="\e[1;34;40m"
export CYoBK="\e[1;34;34m"
export BLoGY="\e[1;34;40m"
export BLoBK="\e[0;34;34m"
export YEoBK="\e[1;30;33m"
export YEoGY="\e[1;33;40m"
export WHoGY="\e[7;37;40m"
# ---------------- save current prompt
export oldprompt=$PS1
printf "$BLoGY"
echo -ne $CYoGY
printf "\e[1;1H-------------------------- GG procedure -----------------------\n"
#--------------- initialize system specs vars
export HostNode=$(hostnamectl)"\n"
export Tnode=$(uname --nodename)"$BLoGY - which FQDN is $YEoBK $(hostname -f)$YEoBK "
export Tkernel=$(uname -s) ### print the kernel name
export Tkrel=$(uname -r) ### print the kernel version
export Tkver=$(uname -v) ### print the kernel release
export Tmachhw=$(uname -m) ### print the machine hardware name
export Tproctyp=$(uname -p) ### print the processor type
export Thwplat=$(uname -i) ### print the hardware platform
export Theos=$(uname -o) ### print the operating system
#
export Thedesk="$(echo $DESKTOP_SESSION)\t"
export Thedesk+="$(env | grep XDG_CURRENT_DESKTOP)"
export XfceV="$(xfce4-about -V | grep about)"
#
export TheHW=$(lshw -disable isapnp -c cpu -c video -c network -short -quiet)
#
export SysRel1=$(lsb_release -cs)
export SysRel2=$(lsb_release -is)
export SysRel3=$(lsb_release -ds)
export SysRel4=$(lsb_release -rs)
# ---------------- launch terminal window
xterm -T "System ID" +cm -fa "Monospace" -fs "12" -geometry "90x51+450+5" -bw "0" -e '
# ---------------- go showing results, printing labels firstly
#
printf "$WHoGY\e[1;1H**** Actual system ***************************** \e[0m"
printf "$CYoGY\e[2;10H Host Node $YEoGY\e[2;20H$HostNode"
printf "$CYoGY\e[11;1H node hostname is: $YEoGY\e[11;22H $Tnode"
printf "$CYoGY\e[12;1H kernel version is: $YEoGY\e[12;22H $Tkver"
printf "$CYoGY\e[13;1H machine hardware is: $YEoGY\e[13;22H $Tmachhw"
printf "$CYoGY\e[14;1H processor type is: $YEoGY\e[14;22H $Tproctyp"
printf "$CYoGY\e[15;1H h/w platform is: $YEoGY\e[15;22H $Thwplat"
#--------------- show system specs on screen
echo -ne "$CYoGY "
printf "$WHoGY\e[17;1H**** OS SPECS ******************************** \e[0m"
printf "$CYoGY\e[18;1H Operating system is: $YEoGY\e[18;22H $Theos"
printf "$YEoGY\e[19;39H $XfceV"
printf "$CYoGY\e[19;1H Desktop env. is: $YEoGY\e[19;22H $Thedesk"
printf "$CYoGY\e[20;2HDistro codename:\e[20;22H$YEoGY $SysRel1"
printf "$CYoGY\e[21;2HDistributor ID:\e[21;22H$YEoGY $SysRel2"
printf "$CYoGY\e[22;2HDescription:\e[22;22H$YEoGY $SysRel3"
printf "$CYoGY\e[23;2HRelease:\e[23;22H$YEoGY $SysRel4"
#
printf "$WHoGY\e[25;1H**** Main system devices (lshw) *********************** \e[0m"
printf "$BLoGY\e[26;2H $YEoGY$TheHW\n"
#
printf "$WHoGY\e[1B**** Block devices List (lsblk - loops excluded) ************** \e[0m"
printf "$YEoBK\e\n$YEoGY"
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,UUID -e7
# >>--------------------------------------↑↑ exclude LOOPS block devices (7) from listing
printf "$BLoGY----------------------------------------------------------------------------\a\e[0m\r\n"
printf "\e[5;32;40mpress a key to terminate ..."
read -n1
set PS1="$oldprompt"]
# --- wait for a key press to terminate and close window
# read -n1
' &
#*** end of command to be executed in the terminal window
###
Answer1=""
printf "\033[1;44;33mYou can get also an OUTPUT into a FILE\n Do you want it (y/N)? \e[0m\n"
read -n1 Answer1
clear
case $Answer1 in
[yY] ) echo -e $"\n Writing file ...";
Tnode="node hostname is: $(uname -n) - which FQDN is $(hostname -A)"
Tkernel="kernel name is: $(uname -s)"
Tkrel="kernel-release is: $(uname -r)"
Tkver="kernel version is: $(uname -v)"
Tmachhw="machine hardware is: $(uname -m)"
Tproctyp="processor type is: $(uname -p)"
Thwplat="h/w platform is: $(uname -i)"
Theos="operating system is: $(uname -o)"
#
Thedesk="desktop env. is: $(echo $DESKTOP_SESSION) - "
Thedesk+="$(env | grep XDG_CURRENT_DESKTOP)"
#
SysRel1="Distributor ID: $(lsb_release -cs)"
SysRel2="Description: $(lsb_release -is)"
SysRel3="Release: $(lsb_release -ds)"
SysRel4="Codename: $(lsb_release -rs)"
# ---
# ---------------- save current values to a file
echo -e "saving results in 000.txt file ...."
echo "------------------------ Actual system description ------------------------" > 000.txt
echo "$Tnode" >> 000.txt
echo "$Tkernel" >> 000.txt
echo "$Tkrel" >> 000.txt
echo "$Tkver" >> 000.txt
echo "$Tmachhw" >> 000.txt
echo "$Tproctyp">> 000.txt
echo "$Thwplat" >> 000.txt
echo " ">> 000.txt
echo "-------------------------------- OS specs --------------------------------">> 000.txt
echo "$Theos" >> 000.txt
echo "$Thedesk" >> 000.txt
echo "$SysRel1" >> 000.txt
echo "$SysRel2" >> 000.txt
echo "$SysRel3" >> 000.txt
echo "$SysRel4" >> 000.txt
echo " ">> 000.txt
echo "-------------------------- Main system devices ---------------------------">> 000.txt
echo "$TheHW" >> 000.txt
echo " ">> 000.txt
echo "--------------------------- Block devices mount --------------------------">> 000.txt
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,UUID >> 000.txt
echo -e " .... 000.txt file saved, press a key to view it and finish"
read -n1
ggedit 000.txt
;;
* ) ;;
esac
echo -e $"\n"
Answer1=""
exit 0
#end