Environment Variables

Similar documents
Environment Variables

UNIX Shell Programming

Introduction to UNIX Shell Exercises

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

System Programming. Unix Shells

Log into Linux Reminders: Homework 1 due today; Homework 2 due on Thursday Questions?

Unix Shell Environments. February 23rd, 2004 Class Meeting 6

Work Effectively on the Command Line

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

Traditional Access Permissions

24 Writing Your First Script

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Lab 2: Linux/Unix shell

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Topic 2: More Shell Skills

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

CS 2505 Computer Organization I Test 1

CS 2505 Computer Organization I Test 1

Topic 2: More Shell Skills. Sub-Topic 1: Quoting. Sub-Topic 2: Shell Variables. Difference Between Single & Double Quotes

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

Bourne Shell (ch 8) Overview. Bourne Shell. Bourne Shell. Bourne Shell. Bourne Shell. Redirect standard error. Redirect standard error

INF322 Operating Systems

Topic 2: More Shell Skills

CS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Chapter 9. Shell and Kernel

Systems Programming/ C and UNIX

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program.

CST Algonquin College 2

5/20/2007. Touring Essential Programs

5/8/2012. Specifying Instructions to the Shell Chapter 8

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Introduction to Linux Workshop 1

Shell Start-up and Configuration Files

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Working with the Linux Shell

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Review of Fundamentals

Lab 1: Cadence Custom IC design tools- Setup, Schematic capture and simulation

Useful Unix Commands Cheat Sheet

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

IOL INTACT Installation Guide

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

AIMMS Function Reference - System Functions

Introduction to Linux

Introduction of Linux

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

Quick Install and License Setup

Traditional Access Permissions

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Unix. Examples: OS X and Ubuntu

A shell can be used in one of two ways:

bash, part 3 Chris GauthierDickey

commands exercises Linux System Administration and IP Services AfNOG 2015 Linux Commands # Notes

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Introduction to Bash Programming. Dr. Xiaolan Zhang Spring 2013 Dept. of Computer & Information Sciences Fordham University

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

PROGRAMMAZIONE I A.A. 2015/2016

Manual Shell Script Linux If File Exists Wildcard

Lecture 3: The UNIX Style

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Introduction to Linux for QSS/OASIS System Administrators and System Operators

Chapter-3. Introduction to Unix: Fundamental Commands

Fun with XMMS (and friends)

Common File System Commands

Introduction to Linux. Roman Cheplyaka

Week 5 Lesson 5 02/28/18

U"lity programs and scripts. Thomas Herring

Unix Tutorial Haverford Astronomy 2014/2015

Introduction to UNIX. SURF Research Boot Camp April Jeroen Engelberts Consultant Supercomputing

Software I: Utilities and Internals. What is vi?

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

Course 144 Supplementary Materials. UNIX Fundamentals

COMS 6100 Class Notes 3

Prof. Navrati Saxena TA: R. Sachan

Working with Basic Linux. Daniel Balagué

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

CS370 Operating Systems

Introduction: What is Unix?

02. At the command prompt, type usermod -l bozo bozo2 and press Enter to change the login name for the user bozo2 back to bozo. => steps 03.

A Brief Introduction to Unix

UNIX and Linux Essentials Student Guide

Docusnap X - Docusnap Script Linux. Script-based Inventory for Linux

Getting your department account

Introduction to Unix: Fundamental Commands

Aliases are set manually or in a login script. Aliases that were set manually will be gone the next time you login.

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Linux Introduction Martin Dahlö Valentin Georgiev

Week 2 Lecture 3. Unix

Std: XI CHAPTER-3 LINUX

Transcription:

Environment Variables 1 A shell is simply a program that supplies certain services to users. As such, a shell may take parameters whose values modify or define certain behaviors. These parameters (or shell variablesor global environment variables) typically have values that are set in certain configuration files. When you install Linux, or use your rlogin account, many of these parameters will have default values determined by the system administrator or by Linux installer. You may generally modify those default values and even define new parameters by editing configuration files within your home directory. Open a bash shell and enter the command $HOME this will show the current value of the environment variable HOME.

The Path Variable 2 The environment variable that is most often encountered is the PATH variable, which determines which directories the shell will search (and in what order) when the shell attempts to locate programs you are attempting to execute. We see that the default PATH for this Ubuntu installation contains the directories: /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games (which apparently does not exist!)

Setting a Variable 3 You can change the value of a shell variable from the command line. Let s add the current directory to the PATH: Note that we can now run the user program sleeper2 without specifying the path. But this only resets PATH for the current shell session.

Bash Shell Startup 4 When a bash shell is started, it automatically executes commands stored in certain files. There are three kinds of shells: (interactive) login shells /etc/profile ~/.bash_profile ~/.bash_login ~/.profile interactive non-login shells /etc/bashrc ~/.bashrc (sets values for various shell variables) a system file that only the root user can modify files in your HOME directory that you can change (inherits login shell variables from files above) another system file another file in your HOME directory non-interactive shells (inherits login shell variables from files above) files named by the environment variable BASH_ENV

Side Note: Hidden Files 5 If you try the lscommand in your home directory, you will (probably) notice that the file.bash_profile is not listed. Filenames that begin with a period are hidden by default. You can use the ls -a command will show hidden files as well as non-hidden files.

Ubuntu Variance 6 When you open an interactive terminal session in Ubuntu, the sequence described on the preceding slide is NOT followed by default. In particular, ~/.bash_profileis not executed automatically, and therefore changes you make to it will not be effective. There is a simple fix for the issue: - open a terminal session and go to Edit/Profile Preferences - select the Title and Command tab - check the box for Run command as a login shell In fact, in my Ubuntu installation, ~/.bash_profiledid not exist initially; I had to create it with gedit.

~/.bash_profile 7 You should use ~/.bash_profileto set changes to the PATH variable because ~/.bash_profile is only executed once. Here is a sample.bash_profile taken from Sobell: if [-f ~/.bashrc]; then # if.bashrcexists in the home directory source ~/.bashrc # run it fi PATH=$PATH:. # add working directory to the path export PS1='[\h \W \!]\$ ' # configure the shell prompt Normally, ~/.bashrc is invoked from another configuration file, as shown here. See the note in Sobell regarding adding the working directory to the path; NEVER add it at the beginning of the path! Sobell has a good discussion of the various options for the appearance of the prompt.

~/.bashrc Here is a sample ~/.bashrc adapted from Sobell: 8 if [-f/etc/bashrc]; then # if global bashrcexists, run it source /etc/bashrc # note: no period in file name fi if [-d"$home/bin"]; then # add user s bin directory to path PATH="$HOME/bin:$PATH" fi set -o noclobber # prevent silent overwriting of files # (by redirection) unset MAILCHECK # disable you have mail notice alias rm= rm-i # always use interactive rm cmd alias cp= cp-i # and interactive cp cmd alias h= history tail alias ll= ls-alf alias commands are a convenient way to create mnemonics for specialized execution of system commands.