Example:
Hostname: hostname command is used to print the hostname of your system.
To change the hostname ( I am changing hostname to node1) follow the following steps.
- sudo su
- hostname node1
- echo "node1" > /etc/hostname
- bash
Every user has its home directory, run the following command to find the home directory of logged in user
echo $HOME
Environment Variables: These are the variables that are defined globally on the system or user level.
For example, PATH is an environment variable, and to print the value of the PATH variable run the below command.
echo $PATH
To find all the environment variables run env command
env
How to Create an environment variable
export var_name=Value
export Name=Raman
env
How to remove the environment variable
unset var_name
unset Name
How to add a new path(/home/vagrant) to PATH variable
export PATH=/home/vagrant:$PATH
Experiment:-
- Find the value of the HOME env variable for the current user and root user.
- Create a shell script file and provide 777 permission to the file and check the PATH variable value and move it to any of the folders like (/usr/local/bin) and check that you can execute this file from any location of your system.
- Print all environment variables
- Create an env variable MVN and set value as "maven home"
- delete the MVN variable from the enviornment.
Create a directory test under /tmp directory
mkdir /tmp/test
Create a directory unitTest under /tmp/test/typesoFTesting
mkdir -p /tmp/test/typesoFTesting/unitTest
Check the current working directory
pwd
Change to unitTest directory and verify you are in unitTest directory
cd /tmp/test/typesoFTesting/unitTest
pwd
Change directory from unitTest to typesoFTesting directory
cd ..
Go back to /home/ubuntu directory
cd /home/ubuntu
pwd
Remove directory unitTest
rmdir /tmp/test/typesoFTesting/unitTest
COMMENTS