CS155: Introduction to Unix

Spring 2018

Customization

See this page as a slide show

Shell Customization

CS155 Customization

Automatic scripts

What’s the syntax?

Environment Variables

Customization usually means setting environment variables.

    export var="value"
    export TZ="America/Denver"

Remember, all examples from now on are bash only.

Inheritance

Changing your PATH

To help the shell find programs in another directory, add it to the beginning of the environment variable PATH:

% ruler 50
/tmp/pmwiki-bash-script41UQSw: line 10: ruler: command not found
% echo $PATH
/bin
% export PATH="~/bin:$PATH"
% echo $PATH
~/bin:/bin
% ruler 50
12345678901234567890123456789012345678901234567890
         1         2         3         4         5

Why did we use "double quotes" as opposed to 'single quotes'?

Changing your prompt

To change your interactive prompt, set the appropriate variable:

    PS1="$USER> "

Why didn’t we use export? That’s because this variable is private to the shell, and not for the use of other programs.

Creating new commands

To create a new command, use alias:

% date
Thu Nov 21 09:26:57 MST 2024
% alias date="echo How about a date?"
% date
How about a date?
% unalias date
% date
Thu Nov 21 09:26:57 MST 2024
% alias mkx="chmod u+x"
% touch zulu
% ls -l zulu
-rw------- 1 cs155 class 0 Nov 21 09:26 zulu
% mkx zulu
% ls -l zulu
-rwx------ 1 cs155 class 0 Nov 21 09:26 zulu

Non-recursive Aliases

Aliases are not self-recursive:

% touch a b c d e f g h i j k l m n o p
% rm *
% touch a b c d e f g h i j k l m n o p
% alias rm='rm -I'
% rm *
rm: remove 16 arguments? y
% touch x y z
% rm *

rm -I prompts if more than three files are to be removed.

umask

% touch x
% umask ugo=rwx
% touch y
% umask u=rwx,g=r,o=
% touch z
% ls -l
total 0
-rw------- 1 cs155 class 0 Nov 21 09:26 x
-rw-rw-rw- 1 cs155 class 0 Nov 21 09:26 y
-rw-r----- 1 cs155 class 0 Nov 21 09:26 z

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2018-02-09T09:48

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building