Topic 7 - Unix Shell Environments Flashcards
HOME
the full path name of your home directory
SHELL
the name of your login shell
PWD
the full path of the current working directory
USER
the user name of the logged in user
TERM
the kind of terminal the user is using
DISPLAY
which X server to display on
PATH
the directories the shell should search to find a command
HOST
the name of e the computer you are using
REMOTEHOST
the name of the host logged-in from
MANPATH
the directories the man command should search to find man pages
Shell variable names can be made up of:
Alphabetical characters
Digits
Underscores
Shell variable names cannot begin with:
a digit
Shell variables can store either:
string of characters, or NULL
Shell variables can be accessed by putting a ____ in front of ____
putting a $ in front of their names. e.g., echo $HOME
Are variable names case-sensitive?
yes
What are the two kinds of shell variables?
Environmental variables (GLOBAL) & Regular Variables (LOCAL)
Define environmental variables
Affecting the current shell and the programs invoked from the shell.
Define regular variables
Affecting the current shell, but not the programs invoked from the shell
Which type of shells define their shell variables in each of the following:
- .profile
- .cshrc and .login
.profile = Bourne-Style shells
.cshrc and .login = C-Style shells
C-Style Shells: How do you set a variable?
set varname=varvalue
C-Style Shells: Clearing a regular (local) variable?
unset varname
C-Style Shells: How do you set environment variables?
setenv EnvironemntVarialbe EnvironemntValue No “=” sign here!
C-Style Shells: How do you clear environment variables?
unsetenv EnvironemntVariable
C-Style Shells: How do you list all environment shell variables?
Regular shell variables?
1) “printing” or “env”
2) “set” without any arguments
Bourne-Style Shells: How do you set a regular (local) variable?
varname=varvalue (there is no “set” here - also, no spaces before / after “=” !!!)
Bourne-Style Shells: How do you clear regular (local) variable?
unset varname (same as C-Style Shell)
Bourne-Style Shells: How do you set an environmental variable?
Same as local variable (EnvironmentVariable = EnviromentValue)
Then, use “export EnvironmentVariable”
Bourne-Style Shells: How do you clear an environmental variable?
unset EnvironmentVaraible (only ‘unset’ - same as regular variables)
Bourne-Style Shells: How do list all local variables? Environmental variables?
“set” - lists ALL existing local AND enviro variables
“print env or just env” will list ONLY enviro (exported) shell variables
Once a variable is exported, the only way to stop the export effect is to _____
“unset” the variable
The shell searches in each directory of $Path how?
In left to right order and executers the first version.
What does “which” cmd do?
locates a unix command and displays its pathname or alias
What does .login do?
Runs once when you log in: contains one-time things like terminal setup
What does .cshrc do?
Runs before the execution of any [t]csh process: Sets lots of variables, e.g., PATH, MANPATH etc.
In C-Style shells, what does “history” cmd do?
Displays the command history list with line numbers
List the ways to rerun a command line in the history:
1) !! - reruns last command
2) !str - returns the latest command beginning with str
3) !n - where n is a number; reruns command number n in the history list
The variable savehist determines:
How much history to be saved in the file name histfile for your next session;
Where are savehist and hostile variables likely to be set?
In C-Style shells: in your .cshrc file. Example:
set history=24
set savehist=10
set histfile=$home/.history.$HOSTTYPE
What is the “alias” cmd syntax?
alias alias-name real-command
Can you put your aliases in your .cshrc file?
Yes
Can you display the alias of a command using the which command?
Yes.
What does the alias command without any arguments do?
Lists ALL existing aliases.
How do you delete alias(s)?
Using the “unalias” cmd: unalias alias-anem
C-Style shells has command and filename completion where you can let the shell complete a long command name - how do you use this feature?
Type a prefix of a command (only the first few letters), then hit the TAB key: the shell will fill in the rest for you, if possible. Same with filenames.