2505 Test 1 Review Flashcards

(87 cards)

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
command to change permissions
chmod
26
command to take away read and write permissions from group from file "foo"
chmod g-rw [path to foo]
27
how would chmod 740 change permissions for each group
owner: r w x group: r - - other: - - -
28
numeric args for chmod
no access - 0 execute - 1 write - 2 read - 4
29
command to create a collection of files
tar cvf [newTar] [targetFile]
30
command to check contents of tar file
tar tvf [tarFile]
31
flat tar files have no...
path listed/directory structure
32
what happens if you tar a dir?
the tar file will contain path info
33
command to extract a tar file
tar xvf [tarName] (-C [destination])
34
commands to unzip zip, gzip, and bzip2 files
unzip, gunzip, bunzip2
35
SPECIAL CHARACTER RULE for ?
match any single character
36
SPECIAL CHARACTER RULE for *
match 0 or more characters
37
SPECIAL CHARACTER RULE for []
match any of the characters within the braces
38
SPECIAL CHARACTER RULE for *.txt
match any file with the ext txt
39
SPECIAL CHARACTER RULE for [abc]foo.html
match a file with html ext and name "afoo" "bfoo" "cfoo"
40
what does scp do?
copy a file between the local machine and remote machine
41
command to copy a file to rlogin
scp foo.txt username: targetDir
42
command to copy file FROM rlogin to the current dir
scp user: documents/foo.txt
43
create an int pointer named point
int *point;
44
assign the value of int "foo" to the int pointer "point"
point = &foo;
45
store the value of "foo" which pointer "point" points to in a NEW int variable called "var2"
int var2 = *point;
46
when assigning char pointers to string ARRAYS, do you need an & ?
NO
47
how many bytes is an int?
4 bytes
48
C function to find out how many bytes a data type is
sizeof(dataType)
49
assign initialized char pointer "point" to a char input of n using malloc
point = (char*)malloc(n*sizeof(char));
50
what is the type of &p if p is a char pointer with a target?
char**
51
int* q = NULL; is *q = 20; valid?
No because q has no target. There will be a segfault error
52
When a pointer's target becomes NULL what is the value of the pointer?
The pointer does not exist
53
int* p = &A; int* q = &B; p = q; What does p point to now?
B
54
meaning of %d
base-10 integer
55
absolute value function
abs()
56
formatting to show 2 digits after decimal point in W columns
%W.2f
57
external linkage
not "static", declared AND initialized outside function
58
internal linkage
static variable outside function
59
no linkage
vars inside a function
60
what goes at the top of a header called "foo.h"?
``` #ifndef FOO_H #define FOO_H ``` #endif
61
static storage duration
Variables declared outside of everything or with "static"
62
command to create an executable for debugging
gcc -o executableName -std=c11 -Wall -ggdb3 (list C files ONLY)
63
while loop to use with fscanf
while(fscanf(fileName,"format", variables) == numOfVariables)
64
whats the common format of a main() function?
``` int main(int argc, char* argv[]) { } ```
65
what happens if you accidentally call a c file where the new tar file name should be?
the c file will get overwritten with a tar file of the same name
66
when assigning a char ELEMENT to a char pointer do you need & ?
YES
67
what does calloc() do
allocates the memory and also initializes the allocated memory block to zero
68
args for strcpy() ?
strcpy(destinationArray, sourceArray)
69
how is strcpy() different from strncpy()?
strncpy() takes an arg of destination, source, index | strncpy() copies everything UP TO the index
70
function to get length of string
strlen()
71
args for calloc() ?
calloc(number of elements, sizeof(type))
72
code to make a duplicate of string array "Title"
char* pCopy = calloc( strlen(Title) + 1, sizeof(char) ); | strncpy( pCopy, Title, strlen(Title) );
73
what goes at the end of a main() function
return 0;
74
static variables always
keep their values
75
variables in a function (that are passed as args) that get modified by the function should be...
pointer type
76
why would the terminal say that a command cannot be found after it was installed?
the directory where it was installed cannot be found in the path variable
77
what does warning: implicit function declaration mean?
the function was not declared before main() OR in a header file
78
how is an include statement for a header file IN a c file formatted?
"#include "
79
when assigning a variable to a pointer you need...
&
80
format specifier for string array vs char
string array -> %s | char -> %c
81
what are you going to forget when scanning?
& for the variables and "" for the format
82
what do we put in front of a variable in a function if we don't want it to change
static
83
what does free() do
deallocates the memory previously allocated by a call to calloc, malloc, or realloc
84
what is a dangling pointer?
pointer pointing to a memory location that has been deleted (or freed)
85
int **p = …; ptr = *p; what type is ptr?
int*
86
args for realloc() ?
2 arguments, pointer to memory, new size in bytes
87
size of char*
8 bytes