Get the App
SLTechnology News&Howtos  ›  Servers  › 

Customize your own shell login script

Shulou Source: shulou.com Published: 2022-06-03 07:33:09 10月27日 Update

Edit the .bash _ profile file under your own user

# .bash _ profile

# export

PS1= "\ n\ e [1Trac32m [\ e [0trans31m\ u\ e [0Tract34m @\ e [0trans31m\ h\ e [1ut32m]\ e [1transfer32m [\ e [0trans34m\ w\ e [1umbent 32m] $"

# Get the aliases and functions

If [- f ~ / .bashrc]; then

. ~ / .bashrc

Fi

# User specific environment and startup programs

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/bin/:/usr/local/bin:/usr/sbin:/sbin

Export PATH

Unset USERNAME

Umask 022

# Custom DJRavine Modification

Login_pwd= `pwd`

Login_data= `date`

Login_users= `users`

Logic_uptime= `uptime`

Server_ip= `/ sbin/ifconfig | grep 'inet addr:' | grep-v' 127.0.0.1'| head-1 | cut-d:-f2 | awk'{print $1}'`

Disk_available=$ (df-h-- block-size=1024 | awk'{sum + = $4;} END {print sum;}')

Disk_used=$ (df-h-- block-size=1024 | awk'{sum + = $3;} END {print sum;}')

Disk_size=$ (df-h-- block-size=1024 | awk'{sum + = $2;} END {print sum;}')

Disk_available_gb=$ (echo "scale=2; $disk_available/ (1024 ^ 2)" | bc)

Disk_used_gb=$ (echo "scale=2; $disk_used/ (1024 ^ 2)" | bc)

Disk_size_gb=$ (echo "scale=2; $disk_size/ (1024 ^ 2)" | bc)

Red= "\ 033 [31m"

Blue= "\ 033 [34m"

Green= "\ 033 [32m"

Echo-e ""

Echo-e "${blue} +--"

Echo-e "${green} Welcome!"

Echo-e "${blue} +--"

Echo-e "${green} Server IP: ${red}" $server_ip

Echo-e "${green} Date: ${red}" $login_data

Echo-e "${green} Users: ${red}" $login_users

Echo-e "${green} Directory: ${red}" $login_pwd

Echo-e "${green} Uptime: ${red}" $logic_uptime

Echo-e "${blue} +--"

Echo-e ""

Df-lh | column-c 6 | awk'{printf "\ 033 [22 × 32m% s\ t% s\ t\ 033 [22better31m% s\ t% s\ t% s\ n", $1meme 6m 5m 5'

Echo-e "${green} Total Disk Space: ${red} $disk_size_gb GB"

Echo-e "${green} Total Used Space: ${red} $disk_used_gb GB"

Echo-e "${green} Total Free Space: ${red} $disk_available_gb GB"

Echo-e "${blue} +--"

PATH=$PATH:$HOME/bin

Export PATH

Tags: Files users scripts login Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Shulou Technology Redmi Docker