Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up."— Presentation transcript:

1 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

2 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.

3 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

4 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”).

5 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”).

6 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.

7 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

8 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

9 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)

10 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

11 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

12 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


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

Similar presentations


Ads by Google