Topic 7 - Unix Shell Environments Flashcards

1
Q

the full path name of your home directory

A

$HOME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

the name of your login shell

A

$SHELL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

the full path of the current working directory

A

$PWD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

USER

A

the user name of the logged in user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

TERM

A

the kind of terminal the user is using

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DISPLAY

A

which X server to display on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

PATH

A

the directories the shell should search to find a command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

HOST

A

the name of e the computer you are using

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

REMOTEHOST

A

the name of the host logged-in from

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

MANPATH

A

the directories the man command should search to find man pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Shell variable names can be made up of:

A

Alphabetical characters
Digits
Underscores

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Shell variable names cannot begin with:

A

a digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Shell variables can store either:

A

string of characters, or NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Shell variables can be accessed by putting a ____ in front of ____

A

putting a $ in front of their names. e.g., echo $HOME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Are variable names case-sensitive?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the two kinds of shell variables?

A

Environmental variables (GLOBAL) & Regular Variables (LOCAL)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Define environmental variables

A

Affecting the current shell and the programs invoked from the shell.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Define regular variables

A

Affecting the current shell, but not the programs invoked from the shell

19
Q

Which type of shells define their shell variables in each of the following:

  • .profile
  • .cshrc and .login
A

.profile = Bourne-Style shells

.cshrc and .login = C-Style shells

20
Q

C-Style Shells: How do you set a variable?

A

set varname=varvalue

21
Q

C-Style Shells: Clearing a regular (local) variable?

A

unset varname

22
Q

C-Style Shells: How do you set environment variables?

A

setenv EnvironemntVarialbe EnvironemntValue No “=” sign here!

23
Q

C-Style Shells: How do you clear environment variables?

A

unsetenv EnvironemntVariable

24
Q

C-Style Shells: How do you list all environment shell variables?
Regular shell variables?

A

1) “printing” or “env”

2) “set” without any arguments

25
Q

Bourne-Style Shells: How do you set a regular (local) variable?

A

varname=varvalue (there is no “set” here - also, no spaces before / after “=” !!!)

26
Q

Bourne-Style Shells: How do you clear regular (local) variable?

A

unset varname (same as C-Style Shell)

27
Q

Bourne-Style Shells: How do you set an environmental variable?

A

Same as local variable (EnvironmentVariable = EnviromentValue)
Then, use “export EnvironmentVariable”

28
Q

Bourne-Style Shells: How do you clear an environmental variable?

A

unset EnvironmentVaraible (only ‘unset’ - same as regular variables)

29
Q

Bourne-Style Shells: How do list all local variables? Environmental variables?

A

“set” - lists ALL existing local AND enviro variables

“print env or just env” will list ONLY enviro (exported) shell variables

30
Q

Once a variable is exported, the only way to stop the export effect is to _____

A

“unset” the variable

31
Q

The shell searches in each directory of $Path how?

A

In left to right order and executers the first version.

32
Q

What does “which” cmd do?

A

locates a unix command and displays its pathname or alias

33
Q

What does .login do?

A

Runs once when you log in: contains one-time things like terminal setup

34
Q

What does .cshrc do?

A

Runs before the execution of any [t]csh process: Sets lots of variables, e.g., PATH, MANPATH etc.

35
Q

In C-Style shells, what does “history” cmd do?

A

Displays the command history list with line numbers

36
Q

List the ways to rerun a command line in the history:

A

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

37
Q

The variable savehist determines:

A

How much history to be saved in the file name histfile for your next session;

38
Q

Where are savehist and hostile variables likely to be set?

A

In C-Style shells: in your .cshrc file. Example:
set history=24
set savehist=10
set histfile=$home/.history.$HOSTTYPE

39
Q

What is the “alias” cmd syntax?

A

alias alias-name real-command

40
Q

Can you put your aliases in your .cshrc file?

A

Yes

41
Q

Can you display the alias of a command using the which command?

A

Yes.

42
Q

What does the alias command without any arguments do?

A

Lists ALL existing aliases.

43
Q

How do you delete alias(s)?

A

Using the “unalias” cmd: unalias alias-anem

44
Q

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?

A

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.