Question

Using Linux Create a custom banner that displays the following information when you log into your...

Using Linux

Create a custom banner that displays the following information when you log into your normal user’s shell (hint: edit ~/.bashrc):

“Hello USER” – (make use of the USER environment variable to get the username)

“Welome to HOSTNAME” (make use of the HOSTNAME environment variable)

System uptime

System’s private IP addresses (not full blown ifconfig output, but just a line for each interface that says “The IP address for ETHX is: XXX.XXX.XXX.XXX” – hint: use the grep and awk commands)

Public IP address of the system, (hint use the curl command on ip.appspot.com)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

copy these lines and paste it in the last line of your ~/.bashrc

echo HELLO $USER
echo WELCOME to $HOSTNAME
echo uptime | bash

for x in {1..10}
do
    p=$(ifconfig eth$x | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1;)
    echo "The IP Address for ETH$x is: $p"
done

dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{print $2}'

explanation:
$USER and $HOSTNAME are hostnames we can directly echo them. uptime is a bash command we are executing it. The next one is printing private addresses, here I am assuming there were up to 10 of eth devices, ifconfig eth$x will give the device details of eth1,eth2...eth10. Then we are doing a grep with string "inet addr" which contains our ip address. Below is the sample output of it

          inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0

In order to format it, we are using cut. "cut -d ':'" means, -d for delimeter ':', it returns a list ['inet addr', '192.168.0.10 Bcast','192.168.0.255 Mask','255.255.255.0'] that splits with ':', so we need to index it (index starts from 1), so we are using -f 2, so we get "192.168.0.10 Bcast". Again we need to split by space, so we are using "cut -d ' '", it returns list ['192.168.0.10', ' '], in this we need to get by index 1. so, it becomes "cut -d ' ' -f 1".

To find the public IP address, we can use dig command that looksup google dns.

 
Add a comment
Know the answer?
Add Answer to:
Using Linux Create a custom banner that displays the following information when you log into your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a Windows batch script. The batch script will contain the following: Ask the user interactively:...

    Create a Windows batch script. The batch script will contain the following: Ask the user interactively: Boot drive letter of the computer Computer name Computer Model Check to see if the boot drive in #1 exists with the folder newfolder (#1 above) If yes cd BootDrive\newfolder If no, make the directory BootDrive\newfolder Check to see if casefile.txt exists: If yes goto the label DONE Tell the user that data already exists in the newfolder folder and exit the program Output...

  • You will create a shell script that prints out the following information about the system it is run on: • The system’s n...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • You are to create and apply a firewall rule set on your Ubuntu server and each...

    You are to create and apply a firewall rule set on your Ubuntu server and each rule should be commented. Make sure to use variables for the IP addresses in your firewall. It's good practice and if I have to test one or more of your rules, I can replace the address in the variable. For any packets you REJECT or DENY, those should be logged. That means you'll need to modify the rule so that if the rule matches...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT