final Flashcards

General Knowledge (243 cards)

1
Q

sudo

A

execute command as root or superuser, also change into another user besides root with permission

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

cal

A

displays calendar in the terminal

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

cd

A

change to specific directory

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

date

A

display or set date and time

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

diff

A

compares files line by line, prints lines that are different

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

find

A

allows you to find files that exist in a directory that matches some pattern

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

grep

A

searches input files and looks for lines that match one or more patterns

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

gzip

A

compress or expand a list of files

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

less

A

view a file one page at a time, backwards or forwards.

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

ls

A

lists files in the current working directory

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

man

A

displays user manual for other commands

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

more

A

view a file one page at a time

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

pwd

A

the present working directory

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

scp

A

copy files securely between computers over network

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

sort

A

sort file, arranges records in particular order, can sort file alphabetically

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

ssh

A

secure way to access computer over an unsecured network by remote machine, transferring files between two machines, and for executing commands on the remote machine

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

tar

A

access collection of files and place them into a highly compressed archive file

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

wc

A

count number of lines, words and characters in a file by ls -1

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

wget

A

download files from the web

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

what is an operating system?

A

programs that manages computer’s hardware, provides base for application of programs and acts as an intermediary between user and hardware

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

SLOC

A

source lines of code

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

what is a kernel?

A

program that has complete control over everything that occurs in the system

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

what is a shell?

A

program that is spawned by the kernel and interacts with the user, providing an interface between the OS and the user

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

what is a process?

A

