CSI 3336 - Final Exam

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/154

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

155 Terms

1
New cards

gdb - steps through program one step at a time

n (next)

2
New cards

A product that can be used to determine and find memory leaks

Valgrind

3
New cards

Create and maintain static libraries

ar (archive)

4
New cards

A single copy of a library loaded into memory

Shared libraries

5
New cards

First call to open returns

3

6
New cards

Get to root directory

/

7
New cards

File descriptor

fd

8
New cards

Function that returns a different value every second

time()

9
New cards

Output exit status of most recently run code

echo $?

10
New cards

Relative path to home directory

~

11
New cards

When matching file names in shell, what matches any single character? (example of file name expansion)

?

12
New cards

Developer of Linux

Linus Torvalds, University of Helsinki

13
New cards

GNU

GNU's Not Unix

14
New cards

Where was C developed?

Bell Laboratories

15
New cards

Libraries in Linux are known as archives. What is the typical file extension?

.a

16
New cards

Create directory named 'cs3336' (located back one directory in myClass)

mkdir ../myClasses/cs3336

17
New cards

Print all files named fooxx (f case insensitive, xx - two base 10 digits) to printer ecs312

lpr -P ecs312 [Ff]oo[0-9][0-9]

18
New cards

Swap order of 1st and last name in a file named classList.txt

sed -E 's/(.)(.)/\2\1/'

19
New cards

Find the max value using a bash shell script

#!/bin/bash

maxValue()

{

big = $1

for val

do

if [[ $big -lt $val ]]

then

big = $val

done

echo $big

}

ret = $(maxValue 15 18)

20
New cards

Write a makefile for project (myprog)

- Must have ability to clean, use at least 1 macro, force gnu89 standard on all compiles

cc = gcc -std=gnu89

OBJ = main.o a.o b.o

myprog: $(OBJ)

$(cc) -o myproj $(OBJ)

clean:

rm myprog $(OBJ)

main.o: main.c a.h b.h

$(cc) -c main.c

a.o: a.c a.h b.h

$(cc) -c a.c

b.o: b.c b.h

$(cc) - c b.c

21
New cards

What is a system call?

Fundamental interface between an application and the Linux kernel.

22
New cards

How are they similar/different from other functions?

Other functions (wrapper functions) invoke system calls. System calls perform the same functions as library functions, but at a different layer of abstraction.

23
New cards

When would you choose to use a system call versus another function?

When working with file descriptors and pipes, system calls must be used to read and write.

24
New cards

Using only system calls for I/O, write readADigit()

- reads individual digit, give int back to calling function if it exists

readADigit(int fd)

{

int answer = -1;

char ch;

if ((read(fd, &ch, 1) != -1) || ch < '0' || ch > '9')

{

answer = -1;

}

else

{

answer = ch - '0';

}

return answer;

}

25
New cards

Code fragment that uses getopt() to count number of v options given on command land and prints count

-v option: get increasingly verbose diagnostic output

int main( int argc, char *argv[] )

{

int vcount = 0;

int opt;

while((opt = getopt( argc, argv, "v" )) != -1)

{

if(opt == 'v')

{

vcount++;

}

}

printf( "%d\n", vcount );

}

26
New cards

Calls the command pwd and redirect its stderr to a file named errLog

pwd 2> errLog

27
New cards

Permissions on the (1) directory are set so that any user can create files in it.

temp

28
New cards

Variable expansion but not file name expansion

" "

29
New cards

The (1) symbol will be expanded as the path to your current directory.

.

30
New cards

Old internet standard protocol for a remote terminal connection

Telnet (23)

31
New cards

Secure alternate protocol

ssh (22), encrypts communication between server and client

32
New cards

Print current time on system

date

33
New cards

Print the number of lines that the string "Bear" is found in the file pressRelease

grep -c "Bear" pressRelease

34
New cards

Print the contents of only the current directory in reverse lexicographical order

ls -r

35
New cards

Replace all occurrences of "Dwayne Johnson" in a file named pressRelease with "The Rock"

sed 's/Dwayne Johnson/The Rock/g' pressRelease

