Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.

Slides:



Advertisements
Similar presentations
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Advertisements

Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
More about Shells1-1 More about Shell  Shells (sh, csh, ksh) are m Command interpreters Process the commands you enter m High-level programming languages.
Linux+ Guide to Linux Certification, Second Edition
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Using Linux Commands 2 Lab#5
Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
The file structure and related utilities CS240 Computer Science II.
Introduction to Shell Script Programming
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University.
CS 2061 Shells Also known as: Unix Command Interpreter.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
IT2204: Systems Administration I 1 6b). Introduction to Linux.
Workbook 6 – Part 1 The Bash Shell
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Linux+ Guide to Linux Certification, Third Edition
Basic Shell Scripting - Part 1 Objective - Learn to: Read Start-up Files Edit Start-up Files Modify Your User Environment Communicate with Users Write.
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
UNIX/LINUX SHELLS.  “A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Writing Scripts Hadi Otrok COEN 346.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
User Environments Objectives –to provide appropriate environments for different types of users Contents –different login programs –user profiles –restricted.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Executable scripts. So far We have made scripts echo hello #for example And called it hello.sh Run it as sh hello.sh This only works from current directory?
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
Compunet Corporation Introduction to Unix (CA263) Your Environment By Tariq Ibn Aziz Dammam Community College.
Environment After log in into the system, a copy of the shell is given to the user Shell maintains an environment which is distinct from one user to another.
Manually Creating a New User Account Presented by Carl South.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Chapter 8: The Bourne Again Shell It’s a command interpreter, it’s a programming language, and it makes a mean martini.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Linux+ Guide to Linux Certification, Second Edition
Configuration your environment Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration.
Lesson 8-Specifying Instructions to the Shell. Overview An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing.
Linux Administration Working with the BASH Shell.
ULI101 Week 10. Lesson Overview ● Shell Start-up and Configuration Files ● Shell History ● Alias Statement ● Shell Variables ● Introduction to Shell Scripting.
Shells.
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
CAP652 Lecture - Shell Programming
Shell Environments.
UNIX and Shell Programming (06CS36)
CHAPTER 8 (skip , ) CHAPTER 10
John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
The Linux Command Line Chapter 11
Linux Shell Script Programming
Module 6 Working with Files and Directories
Chapter 3 The UNIX Shells
Introduction to Bash Programming, part 3
The Linux Command Line Chapter 11
Presentation transcript:

Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up Files Common Shell Environment Variables PATH, PS1 Using Aliases

Start-up Files You may have asked yourself the following questions at some point when using your Phobos or Matrix Accounts: Does the server know my account username and password? Can I access this information stored on the system? Can I change my home directory to be something else? Can I change my default shell to something else? Can I change things like my shell prompt? Most of the answers to the above questions are “yes” which means that you can customize your account. This requires the user to understand certain “start-up” files that are accessed when the user first logs into their account.

Start-up Files When a user first logs into their Unix/Linux account, certain start-up files are accessed: User Login (bash shell) /etc/profile.bash_profile.bashrc User Login (korn shell) /etc/profile.profile.kshrc

bash shell Start-up Files  /etc/profile The file /etc/profile is maintained by the system administrator, for start-up commands common to all users .bash_profile The file called “.bash_profile” (contained in the user’s home directory as a hidden file) stores commands that are automatically run when the user first logs into their account. .bashrc The file called “.bashrc” (contained in the user’s home directory as a hidden file) stores commands that are automatically run when a bash sub-shell is started (“rc” stands for “run command”).

korn shell Start-up Files  /etc/profile The file /etc/profile is maintained by the system administrator, for start-up commands common to all users . profile The file called “.profile” (contained in the user’s home directory as a hidden file) stores commands that are automatically run when the user first logs into their account. .kshrc The file called “.kshrc” (contained in the user’s home directory as a hidden file) stores commands that are automatically run when a korn sub-shell is started (“rc” stands for “run command”).

Customizing Your Shell Environment The user can add or make changes within these start-up files to customize the shell environment. We will discuss how to use Shell Environment Variables and how to use them in start-up files.

Shell Environment Variables The shell requires certain system setting information in order to operate. These settings are stored in what are called “environment variables”. Environment variables usually appear in UPPERCASE. Some of the variables’ values can be changed by the user, some of the variables’ values are set by the system. The user can verify all shell environment variables by issuing the set command (without arguments). Here are a few common environment variables: PATH PS1

PATH Environment Variable The PATH variable lists all available directory paths for the shell to find and execute a program (issued by just it’s filename) from the shell prompt. Eg.PATH=.:/bin:/usr/bin Colon “:” is used to separate or delimit different directory pathnames Note that in this example three directory pathnames will be used:. (current directory), /bin, and /usr/bin

PS1 Environment Variable The PS1 variable represents the “primary string 1 shell prompt” or simply the string of text at the shell prompt. Eg. PS1=‘[ hi! ] ’ If this line was entered at the shell prompt, the prompt would appear as: [ hi! ] Special Characters for PS1 Variable: \h (Hostname of your server) \u (Your username) \w (Absolute directory path) \W (directory name of current directory) \d (Date) \t (time HH:MM:SS)

Shell Environment Variables There are two major concerns when changing shell environment variables: After assigning a value to a variable, the value will not be passed to a child process. To create an environment variable, which will be passed to child processes, use the export command eg. export PS1 PATH A value assigned to an environment variable at the shell prompt will not be kept when the user logs out and then logs back in. To solve this problem, store the variable settings and export command in a start-up file such as.bash_profile or.profile

Creating Aliases The alias command is used to substitute a shorter command to be used in place of a longer command. Aliases will appear with environment variables if you issue the set command. Example:alias l=ls –l Note: Similar to environment variables, aliases are usually stored in a start-up file such as.bash_profile or.profile After issuing this command, user simply enters command l to perform same task as ls -l

Modifying your start-up File Backup your.bash_profile (or.profile) file first! Make revisions to your.bash_profile file using a text editor (vi, nled, pico, etc…) You can use the dot “.” command to run your.bash_profile file to update your current settings: ..bash_profile