[go: up one dir, main page]

0% found this document useful (0 votes)
14 views29 pages

GROUP 04 Programming-1

The document discusses the shell environment in Linux, focusing on environment variables, configuration files, and path management. It explains common environment variables, how to customize them, and the significance of configuration files for global and user-specific settings. Additionally, it covers path management, including viewing and modifying the PATH variable to streamline command execution.

Uploaded by

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

GROUP 04 Programming-1

The document discusses the shell environment in Linux, focusing on environment variables, configuration files, and path management. It explains common environment variables, how to customize them, and the significance of configuration files for global and user-specific settings. Additionally, it covers path management, including viewing and modifying the PATH variable to streamline command execution.

Uploaded by

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

GROUP 04

BB 3106: PROGRAMMING IN BIOINFORMATICS.


QUESTION.
The shell environment in Linux is critical topic as it
defines how user interact with a system via the
command line discuss the shell environment and
configuration based on the following aspects
 Environment variables: Common Environment
Variables, Customizing variables.
 Configuration files: Global configuration, User
Configuration, Startup script.
 Path management.
Shell.
• The shell is a program that takes keyboard
commands and passes them to the operating
system to carry out.
• The shell enables users to execute commands,
run scripts and configure the environment to
suit their workflows.
• The shell environment Linux is an essential aspect of
how users interact with the operating system via the
command line
• There are several aspects that can be considered
in understanding the shell environment and
configuration, they include
i. Environmental variable.
ii. Configuration files.
iii. Path management.
i. Environmental variable.
• The environmental variables are key value pairs
used by the shell and applications to store
information about the system environment.
• They influence the behavior of processes and
commands in the shell.
• Variables provide critical information about the
system and user environment.
Common Environmental variables.
These variables include:
 PATH: Specifies directories, the shell searches for
executable files.
• Example command: echo $PATH output:
/usr/local/bin:/usr/bin:/
 HOME: Points to the user’s home directory.
• Example command: echo $HOME output:
/home/username.
 USER: Holds the username of the current user.
Example command:
• whoami output: username.
• echo $USER output: username.
 SHELL: Specifies the user’s default shell.
• Example command: echo $SHELL output:
/bin/bash
 LANG: determines the system’s language and
locale settings
• Example command: locale output:
en_US.UTF-8
 PWD: represents the current working directory
• Example command: pwd output:
/home/username
Customizing variables.
• Refers to the process in which users define their
own environmental variable to meet specific
requirements.
• For instance, the HISTSIZE value can be
modified from 500 or 1000 by default to meet
the user specific requirements
• Customizing command:
export HISTSIZE=”2000” To check the value of
custom variable we use command: echo
$HISTSIZE output: 2000
Saving changes
• The changes made by customizing variables can be
saved to the shell in file .bashrc by using the command;
echo 'export HISTSIZE=2000'>>~/.bashrc
Activating Our Changes
• The changes we have made to our .bashrc will not take
effect until we close our terminal session and start a
new one because the .bashrc file is only read at the
beginning of a session.
• However, we can force bash to reread the
modified .bashrc file with the following command:
source ~/.bashrc ( Shotts, 2019)
ii. Configuration files.
• Configurations files are files used to customize
the behavior of the shell for both global and
user-specific settings.
• These configuration files include,
global configuration.
user configuration and
startup scripts.
Global configurations.
Are configurations files located /etc and apply to
all users. Examples of common global
configuration files;
• /etc/profile: Sets system-wide environment
variables and startup programs.
• /etc/bash.bashrc: Contains configurations for
interactive shell sessions.
User configuration.
Are files located in the user’s home director and
affect only that user.
Examples of common user configuration files;
• bashrc: Contains configurations for non-login
interactive shells.
• bash_profile or .profile: Used for login shells;
executes once during login.
• zshrc: Similar to .bashrc but for the Z shell (Zsh).
• bash_logout: Executes commands when the user
logs out.
Startup scripts.
Are series of configuration scripts which define
the default environment shared by all users.
• When we log on to the system, the bash program
starts, and reads startup scripts, this is followed
by more startup files in our home directory that
define our personal environment.
• The exact sequence depends on the type of shell
session being started.
• There are two types of these session
a. A login shell session, is one in which we are
prompted for our username and password. This
happens when we start a virtual console session,
• For login shells, the startup files include;
/etc/profile, .bash_profile, .profile, or .login.
b. A non-login shell session, typically occurs
when we launch a terminal session in the GUI.
• For non-login interactive shells, the startup
files include; /etc/bash.bashrc, bashrc.
iii. Path management.
• The PATH environment variable is crucial in determining
where the shell looks for executable files.
• Path management involves the use of commands to
view and modify paths effectively.
Viewing path
To see the current value of the variable PATH use the
command; echo $PATH
Modifying path
• Path modification involves adding directories at
the beginning or at the end of a path.
a. Adding directory to the beginning of a PATH
use the command; export
PATH=/new/directory/path:$PATH
b. Adding directory to the end of a PATH use the
command; export
PATH=$PATH:new/directory/path
•To make the modification permanent, the commands should be
exported to the changes, configuration file such as ~/.bashrc as
shown below

At the beginning use command;

• echo ‘export PATH=/new/directory/path:


$PATH’>>~/.bashrc

At the end use command;


• echo ‘export PATH=$PATH:new/directory/path’>>~/.bashrc

•To apply the changes, use command; source ~/.bashrc


Significance of Path
customization
• By adding directories to the PATH user can
execute commands without specifying their full
path. This is especially useful for customs scripts
or programs stored in non-standard directories.
THANK YOU

You might also like