如何在linux shell的提示符中显示IP
如何在linux shell的提示符中显示IP
2008-05-13 15:30 joomla 178 次点击 Tags: 显示提示当前用户字符
经常在各台linux服务器之间切换,有时会弄不清自己在那台服务器上,当然可以把机器hostname设置为IP,并在PS1环境变量中,将 \h 改为 \H ,但是对于那些已经在使用的服务器,你可能不清楚是否能够修改hostname,那么就可以在/etc/profile ,或者 .bash_profile中设置,来在shell提示符中显示IP,具体代码如下:
PS1="\[\e[32;1m\]`/sbin/ifconfig eth0 | grep "inet addr" | sed -e 's/^.*inet addr:\(.*\) Bcast.*$/\1/'`\[\e[0m\][\u \W]\$ "export PS1
http://www.maycode.com/index.php/hotspot/35-linux/722-linux.html
他们设置了哪些标签:
Collect Command learn Linux
谁收藏了这个网址:
使用标签:learn, collect, linux, Command,时间:2008-5-23 11:01:54 | 相关网摘
如何在linux shell的提示符中显示IP
2008-05-13 15:30 joomla 178 次点击 Tags: 显示提示当前用户字符
经常在各台linux服务器之间切换,有时会弄不清自己在那台服务器上,当然可以把机器hostname设置为IP,并在PS1环境变量中,将 \h 改为 \H ,但是对于那些已经在使用的服务器,你可能不清楚是否能够修改hostname,那么就可以在/etc/profile ,或者 .bash_profile中设置,来在shell提示符中显示IP,具体代码如下:
PS1="\[\e[32;1m\]`/sbin/ifconfig eth0 | grep "inet addr" | sed -e 's/^.*inet addr:\(.*\) Bcast.*$/\1/'`\[\e[0m\][\u \W]\$ "export PS1