Question

In: Computer Science

Once you are in the Linux environment, perform the following steps: Set an environment variable for...

Once you are in the Linux environment, perform the following steps:

  • Set an environment variable for USER that holds the value of your name.

For this submission, you will write a BASH shell program that meets the following requirements:

  • Clear the screen.
  • Display to the user what the program will do and that the program is starting.
  • Display to the user the string “Hello“ and the value of the USER environment variable.
  • Output a blank line.
  • Display to the user a sentence to include the actual date of the day that it is when you run the program.
  • Output another blank line.
  • By using the Cut command, obtain the USER value and output only the first field, along with a sentence about who the user is.
  • Output another blank line.
  • Display to the user the uname value with a –s option, as well as the –m option to show the processor for the system.
  • Output another blank line.
  • Display to the user a sentence that includes the actual uptime of the system that you are running the program on.
  • Output another blank line.
  • Display a goodbye message to the user.
  • End the program.

Solutions

Expert Solution

Setting the environment variable $USER with the export command:

The script bashscript.sh is mentioned below. The important commands used in the script are:

  • echo -> To print messages on the terminal. echo "" prints a blank line.
  • clear -> To clear the terminal screen.
  • date +%F -> to display the today's date; shown in YYYY-MM-DD
  • cut -f1 -d " " -> cut takes the value of $USER and divides it into the columns based on the delimiter space(specified by -d " "), takes the first column (specified by -f1) and returns it. So, Jennifer is returned
  • uname -> -s shows the kernel name, that is Linux, and -m signifies the processor architecture, that is i686 at my VM.
  • uptime -> Command to show the uptime of the machine
  • exit -> To exit from the program

#!/bin/bash

clear

echo "########################################"
echo "This script will start now.."
echo "It will show the current user,"
echo "the system uptime, and the current time"
echo "along with the system type and "
echo "processor architecture of the machine"
echo "########################################"
echo ""


echo "Hello" $USER
echo ""
echo "The script is run on the date:" `date +%F`
echo ""
echo "Your first name is:" `echo $USER | cut -f1 -d " "`
echo ""
echo "The system name is:" `uname -s` "and the processor type is: " `uname -m`
echo ""
echo "The uptime of the system is:" `uptime`
echo ""

echo "GoodBye!!"
exit 1

The IDE screenshot is below:

Execution of the script after making it executable with chmod + x bashscript.sh


Related Solutions

In LINUX Provide the command(s) and any additional steps to perform the following tasks. You will...
In LINUX Provide the command(s) and any additional steps to perform the following tasks. You will need to be running with root privileges. Create a symlink to the /etc/openldap/ directory named "ldapconf" in /tmp/. Find all .conf files in the /etc/ directory and its subfolders. Find all directories starting with "gnome" or "GNOME" anywhere under the /usr/share/ directory. Sam and Susan are members of the "sales" group. Sam has been working on a project that has grown too big for...
linux To install packages you will need root privelages. To temporarily perform an action with root...
linux To install packages you will need root privelages. To temporarily perform an action with root privileges you use the sudo command demonstrated in item 6 below. In your own words, explain the purpose of the sudo command and why sudo is a better choice than logging in as the root user. Make sure your package listings are up to date by running the following command. $sudo apt-get update When this command is done you will see a line that...
An organization has decided to move from a windows server environment to a Linux Server Environment....
An organization has decided to move from a windows server environment to a Linux Server Environment. The organization requires to offer email, web, fileshare, printing services to its users which are predominantly using MAc OS and windows clients. These services would be provisioned from the newly created Linux server. a) Outline some of the issues the system administrator needs to consider when designing the solution? b) How would you resolve the issues ? c) What tools would you use in...
Upgrade your UBUNTU Linux system and document the steps that you took. What events, if any,...
Upgrade your UBUNTU Linux system and document the steps that you took. What events, if any, were logged? Next, search the repositories for the application nginx. If it’s not installed, install it. Document the steps you took.
[Linux permissions] Suppose that you are a superuser on a Linux system, and there is a...
[Linux permissions] Suppose that you are a superuser on a Linux system, and there is a file “/home/alice/foo”, which is owned by an ordinary user Alice. You need to give a permission to read a this file to an ordinary user Bob, but no one else (of course, you as superuser will be able to read it too). Explain how you will do it. Note: You do not have to provide specific commands, just a short description will suffice. [Limitations...
[Linux permissions] Suppose that you are a superuser on a Linux system, and there is a...
[Linux permissions] Suppose that you are a superuser on a Linux system, and there is a file “/home/alice/foo”, which is owned by an ordinary user Alice. You need to give a permission to read a this file to an ordinary user Bob, but no one else (of course, you as superuser will be able to read it too). Explain how you will do it. Note: You do not have to provide specific commands, just a short description will suffice.
Perform a common analysis used to compare means for Exam Anxiety in students: Once you have...
Perform a common analysis used to compare means for Exam Anxiety in students: Once you have retrieved your data set, go to Analyze, then Compare Means, then Independent Samples t-test. Conduct a compare means analysis using an independent samples t-test in SPSS. The grouping variable for Exam Anxiety in students will be gender, grouped as (1, 2).
What are the next steps once you have an isolated colony to determine the bacteria growing...
What are the next steps once you have an isolated colony to determine the bacteria growing in that colony? (These are some of the I’s – selective media what might you suggest?)
Steps to Complete the Week 6 Lab Find this article in the Chamberlain Library. Once you...
Steps to Complete the Week 6 Lab Find this article in the Chamberlain Library. Once you click each link, you will be logged into the Library and then click on "PDF Full Text". First Article: Confidence Intervals, ( I copied and pasted both articles at the bottom of this question). 1. Consider the use of confidence intervals in health sciences with these articles as inspiration and insights. 2. Describe how you could use confidence intervals to help make a decision...
You are a small biotechnology firm and need the financialsupport and the set-up to perform...
You are a small biotechnology firm and need the financial support and the set-up to perform clinical trials on your formulas, what might be your best, and least risky, source of funding? Why?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT