0% found this document useful (0 votes)
6 views2 pages

PE03-Environment Variables

This document outlines a practical exercise for students to learn about environment variables in a Linux OS. It includes steps to view, modify, and export environment variables such as $PWD, $HOME, $EUID, $PATH, and $PS1, as well as creating a new variable MYVAR. The exercise emphasizes the importance of understanding how to manipulate and examine environment variables within the Linux shell.

Uploaded by

ramiplan2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

PE03-Environment Variables

This document outlines a practical exercise for students to learn about environment variables in a Linux OS. It includes steps to view, modify, and export environment variables such as $PWD, $HOME, $EUID, $PATH, and $PS1, as well as creating a new variable MYVAR. The exercise emphasizes the importance of understanding how to manipulate and examine environment variables within the Linux shell.

Uploaded by

ramiplan2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 03 - Environment Variables

This Practical Exercise will take students through the use of environmental
variables in a Linux OS. This includes entries within, modifying and exporting a
modification of variables.
**Ensure you are in your home directory /home/yourlastname.**

1 - View the $PWD environment variable


echo $PWD
This another way of getting the same information as the pwd command.

2 - View the $HOME environment variable


echo $HOME
The results show the home directory of the user you are logged in as.

3 – View the $EUID environment variable


echo $EUID
This shows the ID number of the user account running the commands.

4 – View the $PATH environment variable


echo $PATH
This tells the shell which directories to search for executable files in response to
commands issued by a user.

5 – View the $PS1environment variable


echo $PS1
This defines the prompt used in your shell. This information is how your shell
prompt is displaying the currently logged-in user, the name of the Linux host, the
full path to the current working directory, and a colon.

6 - Change the shell prompt display to add the current time.


PS1='[\u@\h \t \w]:'

Page 1 of 2
PE03-Environment Variables
Now your shell prompt will display the currently logged-in user, the name of the
Linux host, the current time, the full path to the current working directory, and a
colon

7 - Examine ALL of the environment variables including globals, local and shell
options. ( | more will display the information one screen at a time)
set | more (hit the space bar to advance another screen full or the enter key
to advance on line at a time, hit the letter q to quit and go back to your prompt)

8 - Create a new environment variable called MYVAR with a value of 10


MYVAR=10

9 - Examine the contents of MYVAR with echo.


echo $MYVAR

10 - Examine ALL of the global variables


env | more You will not see MYVAR at this time because it is still an
environmental varriable.

11 - Make a custom variable global.


export MYVAR

12 - Run the env command again to see that MYVAR is now an exported global
variable.
env | more (you should see MYVAR=10 around the 10th line)

Page 2 of 2
PE03-Environment Variables

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy