final Flashcards
General Knowledge
sudo
execute command as root or superuser, also change into another user besides root with permission
cal
displays calendar in the terminal
cd
change to specific directory
date
display or set date and time
diff
compares files line by line, prints lines that are different
find
allows you to find files that exist in a directory that matches some pattern
grep
searches input files and looks for lines that match one or more patterns
gzip
compress or expand a list of files
less
view a file one page at a time, backwards or forwards.
ls
lists files in the current working directory
man
displays user manual for other commands
more
view a file one page at a time
pwd
the present working directory
scp
copy files securely between computers over network
sort
sort file, arranges records in particular order, can sort file alphabetically
ssh
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
tar
access collection of files and place them into a highly compressed archive file
wc
count number of lines, words and characters in a file by ls -1
wget
download files from the web
what is an operating system?
programs that manages computer’s hardware, provides base for application of programs and acts as an intermediary between user and hardware
SLOC
source lines of code
what is a kernel?
program that has complete control over everything that occurs in the system
what is a shell?
program that is spawned by the kernel and interacts with the user, providing an interface between the OS and the user
what is a process?
executing/running instance of a program
what is a program?
executable file that is held in storage
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.
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
STDIN
standard in, input stream
STDOUT
standard out, output stream
STDERR
standard error, output stream for error messages
what is the preprocessor directive #define?
allows the definition of macros that are constants that are used throughout the code eg. #define SECONDS 60
ls -l
long listing format in current directory
ls -tl
long listing format ordered by time/date
ls -al
long listing format showing files starting with ‘.’
The UNIX Philosophy is according to?
Brian Kernighan
difference between #inlcude and #include “filename”
first: file is in systems directory
second: file is in your directory
what does that standard library for the C programming language (libc) provide?
macros, type definitions, functions
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
UNIX Pipes
redirects output from one program into the input of another program, direct connection allows for simultaneous operations, data is transferred continuously
what does char *argv[ ] do?
stores an array of character strings
what is an array?
stores an ordered collection of things, where the order can be referenced by an index
what is the most basic program control structure?
if…else if…else
what does atoi( ) do?
ascii to integer, string to integer
what is a loop?
repetition of an action
what is a while loop?
executes while a condition is true
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
what are the 4 steps of problem solving?
understand, identify, develop plan, execute plan analyze and modify the problem
what are the four basic variable types?
int, char, float, double
what is a byte?
memory represented by bits; 1 or 0. Bits are grouped into bytes. Bytes are 8 bits long
what does the size of variable determine?
determines the range of numbers
two types of integers
signed or unsigned
signed integer
numbers can be positive, negative or zero
unsigned integer
numbers can be positive or zero
what is the range of integers?
4 bytes
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
why use 2’s complement?
fundamental arithmetic operations are identical to those on unsigned binary numbers, does not generate negative zero like other schemes
how many decimal digits of precision does a float have?
6 decimals
what is the range of floats?
4 bytes
how many decimal digits of precision does a double have?
15 decimals
what is the range of doubles?
8 bytes
what is the range of chars?
1 byte
why is a char a type of integer?
because C represents characters as integer numbers
int numbers are mapped to a character using?
ASCII, limited to 255 mappings or Unicode
arithmetic operators
addition, subtraction, multiplication, division, remainder
increment and decrement operators
change value by one, (++) or (–)
unary operators
operate on a single operand
prefix
perform action before any other action is taken
postfix
perform action after any other action is taken
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
what is modulo division and what is its restriction?
computes the remainder, and can only be used on integers
assignment operators
assigns value to integer, can also perform another operation ( += )
relational operators
used to form boolean expressions and decision making ( == ), ( != )
logical operators
used in boolean expressions, form basis of decision making ( && ), ( || ), ( ! )
sizeof operator
sizeof( ) returns the size of data as an unsigned long int
what is type casting?
the process of converting one type of data to another type FORMAT - fnum = (float) num
rules of thumb for comments
keep them brief, keep them to the point, three bears rule
different types of notations
Camel Case, Pascal Case, Hungarian, Snake Case, Kebab Case
Camel Case
first word is not capitalized - camelCase
Pascal Case
capitalize all words - PascalCase
what are the two types of Hungarian Notation?
systems hungarian, apps hungarian
Hungarian Notation
name starts with a lowercase prefix and indicates intention
Systems Hungarian
prefix indicates data types - intNumWidgets
Apps Hungarian
prefix indicates logical type - rowPosition and gives hint to the variable’s purpose
Snake Case
words within phrases are separated with an underscore - first_name
Kebab Case
word within phrases are separated with a hyphen - first-name
Conventions of Identifiers representing macros (#define)
written in uppercase with underscores separating words in a phrase
Conventions for system functions
names contain double underscores or begin with an underscore and a capital letter
naming rule for arrays
give them names that are plural
naming rule for booleans
prefixes such as is, has, can
naming rule for numbers
use meaningful descriptive prefixes, such as max, min, total
what are curly braces used for?
surround blocks of code
what are the two styles of using curly braces
new line, end line
New Line Curly Braces
each curly brace is on its own line
End Line Curly Braces
first curly brace is on the same line as statement, end brace aligned with statement
what does ASCII stand for?
american standard code for information interchange
history
gives history of all commands used in the terminal
mkdir
make a new directory or sub directory