2505 Test 1 Review Flashcards

1
Q

difference between ls and ls -l

A

ls -l lists more info, size in byte, modification date, file owner, group

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

navigate to home directory

A

cd ~

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

navigate to previous directory

A

cd -

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

navigate to root directory

A

cd /

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

pwd command

A

prints full system path of current working directory

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

command to list all files in current dir

A

ls

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

what happens when you use “cd” without a destination

A

goes back to the home directory

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

command to copy a file to specific destination

A

cp [original] [new] [../]

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

command to make a directory

A

mkdir [name]

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

command to move a file

A

mv [file] [dir]

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

command to remove

A

rm

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

command to remove A DIRECTORY

A

rmdir

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

command to rename a file

A

mv [oldName] [newName]

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

reference for current directory

A

.

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

reference for parent directory

A

..

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

command to display contents of a file

A

cat [file]

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

command to show first few lines of a file

A

head [file]

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

command to report number of lines, words, and bytes

A

wc [file]

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

command to display lines of a file that match a pattern

A

grep

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

redirection operator to send output to a file and replace its contents

A

>

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

redirection operator to append info to contents of the file

A

> >

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

redirection operator to send contents of file to a program

A

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

file [name]

A

give info about file

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

3 types of users

A

owner (user), group, other (world)

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

command to change permissions

A

chmod

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

command to take away read and write permissions from group from file “foo”

A

chmod g-rw [path to foo]

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

how would chmod 740 change permissions for each group

A

owner: r w x
group: r - -
other: - - -

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

numeric args for chmod

A

no access - 0
execute - 1
write - 2
read - 4

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

command to create a collection of files

A

tar cvf [newTar] [targetFile]

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

command to check contents of tar file

A

tar tvf [tarFile]

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

flat tar files have no…

A

path listed/directory structure

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

what happens if you tar a dir?

A

the tar file will contain path info

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

command to extract a tar file

A

tar xvf [tarName] (-C [destination])

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

commands to unzip zip, gzip, and bzip2 files

A

unzip, gunzip, bunzip2

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

SPECIAL CHARACTER RULE for ?

A

match any single character

36
Q

SPECIAL CHARACTER RULE for *

A

match 0 or more characters

37
Q

SPECIAL CHARACTER RULE for []

A

match any of the characters within the braces

38
Q

SPECIAL CHARACTER RULE for *.txt

A

match any file with the ext txt

39
Q

SPECIAL CHARACTER RULE for [abc]foo.html

A

match a file with html ext and name “afoo” “bfoo” “cfoo”

40
Q

what does scp do?

A

copy a file between the local machine and remote machine

41
Q

command to copy a file to rlogin

A

scp foo.txt username: targetDir

42
Q

command to copy file FROM rlogin to the current dir

A

scp user: documents/foo.txt

43
Q

create an int pointer named point

A

int *point;

44
Q

assign the value of int “foo” to the int pointer “point”

A

point = &foo;

45
Q

store the value of “foo” which pointer “point” points to in a NEW int variable called “var2”

A

int var2 = *point;

46
Q

when assigning char pointers to string ARRAYS, do you need an & ?

A

NO

47
Q

how many bytes is an int?

A

4 bytes

48
Q

C function to find out how many bytes a data type is

A

sizeof(dataType)

49
Q

assign initialized char pointer “point” to a char input of n using malloc

A

point = (char)malloc(nsizeof(char));

50
Q

what is the type of &p if p is a char pointer with a target?

A

char**

51
Q

int* q = NULL;
is
*q = 20;
valid?

A

No because q has no target. There will be a segfault error

52
Q

When a pointer’s target becomes NULL what is the value of the pointer?

A

The pointer does not exist

53
Q

int* p = &A;
int* q = &B;
p = q;
What does p point to now?

A

B

54
Q

meaning of %d

A

base-10 integer

55
Q

absolute value function

A

abs()

56
Q

formatting to show 2 digits after decimal point in W columns

A

%W.2f

57
Q

external linkage

A

not “static”, declared AND initialized outside function

58
Q

internal linkage

A

static variable outside function

59
Q

no linkage

A

vars inside a function

60
Q

what goes at the top of a header called “foo.h”?

A

endif

#ifndef FOO_H
#define FOO_H
61
Q

static storage duration

A

Variables declared outside of everything or with “static”

62
Q

command to create an executable for debugging

A

gcc -o executableName -std=c11 -Wall -ggdb3 (list C files ONLY)

63
Q

while loop to use with fscanf

A

while(fscanf(fileName,”format”, variables) == numOfVariables)

64
Q

whats the common format of a main() function?

A
int main(int argc, char* argv[]) {
}
65
Q

what happens if you accidentally call a c file where the new tar file name should be?

A

the c file will get overwritten with a tar file of the same name

66
Q

when assigning a char ELEMENT to a char pointer do you need & ?

A

YES

67
Q

what does calloc() do

A

allocates the memory and also initializes the allocated memory block to zero

68
Q

args for strcpy() ?

A

strcpy(destinationArray, sourceArray)

69
Q

how is strcpy() different from strncpy()?

A

strncpy() takes an arg of destination, source, index

strncpy() copies everything UP TO the index

70
Q

function to get length of string

A

strlen()

71
Q

args for calloc() ?

A

calloc(number of elements, sizeof(type))

72
Q

code to make a duplicate of string array “Title”

A

char* pCopy = calloc( strlen(Title) + 1, sizeof(char) );

strncpy( pCopy, Title, strlen(Title) );

73
Q

what goes at the end of a main() function

A

return 0;

74
Q

static variables always

A

keep their values

75
Q

variables in a function (that are passed as args) that get modified by the function should be…

A

pointer type

76
Q

why would the terminal say that a command cannot be found after it was installed?

A

the directory where it was installed cannot be found in the path variable

77
Q

what does warning: implicit function declaration mean?

A

the function was not declared before main() OR in a header file

78
Q

how is an include statement for a header file IN a c file formatted?

A

“#include “

79
Q

when assigning a variable to a pointer you need…

A

&

80
Q

format specifier for string array vs char

A

string array -> %s

char -> %c

81
Q

what are you going to forget when scanning?

A

& for the variables and “” for the format

82
Q

what do we put in front of a variable in a function if we don’t want it to change

A

static

83
Q

what does free() do

A

deallocates the memory previously allocated by a call to calloc, malloc, or realloc

84
Q

what is a dangling pointer?

A

pointer pointing to a memory location that has been deleted (or freed)

85
Q

int **p = …;
ptr = *p;
what type is ptr?

A

int*

86
Q

args for realloc() ?

A

2 arguments, pointer to memory, new size in bytes

87
Q

size of char*

A

8 bytes