Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The server I administrate, inconveniently enough, has a dynamic IP address assigned by DHCP. The convenient counterbalance, though, is that it happens to be set up about two feet from where I sit. I know how to edit /etc/issue to show different values before the login prompt is delivered to the display, but I'd like to know if it's possible for /etc/issue to display the current IP address of eth0 (re-evaluated at boot time) so that I can see it and then ssh in without having to log in to run ifconfig.

share|improve this question
Can conky be used in the login screen? If so you could make all sorts of info handy. – dibs Nov 15 '12 at 1:07
up vote 7 down vote accepted

/etc/issue is unfortunately a plain text, it has some options you can add to it (see man agetty) but not the IP address of eth0.

If you put this in /etc/rc.local:

IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
echo "eth0 IP: $IP" > /etc/issue

Then you will see something like this:

myServer login:
share|improve this answer
Works flawlessly! Thanks. – ssonicblue Nov 16 '12 at 7:12
Please note for anyone running this, this will overwrite the contents of /etc/issue. You could add steps to grep out the previous "eth*" lines and then append them. – Rebs Mar 16 at 22:57

Building on Alex's answer and Rebs' comment, this is what I have for my /etc/rc.local file (only relevant lines):

PRE_MSG="Ubuntu 14.04.3 LTS" # this is from the original /etc/issue

IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')

IP_MSG="Server IP Address:"

printf "%s %s %s\n\n%s %s\n\n" "$PRE_MSG" '\n' '\l' "$IP_MSG" "$IP" > "/etc/issue"

The printf command does the magic. Unfortunately putting the '\n' and '\l' inside the format string ended up replacing the first one with the new line character and the /etc/issue file was messed up.

So long story short, these 4 lines keep the original info displayed by /etc/issue file and add the Server IP Address: message.

And as Rebs' said, keep in mind that every time you reboot the server, this script will override the /etc/issue file, so maybe try it inside a different script and on a different file and once it's working, transfer the changes over...

Good luck and happy BASHing :)

share|improve this answer

As of Debian 8/jessie you can use the \4 and \6 escape characters to output the IPv4 and IPv6 addresses. So the /etc/issue file:

Debian GNU/Linux 8 \n \l

eth0: \4{eth0}

Would output something like the following at the login console:

Debian GNU/Linux 8 myserver

myserver login:

I imagine Ubuntu would provide similar functionality (at least in newer releases)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.