executing/running instance of a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
what is a program?
executable file that is held in storage
26
what is a virtual machine?
Emulator of a computer system. Provides an interface identical to the underlying bare hardware. Creates illusion of multiple processes, each executing on its own processor with its own virtual memory.
27
what is the preprocessor directive #include?
tells preprocessor to get a particular header file and add it to the code before compilation, add information about standard library routines
28
STDIN
standard in, input stream
29
STDOUT
standard out, output stream
30
STDERR
standard error, output stream for error messages
31
what is the preprocessor directive #define?
allows the definition of macros that are constants that are used throughout the code eg. #define SECONDS 60
32
ls -l
long listing format in current directory
33
ls -tl
long listing format ordered by time/date
34
ls -al
long listing format showing files starting with '.'
35
The UNIX Philosophy is according to?
Brian Kernighan
36
difference between #inlcude and #include "filename"
first: file is in systems directory second: file is in your directory
37
what does that standard library for the C programming language (libc) provide?
macros, type definitions, functions
38
Basics of UNIX Philosophy?
write programs that do one thing well, write programs to work together, write programs to handle text stream, everything is a file, write small single programs (modularity), ability to chain programs to peform complex tasks
39
UNIX Pipes
redirects output from one program into the input of another program, direct connection allows for simultaneous operations, data is transferred continuously
40
what does char *argv[ ] do?
stores an array of character strings
41
what is an array?
stores an ordered collection of things, where the order can be referenced by an index
42
what is the most basic program control structure?
if...else if...else
43
what does atoi( ) do?
ascii to integer, string to integer
44
what is a loop?
repetition of an action
45
what is a while loop?
executes while a condition is true
46
what is a for loop?
allows to specify 3 important aspects of looping in one place - start condition, end condition, and the change while looping
47
what are the 4 steps of problem solving?
understand, identify, develop plan, execute plan analyze and modify the problem
48
what are the four basic variable types?
int, char, float, double
49
what is a byte?
memory represented by bits; 1 or 0. Bits are grouped into bytes. Bytes are 8 bits long
50
what does the size of variable determine?
determines the range of numbers
51
two types of integers
signed or unsigned
52
signed integer
numbers can be positive, negative or zero
53
unsigned integer
numbers can be positive or zero
54
what is the range of integers?
4 bytes
55
how are negative signed ints represented?
in 2's complement format, changing the 0's to 1's and 1's to 0's, then adding 1
56
why use 2's complement?
fundamental arithmetic operations are identical to those on unsigned binary numbers, does not generate negative zero like other schemes
57
how many decimal digits of precision does a float have?
6 decimals
58
what is the range of floats?
4 bytes
59
how many decimal digits of precision does a double have?
15 decimals
60
what is the range of doubles?
8 bytes
61
what is the range of chars?
1 byte
62
why is a char a type of integer?
because C represents characters as integer numbers
63
int numbers are mapped to a character using?
ASCII, limited to 255 mappings or Unicode
64
arithmetic operators
addition, subtraction, multiplication, division, remainder
65
increment and decrement operators
change value by one, (++) or (--)
66
unary operators
operate on a single operand
67
prefix
perform action before any other action is taken
68
postfix
perform action after any other action is taken
69
what impacts result of a division operation?
based on the types of operands, if both are ints, result is an int. If one operand is floating, result can be float
70
what is modulo division and what is its restriction?
computes the remainder, and can only be used on integers
71
assignment operators
assigns value to integer, can also perform another operation ( += )
72
relational operators
used to form boolean expressions and decision making ( == ), ( != )
73
logical operators
used in boolean expressions, form basis of decision making ( && ), ( || ), ( ! )
74
sizeof operator
sizeof( ) returns the size of data as an unsigned long int
75
what is type casting?
the process of converting one type of data to another type FORMAT - fnum = (float) num
76
rules of thumb for comments
keep them brief, keep them to the point, three bears rule
77
different types of notations
Camel Case, Pascal Case, Hungarian, Snake Case, Kebab Case
78
Camel Case
first word is not capitalized - camelCase
79
Pascal Case
capitalize all words - PascalCase
80
what are the two types of Hungarian Notation?
systems hungarian, apps hungarian
81
Hungarian Notation
name starts with a lowercase prefix and indicates intention
82
Systems Hungarian
prefix indicates data types - intNumWidgets
83
Apps Hungarian
prefix indicates logical type - rowPosition and gives hint to the variable's purpose
84
Snake Case
words within phrases are separated with an underscore - first_name
85
Kebab Case
word within phrases are separated with a hyphen - first-name
86
Conventions of Identifiers representing macros (#define)
written in uppercase with underscores separating words in a phrase
87
Conventions for system functions
names contain double underscores or begin with an underscore and a capital letter
88
naming rule for arrays
give them names that are plural
89
naming rule for booleans
prefixes such as is, has, can
90
naming rule for numbers
use meaningful descriptive prefixes, such as max, min, total
91
what are curly braces used for?
surround blocks of code
92
what are the two styles of using curly braces
new line, end line
93
New Line Curly Braces
each curly brace is on its own line
94
End Line Curly Braces
first curly brace is on the same line as statement, end brace aligned with statement
95
what does ASCII stand for?
american standard code for information interchange
96
history
gives history of all commands used in the terminal
97
mkdir
make a new directory or sub directory
98
who was the inventor and co inventor of the UNIX pipes?
Doug McIlroy (inventor), Ken Thompson (co-developer)
99
advantages of VM
provides complete protection of system resources
100
disadvantages of VM
VM concept is difficult to implement, difficult to duplicate underlying machine
101
what are the four main components of a program structure?
preprocessor directives, main function, variables and statements, return function
102
what are the three file streams?
STDIN, STDOUT, STDERR
103
how to unzip gzip
gunzip "filename".tar.gz
104
how to unzip tar
tar -xvf "filename".tar
105
how to zip gzip
gzip "filename".tar
106
how to zip tar
tar cvf "filename".tar *.c
107
grep -i
not case restricted
108
date -f
command uses a format string to parse the date rather than using the default
109
Who developed the C language?
Brian Kernighan, Dennis Ritchie
110
#include
paste code of given file into the current file
111
#define
defines a macro which is a segment of code which is replaced by the value of the macro
112
#undef
cancels the definition of a macro
113
#ifdef
checks if a macro is defined by #define, if yes, execute the code
114
#ifndef
checks if a macro is not defined by #define, if yes, execute the code
115
#if
evaluates an expression or condition, it is it true, execute the code
116
#else
#if condition is false, the #else code is executed
117
#elif
else if construct
118
#endif
ends an if-else set of statements
119
#error
causes preprocessor to report a fatal error. the rest of the line following #error are used as the error message
120
#warning
causes the preprocessor to report a warning
121
#pragma
used to provide additional information to the compiler.
122
chgrp
change the group of ownership of a file or directory
123
chmod
changes access mode of a file
124
chown
change owner and group files, directories and links
125
cp
copy files + directories
126
mkdir
create directory
127
more
allows you to view a file one page at a time
128
mv
move files or drectories
129
rm
remove files or directories
130
history
shows all the last commands that have been recently used
131
clear
used to bring the command line on top of the computer terminal
132
echo
command in bash and C shells that writes arguments to standard output
133
bg
job control command, resumes suspended jobs in the background
134
all preprocessor directives
#include, #define, #pragma, #if, #else, #undef, #ifdef, #ifndef, #endif, #warning, #error
135
what does $ls -l | wc do?
lists files in current directory using long format, then prints out the number of lines, words, and characters generated by ls -l
136
how to read in characters?
fgets( variable, size, stdin ); chop( variable ); fflush( stdin );
137
how are ASCII characters stored?
in 8 bits -- 2^7, 2^6, ..., 2^0
138
examples of string operations
strcat, strcmp, strcpy, strlen
139
strcat
adds a string to the end of another string -- (char *dest, char *source );
140
strcmp
compares two strings, if the value is less than 0; s1 is less than s2, if the value is greater than 0; s2 is less than s1, if value is zero; the two strings are equal ( char *s1, char *s2 );
141
strcpy
copies one string to another string; | ( char *dest, char *source );
142
strlen
returns with the length of characters in a string; ex. char string[50]; int length; length = strlen( string );
143
arithmetic operators
+, -, *, /, %
144
relational operators
==, !=, >, =
145
logical operators
&&, ||, !
146
assignment operators
a+=b, a-=b, a%=b, a*=b, a/=b
147
sizeof( )
returns sizeof data ( data types, variables, ...) as an unsigned long int
148
casting
format: (type) expression ex. int num = 12; float fnum = 2.3; fnum = (float) num;
149
why to use indentation?
to show which statements are grouped together, used heavily in nested loops
150
why and when to use comments?
comment to help code reader, comment statements that are particularly confusing, comment blocks of code's function
151
function definition
group of statements that together perform a task
152
function declaration
declare before the main( ) function, in source file containing the mainline
153
function return
if function returns a value, data type must be defined in the function declaration
154
passing parameters by value
value of parameter in calling routine is copied into the value of the parameter in the function. changes made to parameter in function have no effect of the value of variable in the function.
155
passing parameters by reference
method tells the function where the actual parameters are in memory. variables in function are actual variables in the calling routine. AKA : passes by means of pointers
156
arrays and pointers
closely related, both contain address of a variable | ex. point = &array[0] OR pointer = array
157
pointer declarations
every pointer to a specific data type, if *iPointer points to int x, *iPointer can be used anywhere x could be used
158
pointer referencing
reference only has a variable that it is referencing. | datatype &referenceName = variable;
159
pointer dereferencing
access and manipulation of data. x = 5; int *p = &x; *p = 2 : makes *p usable in the same cases as x
160
preprocessor compilation
a separate program (cpp), invoked automatically by compiler before compilation
161
compiler
converts all the C source code into object code and puts it into a file ending in ".o", not directly executable unless you add code for all the library functions used by the function
162
linker
links together object files into binary executable- includes: .o files from source file, pre-compiled object files called into library files (.a or .sh)
163
.c files
source code files
164
.h files
header files
165
.o files
object files
166
compiler option : -o
specify all output executable name(s)
167
compiler option : -Wall
enables all warnings
168
compiler option : -c
produces only compiled code
169
compiler option : -lm
links with shared libraries
170
compiler option : -ansi
enables support of ISO c89 style
171
make
tool to simplify building program executables from many modules
172
static library
the result of the linker making copies of all called library functions to the executable. .a files are static libraries, created with the ar command
173
archives (ar)
program that creates a static library and can [c flag] - create static libraries [r flag] - add object files in static library [t flag] - list the name of .o files in the library ex. ar rc libutil.a chop.o trim.o reduceSpace.o
174
scanf( )
reads user input | ex. scanf( "%d", &num );
175
fscanf( )
stream pointer to a file stream | ex. int fscanf( FILE *stream, const char *format, ..., );
176
fgets( )
adjusts to read from any type of file, can specify buffer length to counter buffer overflow ex. char *fgets( char *str, int n, FILE *p );
177
fputs( )
writes string strPtr to file fp without the terminating byte '/0', returns non-negative on success or EOF on error
178
fprintf( )
similar to printf, but writes to a file instead of the screen, returns number of characters printed, excluding '/0'
179
text files
sequence of ASCII characters stored on a disk, each character stored as one byte equivalent to C strings
180
opening file
opened for reading/ writing, filename associated with file pointer, pointer points to structure with file info FILE *fp ex. fp = fopen( "filename", r );
181
closing file
fclose( fp );
182
reading file
done with the same commands to read from keyboard ( stdin stream )
183
writing file
fprintf, fputs
184
file pointer
FILE *fp | fp = fopen("filename", r);
185
file modes : r
open an existing file from reading; start at the beginning
186
file modes : w
create a new file for writing
187
file modes : a
append - open an existing file; write at the end of the file
188
file permission : chmod
octal mode : format ooo file ex. $chmod 744 file; symbolic mod: ex. $chmod u+rwx, g+rw, o+r file;
189
file permission : chown
change ownership of file, must have permission | ex. $chown owner filename;
190
file permission : chgrp
change group of the file, must have permission | ex. $chgrp group filename
191
file permission : file
determines file type | ex. $file testChop.c
192
file permission : touch
changing a file's modification date, can also create a blank file ex. $touch chop.c
193
struct definition
user-defined structure in C allows combination of different data types
194
struct declaration
``` struct name strName; struct name { member variable member variable } ```
195
passing structs to functions
three ways to pass structures: - pass individual members variables of struct by value to the function - pass individual members variables by pointer to func - pass entire structure by reference / pointer
196
testing strategies
- test systematically - test as you write - test boundary conditions - test pre- and post- conditions
197
program design
monolith approach and dividing the problem approach
198
monolith approach
everything is done in one main routine. | only use functions supplied by system.
199
dividing the problem
two criteria : form, function
200
dividing the problem : form
look at operations, think about the division of function based on branching
201
dividing the problem : function
looks at operations and construct functions based on results
202
dividing the problem : form advantages
easy to read and understand
203
dividing the problem : form disadvantages
everything needs to be changed to change the I/O
204
dividing the problem : function advantages
functions are light-weight and reusable
205
dividing the problem : function disadvantages
functions do not handle I/O
206
monolith approach : disadvantages
- long and hard to read - can be repetitions of previous code - hard to modify
207
model-view-controller
- software design-pattern used to develop user interfaces | - divides program into three interconnected elements
208
model-view-controller : model
directly manages data, logic and rules of application
209
model-view-controller : view
any representation of information
210
model-view-controller : controller
accepts inputs and converts it to commands
211
shell scripts : printing with echo
echo " there are " ... " files in directory "
212
shell scripts : setting variables
A = 1, B = "text string", C = $(date)
213
shell scripts : using variables
echo " A is $A "
214
shell scripts : capturing output of commands
variable = &( ... ) | echo "$variable"
215
shell scripts : arithmetic operations
$ (( expression )) operations: +,-,*,/,%,++,--,** ex. $ (( 20 + 5 ))
216
shell scripts : command line parameters
parm1 = $1, parm2 = $2 | ex. ./parms.sh one two
217
shell scripts : functions
``` ex. function totalFiles{ find $1 -typef | wc -l } home = /home/debs/Programs totalFiles $home ```
218
shell scripts : comparisons
-lt, -gt, -eq, -ne, -le, -ge
219
shell scripts : branching - if
``` if [ ... ]; then do this elif [ ... ]; then do this else do this fi ```
220
shell scripts : branching - for
``` FILES = "$@" for f in $FILES do do this done ```
221
shell scripts : branching - while
``` i = 0 while [ $i -le 4 ] do do this done ```
222
1-D Array
datatype name [size]
223
2-D Array
datatype name [size1] [size2] ``` int grid [3][4] = { {0,1,2,3}, {1,3,5,7}, {2,4,6,8}, }; ```
224
passing arrays to functions
1-D : pass by pointer 2-D : when both dimensions are macro when 2nd dimension is macro using a pointer when neither are macro pointer : displayArray(&field[0][0], row, col );
225
global scope variables
- variables accessible from everywhere, are macro constants | - great for system functions
226
local scope variables
- variables inside function | - variables in functions can have the same name
227
switch
- test value of a variable and compares it with cases - when match is found, execute code; break statement will terminates switch ex. switch ( expression ){ case 1: statements; break; default: statements; break; }
228
maximal munch
compiler will bite off the one with largest sequence of char | ex. z = y+++x; == z = y++ + x;
229
#include "limits.h"
for integer limits: INT_MIN, UINT_MIN, LONG_MIN, ULONG_MIN
230
#include "values.h"
for float: FLT_MIN | for double: DBL_MIN
231
static variables
- some functions wont work because variables are only in scope of function - static variables, not stored in stack format: static datatype name = value;
232
precedence
arithmetic, relational, logical
233
bitwise operators
- works on bits and performs bit-by-bit operators | includes: binary AND(&), binary OR( | ), binary(^)
234
binary AND
copies a bit to result it both operands exist
235
binary OR
if either operand exists
236
binary XOR
if only one exists
237
shift operators
to left (<>#)
238
conditional operator
returns a value when true, and another when false | ex. (A>100? 0 : 1 );
239
random( )
- function that uses a non-linear additive feedback random number generator - default table size of 31 long integers in range from 0 to RAND_MAX - period of generation 16^((2^31)-1)
240
srandom( )
- function sets its arguments as the seed for a new sequence of random integers to be returned by random() - if no seed --> uses seed with a value of 1
241
file modes : r+
open existing file for reading and writing; start at the beginning
242
file modes : w+
create new file for reading and writing; start at the beginning; truncates existing file
243
file modes : a+
open existing file for reading and writing; write to the end of the file