customizing linux environment tutorial 4 engr 3950u / csci 3020u operating systems instructor: dr....
TRANSCRIPT
Customizing Linux Environment
Tutorial 4 ENGR 3950U / CSCI 3020U
Operating Systems
Instructor: Dr. Kamran Sartipi
Customizing Shell
Making it more user-friendly Adjusting it to your specific needs
There are jobs you repeat everyday Complicated tasks Commands you always forget
Important files BASH
/etc/bashrcSystem wide functions and aliases
/etc/profilesSystem wide environment and start-up programs
~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
BASH Invocation Order We have: login shell and interactive shell Login shells:On login:if /etc/profile exists, source it.if ~/.bash_profile exists, source it, else if ~/.bash_login exists, source it, else if ~/.profile exists, source it.On exit:if ~/.bash_logout exists, source it.
Non-login interactive shells:On startup:if ~/.bashrc exists, source it.
Alias Create an alias, aliases allow a string to be substituted
for a word when it is used as the first word of a simple command.
SYNTAX:alias [-p] [name[=value] ...] unalias [-a] [name ... ]
If arguments are supplied, an alias is defined for each name whose value is given.
If no value is given, `alias' will print the current value of the alias.
Alias Examples
alias nic 'nice +12 emacs -i -r -geometry 80x61+207+31 &‘
alias gh 'ghostview &‘ alias mca='mc -a‘ alias fnd 'find . -name "\!*" -print‘ alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde‘
alias l.='ls -d .* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty'
Export Export Set an environment variable. Mark each name to be
passed to child processes in the environment.
SYNTAX export [-fn] [-p] [name[=value]] OPTIONS -f The names refer to shell functions; otherwise the names refer to shell variables -n No longer mark each name for export. -p Display output in a form that may be reused as input.
If no names are supplied, or if the `-p' option is given, a list of exported names is displayed.
Export Example
If we want to modify PATH inside a shell script and have the effect preserved when we return to the shell
PATH=$PATH:$HOME/binexport PATH
Umask
umaskUser's file creation mask. Set the shell process's file creation mask to mode.
SYNTAX umask [-p] [-S] [mode] OPTIONS
mode File creation mask -S Print the mask in symbolic format -p Output in a form that may be reused as input
The current value of the mask will be printed if mode is omitted,
If mode begins with a digit, it is interpreted as an octal number; if not, it is interpreted as a symbolic mode mask similar to that accepted by the chmod command.
Umask Examples
umask 02 # Full group access, deny write to others.
umask 66 # Deny read and write to group and others.
umask 77 # Deny everything to everyone.
umask 26 # Deny group write, deny read and write to others.
Command Prompt
Similar to Dos prompt it can be customized
Examples: set prompt="[$USER] <$HOSTNAME \!> “
In Bash the $PS1 is used as the environment variable for the prompt syntax
Miscellaneous
if ( -r ${HOME}/.aliases ) source ${HOME}/.aliases
Sourcing .aliases file if it exists.