Q2 50-74 Flashcards

1
Q
Assuming that you are running a Bourne-shell and the abc file does not exist, what is the output of the following Unix commands: 
cd /tmp;
pwd > abc; 
ln abc ABC;
rm abc;
cat ABC
A
  1. Bring us to /tmp folder
  2. Write a new file abc with our pwd, /tmp
  3. Link abc to ABC
  4. Removes the original abc file
  5. Cannot open ABC, because the file it’s hard linked to has been removed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
Predict the output of the following commands:
   cd ~
   pwd
   tcsh
   cd /
   pwd
   exit
   pwd
A
  1. Change Directories to the user’s home directory
  2. Show our Present Working Directory
  3. Change our shell to C shell (tcsh)
  4. Change Directories to absolute root
  5. Show our Present Working Directory
  6. Exit C shell
  7. We will now be back at our user’s home directory (cd ~) because changing shells doesn’t affect our pwd.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In tcsh shell, how do you create a regular variable?

A

set varname = variable

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

In sh shell, how do you create a regular variable?

A

varname = variable

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

In tcsh shell, how do you change a value of a regular variable?

A

set varname = newVariable

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

In sh shell, how do you change a value of a regular variable?

A

varname=newVariable

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

In tcsh shell, how do you delete a regular variable?

A

unset varname

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

In sh shell, how do you delete a regular variable?

A

unset varname

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

In tcsh shell, how do you create an environment variable?

A

setenv environmentVarname environmentVariable

NO EQUAL SIGN

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

In sh shell, how do you create an environment variable?

A

environmentVarname=EnvironmentVariable

export EnvironmentVarname

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

In tcsh shell, how do you change a value of an environment variable?

A

setenv environmentVarname newEnvironmentVariable

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

In sh shell, how do you change a value of an environment variable?

A

unset environmentVarname
environmentVarname=newEnvironmentVariable
export EnvironmentVarname

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

In tcsh shell, how do you delete an environment variable?

A

unsetenv environmentVarname

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

In sh shell, how do you delete an environment variable?

A

unset environmentVarname

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

What is the difference between regular shell variables and environment shell variables?

A

Global/Environmental affects the current shell and all the programs invoked from that shell.

Local/Regular affects only the current shell but none of the shell it invokes.

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

In tcsh shell, how do you display all current environment variables?

A

env

17
Q

In tcsh shell, how do you display all current regular variables?

A

set

18
Q

In sh shell, how do you display all current environment variables?

A

env

19
Q

In sh shell, how do you display all current regular and environment variables?

A

set

20
Q

Is there a command under sh shell that can display current environment variables alone?

A

printenv

21
Q

In tcsh shell, create an alias named rm that always deletes files recursively.

A

alias remove rm -r -f

22
Q

In tcsh shell, create an alias named ls that always display files with long format.

A

alias long ls -l

23
Q

In tcsh shell, how would you configure the Unix history to store the last 200 commands?

A

set history=200

24
Q

In tcsh shell, how would you configure the Unix history to store the last 100 commands between two consecutive sessions?

A

set savehist=100