Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thanks but what I want to do is to add a little IP information
in the /etc/issue file in my situation which several servers
share a single monitor through a switcher, and all machines
have the same text mode login screen, confuses users
occasionally.
and... upon adding that $my_ip to /etc/issue, what thing do i have to restart so the change takes effect without rebooting? Thanks big time once again in advance.
Originally posted by kdnt Yes it works. Thanks born4linux!
But, sorry for my ignorance.... where does the printenv output
sits? Want to hardcode the definition of my_ip into the system.
Thanks again.
The question is a little vague. If you are asking how to make the system IP an environment variable, then you could take the code that born4linux gave you and add it to your /etc/profile. Make sure to export the variable as well. Best practice is to make any env vars in all caps (i.e. MY_IP instead of my_ip).
yes thanks jeremiah. "/etc/profile" is what I want. And how to make the changes effective without rebooting? I did all you
experts said, but upon loading up another terminal and establishing connection (I'm doing all in secureCRT and have root permission) the change didn't show up. And what does "export the variable" mean? Thanks again.
Shown above is how you can export the variable. This is done to make it available to all logged in users.
To make the IP show up on the login screen, you would want to add the IP into the file /etc/issue. There is no need to reboot or restart anything. All future connections will read this file when they make the connection.
You won't be able to use the $MY_IP inside the /etc/issue file though, because the /etc/profile is not read until after login. Whereas the /etc/issue file is read before login.
Another way if your IP address is static, and you've got network access at boot and you only need it for/etc/issue you process it this way as well. Add this line to for instance to rc.local, (w/o outer quotes) after any other lines that change issue: "host $(hostname) | awk '{print "Our IP address is:", $4}' >> /etc/issue"
If your IP address changes often then you better to add the line to the script that runs after you re-establish your connection.
You could also try "host $(hostname) | awk '{print "MY_IP=",$4}' > /etc/.myip" and pick it up in profile using if [ -f "/etc/.myip" ]; then . /etc/.myip; else MY_IP="unknown"; fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.