Tools Flashcards

1
Q

Libraries:

Static Linking

vs

Dynamic Linking

A
  • Static Linking
    • Every routine needed from the library is included in the executable file
    • Routines are PART OF the program
  • Dynamic Linking
    • References to library routines are left to resolve during execution
    • Library objects not loaded until they are needed at runtime
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Libaries:

What are

“Shared Libraries”?

A

Libraries that are prepared for

Dynamic Linking

These are also called

Dynamic Linking Libraries (DLLs)

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

Shell Scripts:

Overview

A
  • A shell script is just a sequence of shell commands
  • Stored in an executable text file
    • The “x” bit in the file permissions must be turned on with “chmod”
  • The shell finds programs by looking for executable files in the path ( $PATH )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Shell Utility Toolkit:

Basic

Line Oriented Processing Tools (8)

A
  • grep
    • find patterns
  • sed
    • edit lines
  • cut
    • extract columns
  • sort
    • sort lines into specified order
  • uniq
    • display unique lines in a sorted file
  • tail
    • display last lines of a file
  • head
    • display fist lines of a file
  • wc
    • count words, lines or characters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Shell Utility Toolkit:

grep

A
  • Grep is used to find lines or patterns in text
  • Use:
    • grep [-e pattern]
  • This will output any lines that contain any of the patterns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Shell Utility Toolkit:

sed

A
  • Used to edit/rewrite lines within the text
  • Use:
    • sed [-e action]
  • Copies input to output, performing all actions on each line
  • Possible Actions
    • Delete: /pattern/d
      • Delete line if pattern found
    • Read: /pattern/r
      • Read file after the line where pattern occurs
    • Replace: s/pattern/replace/g
      • Substitute “replace” at occurrences of “pattern”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Shell Utility Toolkit:

cut

A

Extract the columns of text

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

Shell Utility Toolkit:

sort

A

Sort lines of text into a specified order

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

Shell Utility Toolkit:

uniq

A

Display unique lines in a sorted file

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

Shell Utility Toolkit:

tail

A

Display the last lines of a file

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

Shell Utility Toolkit:

head

A

Display the first lines of a file

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

Shell Utility Toolkit:

wc

A

Counts words, lines or characters in text

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

Shell Utility Toolkit:

File System

Manipulation Tools (8)

A
  • cp - copy
  • mv - move
  • rm - remove
  • ls - list
  • chmod - change file access modes
  • chown - change file owner
  • find - navigate directory structure, testing files for attibutes
  • touch - change last-modified time on a file to current
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Shell Utility Toolkit:

Miscellaneous Tools (5)

A
  • echo - echo arguments on stdout
  • cat - copy a file, or files, to stdout
  • tr - translate characters
  • date - echo current date and time
  • man - see manual page of a command
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Shell Utility Toolkit:

Scripting Languages

A

In addition to simple shell scripts:

  • awk
    • Process files based on
      • rich pattern matching
      • text manipulation
  • perl
    • Works similarly, but with more c-like facilities
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Difference between

C Programming

and

Shell Programming

A

C Programming deals with:

  • Data Structures
  • Algorithms

Shell Programming deals with:

  • The file system
  • Utilities

A professional uses both language types for their unique strengths.

17
Q

Shell Utility Toolkit:

echo

A

Writes text to stdout

Can pass plain or quoted text

Special Characters:

  • *
    • represents the contents of the directory
  • $
    • used for substitution variables
  • ’ ‘
    • surrounding text with single quotes means special characters are ignored
18
Q

The Shell:

Using pipelines

A

Use the “|” to connect Filter programs int a pipeline

Example:

% ls -a | sort | uniq

Each step along the pipeline will perform the function

on the results of the previous step

19
Q

Shell Command Format

A

[command] [-switch] …. [argument(s)] …

  • Command file names are located in /bin/
  • Built in verbs like “cd”
  • Switches are a single letter, such as -a
  • can combine switches by adding the letters: -a1
  • some switches require you to add a value
20
Q

What doe the Shell Provide?

A
  • Interactive Interface
    • Allows use of all system capabilities
    • Navigate and manipulate file system
    • Invoke System Commands and Programs
    • Customize your environment
  • Programming Environment
    • For system programmers
    • Automate interactions
    • “glue” together smaller programs
    • Prototype solutions
21
Q

The Shell:

Redirection of

Input

A

By Default, input is normally stdin

Use “<” to specify a different file descriptor.

This allows a file to be used as input.

Example:

% grep -e “abc” < myFile.txt

22
Q

The Shell:

Redirection of

Output

A

By default, output of programs is to stdout.

Use “>” to redirect the output to a different file descriptor.

This allows output of a program to be written to file.

Alternatively, use “>>” to append the file instead of writing over it.

Example:

% grep -e “abc” > my_output_file.txt

% grep -e “abc” >> my_output_file.txt

23
Q

The Shell:

Redirection of

Error

A

By default, errors are printed to stderr

Use “ 2> “ to redirect to a different file descriptor

Example:

% grep -e “abc” 2> my_error_file.txt

24
Q

Libraries:

How Dynamically Linked Library

routines are used when called

A
  • The Executable File is by itself
  • A call to a routine in the library goes to a Loader routine that has the name of the routine as an argument
  • The Loader copies the needed routine from the library and loads it into memory
    • Copying may be skipped if the routine is already loaded in memory
  • The call is redirected to this routine
25
Q

Dynamic Linking:

Advantages

A

Advantages

  • Size of executable is reduced
    • Library routine not present in executable
  • Overal system speed increased
    • Library routine is only loaded once, then shared
  • Program Robustness increased
    • Changes to the library don’t require relinking
26
Q

Dynamic Linking:

Disadvantages

A

Disadvantages:

  • Libary version control
    • Can the executable find the right version of the library routine?
  • “Thrashing” of library routines in memory due to a constrained environment
27
Q

Libraries:

Benefits of Using Libraries

A
  • Save Development Time
    • Reusing routines that have already been throroughly debugged
  • Save Maintenance Time
    • Evolve a coherent capability
    • Using well known libraries with existing best practices
28
Q

Libraries:

Characteristics of

Good Libraries

A

A Good Library is:

  • Complete
    • All elements needed for some specific problem are there
  • Concise
    • Less is more, it is efficient
  • Coherent
    • Pieces fit together well without undue mental stress
  • Correct
    • Pieces work in all combinations and usages
  • Configurable
    • Users can tune and axtend as needed
  • Changeable
    • Maintainers can evolve the library as the environment changes
29
Q

Shell:

Three Normally Open File Descriptors

A
  • 0: Standard Input, stdin
  • 1: Standard Output, stdout
  • 2: Standard Error, stderr
30
Q

Parts of the

Executable

Format

A
  • Cookie
    • Number that identifies the file as a binary executable file
  • Header
    • Size of the file in bytes
  • Code
    • Combined Code Sections
    • Always begins with standard C startup routine from system library
  • Data
    • Combined Data Sections
    • Contains only initialized external
    • and static internal data
    • Room for uninitialized data set aside during loading
    • includes numbers and strings
31
Q

What does the

Linker

do?

A

Combines separate

Object files

into a single

Executable File

32
Q
A