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 pushed some changes to https://github.com/scompo/stellaris-launchpad-template-gcc .
I basically fixed some compile warnings, cleaned up the makefile (thanks wollow) and used a dinamic stack allocation.
I’ve been playing around a lot with the Stellaris Launchpad board, looking around the stuff I never noticed that the besides the fact of being licensed with a BSD style license, the Stellarisware SW provided by Texas Instruments has a closed license for the various examples.
The basic files needed to create a program for the board, and basically for all the ARM processors are the following with binutils and gcc:
- The program you want contained in a .c file.
- A linker script due to the fact you don’t have an operating system running.
- A startup code file that zeroes the .bss segment variables, copies the .data segment to ram and setups the NVIC vector table.
- A Makefile to build everything easily.
The program and the Makefile can be done with not much worries, but the linker script and the startup code are quite difficult, at least for me, to understand and set up properly.
So I ended up building from scratch the whole files needed and licensed them with a BSD license (Basically, do what you want with them, just give me credit I’m happy if someone find them useful, you can contribute, but don’t blame me if it doesn’t work lol)
You can find them in this Github repository
Continue reading “A lot of stuff learned!”