36
New cards

Vim: moves cursor to beginning of file

gg

37
New cards

Vim: get editor to save copy of current file

:w

38
New cards

Vim: get editor to move cursor to end of current line

$

39
New cards

Vim: undo last change to file

u

40
New cards

Regex that matches: catinthehat.txt

grep -E "catinthehat.txt" file_name

41
New cards

Regex that matches bears (first letter case insensitive)

grep -E "[Bb]ears" file_name

42
New cards

Regex that matches any number followed by a colon

grep -E "[0-9]+:" file_name

43
New cards

Regex that matches any 5 letter sequence that repeats at least once

grep -E "([a-zA-Z]{5}).*\1" file_name

44
New cards

Shell Expansions: files ending in .thm

*.thm

45
New cards

Shell Expansions: "file" followed by any single char followed by ".txt"

file?.txt

46
New cards

Shell Expansions: all files located in user SMITHB's home directory ending in ".sh"

~SMITHB/*.sh

47
New cards

Shell Expansions: files named "foo" with the first character case insensitive

[Ff]oo

48
New cards

Developers of UNIX

Denis Ritchie, Ken Thompson, Brian Kernighan

49
New cards

Current directory

.

50
New cards

Previous directory

..

51
New cards

Write to a stream (overwrite)

>

52
New cards

Write to a stream (append)

>>

53
New cards

Developers of C

Denis Ritchie, Brian Kernighan

54
New cards

Shell

Good for quick and simple development

55
New cards

KISS Principle

Keep it Small and Simple

56
New cards

Bash

Bourne Again Shell

57
New cards

sh

Bourne Shell

58
New cards

ksh

Korn Shell

59
New cards

csh

C Shell

60
New cards

Bash spawns new shell, executes given command, then returns result. (T/F)

True

61
New cards

Bash built-ins run on the original bash, and as a result, is faster and more efficient. (T/F)

True

62
New cards

Concatenate strings in bash

foo = "Hi"

bar = "there"

total = $foo$bar

63
New cards

""

Do not suppress variable expansion. Suppress shell expansion.

64
New cards

''

Suppress everything

65
New cards

``

Command substitution

- Identical to $(_)

66
New cards

0

Standard in

67
New cards

1

Standard out

68
New cards

2

Standard error

69
New cards

/dev/null

Universal trash can in Linux

70
New cards

kill

kills precess specified by pid

71
New cards

ps -ef | grep user_name

grabs all processes related to a specified user

72
New cards

head

returns first 10 lines

73
New cards

head -num

returns first num lines

74
New cards

tail

returns last 10 lines

75
New cards

tail -num

returns last num lines

76
New cards

Pipe

takes stdout for the first process and uses it as stdin for another process

77
New cards

export

allows every instance of the shell to have access to the variable

78
New cards

In Bash, 0 is considered true (T/F)

True

79
New cards

grep

global regular expression print

80
New cards

sed

special command (substitution in ed)

- manipulates strings, but by default, does not modify files

81
New cards

Remove all instances of 'TX', replace with Texas

sed 's/TX/Texas/g' file_name

82
New cards

sed: i

change in place

83
New cards

*

0 or more of the preceding pattern

84
New cards

? (file name expansion)

matches exactly one character

85
New cards

[...] (file name expansion)

character class

86
New cards

^

first of line

87
New cards

( )

capture group

88
New cards

$

last of line

89
New cards

{n, m}

range of a number of occurrences (at least n, at most m)

90
New cards

{n}

exactly n occurrences

91
New cards

{n, }

at least n occurrences

92
New cards

{ ,m}

at most m occurrences

93
New cards

+

1 or more

94
New cards

|

or

95
New cards

\

escape

96
New cards

* (file name expansion)

0 or more characters

97
New cards

?

0 or 1

98
New cards

Shebang line

#!/usr/bin/bash

- indicates what interprets the file

99
New cards

-rwxrwxrwx

Read, write, executable permissions

- 3 sets of octal numbers

- chmod

100
New cards

You must give file executable permissions OR (1)

1. explicitly give it bash when executing

ex. $bash ./hw.sh