Adding information about the IP address of a linux machine to the login prompt
Things to know
Getting the IP address
The IP address for the current machine can be obtained entering the following command:
There are some default scripts run after particular events.
The one I want (after startup) it’s located in
Login prompt message
The login message it’s handled by the agetty command and documentation about it can be found using
The agetty command displays and interprets the content of the
Mixing all this togheter
At startup I need to get the IP address of the machine and append it to the issue file to be printed out at the login screen.
First thing to do is to create a copy of the
This can be done with the command:
sudo cp /etc/issue /etc/issue.base
The next thing to do is to edit the
/etc/rc.local file to:
- gather the current IP address
/etc/issue.base back to
- append to
/etc/issue a new line with a string like
IP address: xxx.xxx.xxx.xxx
This can be done editing the original
/etc/rc.local that should look like this:
To look like this:
After a reboot the login prompt should look like this:
Ubuntu 16.04.1 LTS ubuntu-base-vm tty1
IP Address: 192.168.1.5
I came across a funny issue on utils (available here) today, basically 2 unit tests were not executed by Apache Maven on Travis CI.
It’s funny beacause it happened to me before, so I knew how to fix this problem.
On my machine I usually run JUnit tests with the JUnit plugin integrated into the Eclipse IDE because it’s nice, green/red, failure log, stacktrace and stuff.
Instead, when calling from the command line
mvn test, Maven uses the maven-surefire-plugin to execute the tests. In its documentation it says that the default configuration, which I can’t be bothered to change, is to pick up every file name that matches this expressions:
A typo like NullCheckerTests, instead of NullCheckerTest prevents the tests in the class from being executed because the class it’s just ignored during test execution.
The solution it’s easy, following naming conventions, I think it’s nice to call all my test with an ending *Test in the name of the file and class, after all if you’re declaring an xxx test class, so it should be called
XxxTest in a file named
An example of the problem and the relative solution can be found here.
I thought that sharing this issue could be useful if anybody encountered the same problem.
By the way, because of this issue I released version 1.0.5 of utils.