The IP address is displayed before logging on to the Ubuntu console.

Source: Internet
Author: User

Before logging on to the Ubuntu console, the IP address is displayed. to log on to Ubuntu in VMware through PuTTY in Windows, you must first know the IP address of Ubuntu. If DHCP is used, the IP address may be different from the previous login. Is there a way to display the IP address in the prompt before logon? The answer is yes. The prompt message before logon is from the/ertc/issue file. The system version, host name, and logon port are displayed by default. The file content is as follows: Ubuntu 12.04.2 LTS \ n \ l is shown as follows: Ubuntu 12.04.2 LTS ubuntu tty1 we can modify this file to display other information, for example, kernel version, current date and time, and computer domain name. These are all very simple. You only need to insert a corresponding conversion code. However, it is not so easy to display the IP address of a computer. We must find a way to get the IP address information. The following command can get the IP Address: /sbin/ifconfig | grep "inet addr" | grep-v "127.0.0.1" | awk '{print $2}' | awk-F: '{print $2}' but how can I add the obtained IP address to the/etc/issue file? First copy the original/etc/issue file and save it $ sudo cp/etc/issue-ori and then create a new one under the/etc/network/if-up.d/directory script file, the content is as follows :#! /Bin/sh if ["$ METHOD" = loopback]; then exit 0fi if ["$ MODE "! = Start]; then exit 0fi cp/etc/issue-ori/etc/issue/sbin/ifconfig | grep "inet addr" | grep-v "127.0.0.1" | awk '{print $2 }' | awk-F: '{print $2}'>/etc/issueecho "">/etc/issue. This is done. The next time you start Ubuntu, the IP address is displayed before the logon prompt. With this IP address, you can log on through PuTTY.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.