Shell Flashcards

1
Q

Shell

A
  1. started automatically by unix after login
  2. Allows the user to interactively start, stop, suspend, and resume
    other programs and control the access of programs to the terminal
  3. Supports automation by executing files of commands (“shell scripts”), provides programming language constructs (variables, string expressions, conditional branches, loops, concurrency)
  4. Select files with fewer keystrokes [Simplifies file selection via keyboard (regular expressions, file name completion)]
  5. Simplify command entry – Simplifies entry of command arguments with editing and history functions
  6. Most common shell – Most common shell (“sh”) developed 1975 by Stephen Bourne, modern GNU replacement is “bash” (“Bourne-Again SHell”)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Unix IPC - supported by shell, via command line syntax

A
Process  A -> B (provided into process)
- Invoke 
- provide command line args
- environment vars 
- current directory
- signals
- resource limits, umask
- priority
(out of process)
- return value
- ability to have execution completion time queried
(duplex)
- standard input / out / err
- files/pipes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

UNIX IPC not supported by shell

A

Full duplex:

  • sockets
  • shared memory
  • semaphores
  • messages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Receiving/returning communication channels in a C program

A
  • C program invoked
  • OS calls main function, recieves argv array, plus a global variable environ, which is a name of strings of the form name=value where name is free of =.
  • argv[0] is usually the name or path of the program
  • main() == 0 signals success, other values signal errors to calling process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Unix file IO

A
  • open() or creat() system calls taking a path name, returning an integer “file descriptor”
  • read()/write()/seek() system calls, taking FD as an operand
  • close() to release any data structures associated with an opened file (position pointer, buffers, etc.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

view currently opened files

A

lsof tool

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

Standard file descriptors

A
Shell opens three FDs for each process
- 0 = standard input [=keyboard]
- 1 = standard output 
- 2= standard error 
[both=screen of video terminal]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly