Skip to content
  • Home
  • Contact Us
  • About Us
  • Privacy Policy
  • DMCA
  • Linkedin
  • Pinterest
  • Facebook
thecscience

TheCScience

TheCScience is a blog that publishes daily tutorials and guides on engineering subjects and everything that related to computer science and technology

  • Home
  • Human values
  • Microprocessor
  • Digital communication
  • Networking
  • Toggle search form
setting environment and path in linux

Environment and Path Setting in Linux

Posted on December 20, 2022January 29, 2023 By YASH PAL 2 Comments on Environment and Path Setting in Linux

Environment and Path Setting in Linux – Bash shell is used for various purposes under Linux. How do you customize the shell environment variable under Linux operating systems?


You can use shell variables to store data, set configuration options, and customize the shell environment under Linux. The default shell is Bash under Linux and can be used for the following purposes:

  1. Configure the look and feel of the shell.
  2. Set up terminal settings depending on which terminal you’re using.
  3. Set the search path such as JAVA_HOME, and ORACLE HOME.
  4. Set environment variables as needed by programs.
  5. Run commands you want to run whenever you log in or out.
  6. Set up aliases and/or shell functions to automate tasks to save typing and time.
  7. Changing bash prompt.
  8. Setting shell options.

You can use the following commands to view and configure the environment.

Table of Contents

  • Display Current Environment in Linux
    • Pathnames
    • Absolute Pathnames
    • Relative Pathnames

Display Current Environment in Linux

To display the current environment, type the following command:

$ set

BASH =/bin/bash
BASH_ARGC = ()
BASH_ARGV = ()
BASH_LINENO = ()


Note – There are other values available in the environment depending on your system. we are not displaying the whole values here.


The $PATH defines the search path for commands. It is a colon-separated list of directories in which the shell looks for commands. The $PS1 defines your prompt settings. see the list of all commonly used shell variables for more information. you can display the value of a variable using the printf or echo command.


$ echo “$HOME”
OR
$ printf”%s\n” $HOME

Sample output

/home/ram

You can modify each environmental or system variable using the export command. Set the PATH environment variable to include the directory where you installed the bin directory with Perl and shell scripts:


export PATH = $ { PATH)/home/ram/bin
OR
export PATH=${PATH}:${HOME}/bin


Pathnames

Every file has a pathname, which is a trail from a directory through part of the directory hierarchy to an ordinary file or a directory. Within a pathname, a slash (/) to the right of a filename indicates that the file is a directory file. The file following the slash can be an ordinary file or a directory file. The simplest pathname is a simple filename, which points to a file in the working directory.


Absolute Pathnames

An absolute pathname starts with a slash (/), which represents the root directory. The slash is followed by the file’s name located in the root directory.

setting environment and path in linux

An absolute pathname continues, tracing a path through all intermediate directories, to the file identified by the pathname. String all the filenames in the path together, following each directory with a slash (/). This string of filenames is called an absolute pathname because it locates a file absolutely by tracing a path from the root directory to the file.

The part of a pathname following the final slash is called a simple filename, or basename. the above figure shows the absolute pathnames of directories and ordinary files in part of a filesystem hierarchy.

environment and path setting in linux


Relative Pathnames

A relative pathname traces a path from the working directory to a file. The pathname is relative to the working directory. Any pathname that does not begin with the root directory (represented by /) or a tilde (~) is a relative pathname. Like absolute pathnames, relative pathnames can trace a path through many directories. The simplest relative pathname is a simple filename, which identifies a file in the working directory.

engineering subjects, linux Tags:engineering subjects, linux

Post navigation

Previous Post: Hard links and Symbolic links
Next Post: HackerRank Hello World! in C problem solution

Related Posts

Access Methods in Networking Digital communication
Natural Acceptance of Human Values engineering subjects
Sanyam and Swasthya in Human values engineering subjects
Types of Internet Layer Protocols Digital communication
input and output units in computer Input and Output units in computer computer fundamentals
Design of spherical dome to carry Load civil engineering

Comments (2) on “Environment and Path Setting in Linux”

  1. Tabuche says:
    January 31, 2023 at 10:49 AM

    Monitor Closely 1 tadalafil increases effects of esmolol by pharmacodynamic synergism how fast does accutane work

    Reply
  2. Tabuche says:
    February 1, 2023 at 5:03 AM

    lasix cheapest Endometriosis- Related infertility in case

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Pick Your Subject
Human Values

Copyright © 2023 TheCScience.

Powered by PressBook Grid Blogs theme