Question

I need help with the following Linux bash assignment: Display the value of all environment variables...

I need help with the following Linux bash assignment:

Display the value of all environment variables to the screen.

Add a temporary environment variable called Semester with a value of Spring to your currently running shell only.

Modify your .bashrc file to create an environment variable called CLASS with a value of "CIS 220" that is available to all processes.

Modify your .bashrc file to add $HOME/scripts to your path without removing any other items from your path.

Modify your .bashrc file to add an alias named howmany that will use the who command to print the login names and a count of the currently logged in users. (Use the who man page to see how to do this.)

Modify your .bashrc file to add a function named newdir that will make a new directory AND set it as the current working directory. It should get the directory name via a parameter.

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

Display the value of all environment variables to the screen : Use the printenv command

Add a temporary environment variable called Semester with a value of Spring to your currently running shell only.:

export Semester = Spring

Modify your .bashrc file to create an environment variable called CLASS with a value of "CIS 220" that is available to all processes.

vim ./bashrc

Add : export CLASS="CIS 2020"

source ./bashrc

Modify your .bashrc file to add $HOME/scripts to your path without removing any other items from your path.

vim ./bashrc

export PATH = $PATH:$HOME/scripts

source ./bashrc

Modify your .bashrc file to add an alias named howmany that will use the who command to print the login names and a count of the currently logged in users.

vim ./bashrc

alias howmany = 'who -q -H'

source ./bashrc

Add a comment
Answer #2

#Display the value of all environment variables to the screen.Type the below command on the screen:

env

#------------------------------------------------

#Add a temporary environment variable called Semester with a value of Spring to your currently running shell only

export Semester="Spring"

echo $Semester

#------------------------------------------------

# The rest of the assignment requires changes to .bashrc
# In your home directory, open the .bashrc file using vim
cd
vi .bashrc

#------ Add everything below to your .bashrc file ------------

#Modify your .bashrc file to create an environment variable called CLASS with a value of "CIS 220" that is available to all processes.

export CLASS="CIS 220"

#Modify your .bashrc file to add $HOME/scripts to your path without removing any other items from your path.

export PATH=$PATH:$HOME/scripts

#Modify your .bashrc file to add an alias named howmany that will use the who command to print the login names and a count of the currently logged in users. (Use the who man page to see how to do this.)

alias howmany='who -u; echo "The number of logged in users is `who | wc -l` " '

#Modify your .bashrc file to add a function named newdir that will make a new directory AND set it as the current working directory. It should get the directory name via a parameter.

function newdir()
{
newCurrDir="$1"
if [[ -d "$newCurrDir" ]]
then
echo "$newCurrDir : Directory already exists. Will change to it anyway"
else
mkdir -p "$newCurrDir"
cd "$newCurrDir"
echo "Changed Directory to `pwd` "
fi
}

#------ Save the .bashrc file and exit. Open a new terminal and log in

#-------------------- How to test -------------------------

# In your new terminal, type the below commands one by one:
echo $CLASS

echo $PATH

howmany

newdir "This_be_me_new_dir"

# A new dir called This_be_me_new_dir is created and the current dir will be changed to it
# On your screen, you will see something similar to the following:

Add a comment
Know the answer?
Add Answer to:
I need help with the following Linux bash assignment: Display the value of all environment variables...
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
  • In Linux we are doing environment variables:   Display value of all environment variables to the screen....

    In Linux we are doing environment variables:   Display value of all environment variables to the screen. Add a temporary environment variable called Semester with a value of Fall to your currently running shell only. Modify your .bashrc file to create an environment variable called CLASS with a value of "CIS 220" that is available to all processes. Modify your .bashrc file to add $HOME/scripts to your path without removing any other items from your path.

  • This is done in Linux terminal. Modify the .bashrc file using command line which would add...

    This is done in Linux terminal. Modify the .bashrc file using command line which would add the following functionality to your shell upon opening a new terminal: 1. Alias called “fc” (short for “folder contents) invoking the command “ls -lah”B. Welcome message “This is demo number 7” C. Variable “semester” being equal to “Winter 2020” and print the value on screen 2. Create any directory of your choice and add it to PATH variable. 3. Show an example of local...

  • Hi I beed this assignment to be in a script in linux from codio. Can someone...

    Hi I beed this assignment to be in a script in linux from codio. Can someone please help me step by step thank you. Overview: In this milestone, you will demonstrate your ability to create a basic script in Linux. Review the Final Project Guidelines and Rubric document to see how this milestone will prepare you for the scripting portion of the project. You will perform this milestone in Codio in the unit called “Milestone 2: Scripting.” You will create...

  • I need help with this. 10-21. Briefly describe the following Linux commands and acronyms. ssh: telnet:...

    I need help with this. 10-21. Briefly describe the following Linux commands and acronyms. ssh: telnet: traceroute: TCP: LAN: DNS: ftp: ssh: ping: env: g++: gcc: 22. Show a command that will create a file named "etc.tar" in your home directory from recursively going through all of the files in the "/etc" directory. In other words, the "etc.tar" file will include the files in the "/etc" directory as well as all of its subdirectories. IMPORTANT: This command must work for...

  • Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell...

    Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell variables, and .profile script file, echo SHELL, HOME, PATH, MAIL and TERM are predefined shell variables. You can use the value of a shell variable in a shell command putting $ in front of it. For example, to display the value of the HOME directory of the user, specify $HOME in the echo command like echo $HOME. Do not give just the value of...

  • I need help with my homework assignment Linux systems keep user account information in the passwd...

    I need help with my homework assignment Linux systems keep user account information in the passwd file and the encrypted password in the shadow file. The passwd file containing account information might look like this: smithj:x:1001:1001:John Smith:/home/smithj:/bin/bash The shadow file containing password and account expiration information for users might look like this: smithj:KJDKKkkLLjjwlnttqoiybnm.:10063:0:99999:7::: The fields in the shadow file are separated by a colon, with the first field being the username and the second being the password. Under normal circumstances,...

  • i need help with this scripting assignment in power shell thanks Lab 7: PowerShell Search and...

    i need help with this scripting assignment in power shell thanks Lab 7: PowerShell Search and Report Search Report host path date Execution time nnn Directories n, nnn, nnn Files nnnnnnn Sym links nnnnnnn Old files nnnnnnn Large files nnnn, nnn Graphics files nnnnnnn Executable files nnnnnnn Temporary files n, nnn, nnn TotalFileSize nnnn, nnn Introduction Lab 7 is nearly identical to Lab 2, except it is written in PowerShell, uses no UNIX/Linux tools to do its work, creates no...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

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