Posix + git Flashcards Preview

SWTools > Posix + git > Flashcards

Flashcards in Posix + git Deck (96)
Loading flashcards...

What is SSH?

Secure shell (SSH) is a protocol to allow you to remotely log in to another computer. SSH is the client which you run in your machine. The way it works is that the machine you're trying to connect sends you a challenge which your private key solves and sends the result to the host machine which verifies it via your public key


What is SSHD?

sshd is the server, or daemon in UNIX-speak. It runs in the background on the machine you want to connect to


What port is used by SSH

TCP port 22


What does the command uname -a do?

Prints all information about the current operating system


What command is used to check what user is currently using the computer?



What command is used to create a new key pair?

ssh-keygen -t ed25519


What do each of the brackets represent? (-)(---)(---)(---)

1. File type
2. Owner
3. Group
4. Everyone else


What does the scp command do?

It stands for secure copy and allows you to copy files over SSH


scp syntax is: scp source destination. What form can source/destination take?



What is the format of chmod command?

chmod bit_field file_name. I.e. chmod 600 config


How to activate agent forwarding for SSH and what does it do?

-Activate with -A flag
-It allows to reuse same private key in your machine to access machines from a machine other than your own (if you already connected to that machine via SSH)


What is vagrant?

A program to manage VMs through another program like virtualbox.


What does the which command do?

It tells you the location of a given command


What is Busybox

It's a distribution of the common POSIX commands


What kind of files are usually stored in /etc?

System wide configuration files usually only editable by root


What is musl?

A lightweight implementaiton of the C standard library


What kind of files are stored in /lib?

Dynamic libraries like the C library


What does /sbin or /usr usually contan?

System binaries and readonly data like configuration files but not temp data respectively


What does /tmp store?

Temporary files that may live in RAM


What does /var store?

Files that vary over time like caches or logs


What are /dev, /sys, and /proc used for?

-/dev - interface for devices like hard disks
-/sys - system functions (i.e. changing screen brightness)
-/proc - running processes


What's a package manager and what is its main benefit? (according to david's notes)

It allows you to install packages from a repository and it has the advantage of installing dependencies automatically.


What command do you use to figure out what dependencies a package depends on? (alpine linux)

apk info -a [name of package]


What are the two commands that should be run regularly by system administrators?

sudo apk update
sudo apk upgrade


What are 3 ways of turning off pattern matching?

1. ""
2. ''


What is good practice when setting and using shell variables?

Set the variable inside "" and use it inside "". I.e. p = "silly name" , "$p"


What file is processed by bash when it startups up and what you can do with it?

.profile - you can configure the default text editor for instance


What's the difference between git revert and git reset

Git revert creates a new commit by changing the files to the state at which they were in a previous commit. Git reset moves the HEAD pointer to the commit that you want and leaves the working copy intact unless you specify --hard


How do you show the current user in the prompt?

You have to edit the profile file in /etc/ to include the user in PS1(prompt level 1)


How to check if a user has been added?

- tail /etc/passwd
- tail /etc/group


How to add a user to a specific group?

(from root) sudo adduser [user] [group-name]


What is the setuid used for?

To give normal users the right to execute programs as root. I.e. to execute specific programs in a dir from another user where they wouldn't normally have w/x rights.


What does the sticky bit do in a directory file?

It allows only the person who creates a file in the dir to be able to edit and rename them. Other people, although they have write permission to dir, cannot edit your file. Usually seen in /tmp


What does it mean to set the SGid on a folder?

That if someone inside that dir creates a file, the file adopts the group for the dir, not of the creator of the file


What's the purpose of the /etc/sudoers file?

It configures what sudo is allowed to do. I.e deciding who's allowed to reboot to shutdown the machine


What is mount/unmounting for?

Attaching an external filesystem to your local filesystem (i.e. from a USB or external disk)


What does a rebase do?

It can be used to resolve a conflict by pretending that everything in origin happened before you started your changes.


What command(s) remove duplicate lines in linux?

... sort | uniq ...


What is concurrent programming?

When 2 or more processes are happening at the same time


Why does the PID increase by 2 when running the launch program that executes a program within another program?

Beacause the fork means that there's a child and parent process being execute. Those are 2 PID.


How do you extract a tar file?

tar xvf file_name.tar


What is the -e flag used for in the shell?

bTo run something as a script


What's a primary key?

A candidate key designated to uniquely identify each row


What's a composite key?

A key conformed by many attributes


Define 1NF

No collection-valued attributes (lists,sets,CSV)


What's a superkey?

A single or set of columns that are unique


What's a superkey?

A single or set of columns that are unique


What's a key attribute?

A column/attribute that's part of a candidate key


What's a functional dependency?

When one or more columns can uniquely identify another column


What's a trivial functional dependency?

When the column uniquely identified by the other columns forms part of the latter set.


Define 2NF

Conforms to 1NF plus there are no partial functional dependencies


What's a partial functional dependency?

A fd (A -> B) where A is part of a candidate key (but not all of it) and B is non-key


Why are partial functional dependencies considered a violation of 2NF?

Consider candidate key {A, B}

If A -> C, and C is non-key this is a partial fd and it expresses that C is an attribute of A but not of B. Hence, it can cause repetitive values and it'd be better to put C in another table together with a copy of col A to achieve 2NF


Define 3NF

Conforms to 2NF plus there are not transitive functional dependencies. No dependencies between non key attributes.
A -> B -> C . where B and C are non-key


How to achieve lossless decompisition?

If you have a table with 3 sets of column(s) where there is A -> B which is annoying. You can put A -> B in one table and A -> C in another. You won't lose any information this way. Gets you 2NF and 3NF


Describe BCNF

Conforms to 3NF plus the determinant of every non trivial FD is a superkey. This means only FDs allowed are ones that arise from a superkey
{A} -> B. where A is superkey


When doesn't 3NF imply BCNF?

When there are overlapping composite candidate keys.
Table: A,B,C
FD1: A -> C
FD2: B -> C


What's the difference between the "WHERE" and "HAVING" clauses in SQL?

The latter is evaluated after the "group by" and after aliases. Thus, it applies to the groups formed by the group by command


What kind of columns are permitted to be selected in an statistics query?

Stats (i.e. avg(cost)), constants, columns used in the group by


What's the difference between count(1) and count(*)?

There's no difference in the output.


What are the steps involved in building a C program?

Compiling and linking (with libc or other libraries, and crt (c runtime written in assembly))


How to make sure a C project is compatible with different OS's?

Through a configure program which tests your shell and compiler to see what kind you have and uses that info to create a makefile and config.h file that you can include in your C files.


What are the 3 stages (as a user) to run a C file from another creator?

1. ./configure
2. make (optional: test)
3. make install


What does the ./configure file check for specifically?

Whether your system has a C compiler.
Whether your C compiler is gcc.
Whether your C compiler actually works.


How is an artefact defined in Maven?

-groupId (provider)
-artifactId (specific artifact/package)


What do system calls do?

Retrieve3 information about files (stat, lstat(link), fstat(file desc)


Which port do databases connect to by default?

TCP 3306


What's a prepared statement and why is it useful?

It's a pattern where you hardcode an SQL command except the parameters which you leave blank with placeholders. In the second phase(execute), that's when you input the actual parameters after the command has been compiled. It's useful to avoid SQL injection.


What's JDBC and how do you use it?

A low-level API to interact with databases. You start by connecting via a connection string, then you input the prepared statement via a try with block, you bind your parameters and iterate over the result set to do what you want to do with the output.


What does statelessness mean?

Decoupling of frontend from backend. Server is able to respond to a request just from the information contained in the request and nothing else (client not needed)


What is REST?

It's a software architectural style (representational state transfer) which has the following features:
- Client server separation of concerns: client and server decoupled (good for scalability)
- Statelessness - request has all information needed, server doesn't need client
- Cacheability - HTTP responses should be cacheable
- Uniform interface - same commands (get, put)


What is REST?

It's a software architectural style (representational state transfer) which has the following features:
- Client server separation of concerns: client and server decoupled (good for scalability)
- Statelessness - request has all information needed, server doesn't need client
- Cacheability - HTTP responses should be cacheable
- Uniform interface - same methods (get, put)


What's asynchronicity?

Code that doesn't immediately reutrns value but returns a promise. I.e. due to making a call to the API


JDBC vs Hibernate

JCBC lets Java connect to database
hibernate let you define queries each with Java type
get result as Java classes
mapping SQL database to Java objects


What's TCP?

Method of transferring data throughout the internet reliably. This means that you make sure you’re sending everything you need to send and receiving everything you need to receive


What's the application layer?

High-level protocols such as SSH, HTTP, HTTPS, SMTP. Data is already meaningful on this layer


What's the internet/network layer?

IP - lower level protocol for dealing with data transmission


What's the network access layer?

data link and physical network - ready to send the data


What's the advantage of using web frameworks?

Open source so it leads to greater quality of security, performance etc.,


What's the disadvantage of using web frameworks?

learning curve, overkill for simple tasks, potential vulnerabilities, fixed programming paradigm


What are UNIX's principles?

1.Everyting is a file
2.Use of readers and writers to accomplish larger tasks
3.Programs can communicate using streams of ASCII


Why is UNIX separated into kernel and userland?

User contains the shell which runs the programs sed by users (i.e. ls). Kernet was historically used to coordinate timesharing and concurrent processes


What is the historical reason for xOFF and xON and what are they equivalent to?

xOFF is ctrl-S
xON is ctrl-Q
It was meant to tell the shell that it's going to fast so pause until teletype could catch up and continue printing


What's the line discipline?

It's a kernel module located between driver and shell. Concerned with input from teletype and it contains a buffer that gathers information a line at a time


How do you turn off the kernel and C lib bufers?

- stty raw
- setbuf(file, NULL)
- stdbuf -o0 incase you're running someone else's C program which stops in the middle and you need to redirect output to a file


How to check which package is responsible for a particular file?

apk info --who-owns [file_path]


What are the most common apk commands?

apk search
apk list
apk info
sudo apk add
sudo apk update
sudo apk upgrade


What are reasons for virtualizing?

- Emulate a different stack
- Cost/scalability


What's the difference between a VM and a container?

A container is like a lightweight VM where only programs and libraries are isolated (i.e. able to use different version of python for different programs)


What's the difference between a fake and real conflict?

A fake conflict occurs when 2 people have worked on different files in parallel and have committed.


What's the problem with soving a fake conflict via fast forward?

The problem is that there might be issues if files are dependent in a way. I.e. person A works on main and changes it. Person B writes documentation nfor main on README.md. It's a fake conflict but person B has actually written doc for previous version of main.c before person A had edited it.


How are natural joins used?

When you want to do a join between two entities on a specific attribute that is named the same in both entities. It's just a shortcut for an inner join, less verbose. SELECT name, title FROM lecturer NATURAL JOIN unit


Other commands

IN - checks for existence in list
ALL - compares value against all values in list
EXISTS - checks for existence in list


Other commands

IN - checks for existence in list
ALL - compares value against all values in list
EXISTS - checks for existence in list


How does Hibernate work?

It has JPA annotations to tell the program what's what. It connects via a connection string using a session factory. Then you can do typed queries to query for a type-safe result. Here you can set a parameter like (binding in JDBC)


What's the n+1 problem and how's it solved?

Hibernate doesn't join unless explicit. It gives you a proxy object. N+1 problem is that it fires off n+1 queries for a given operation where n is the number of objects. To solve it you have to specify where you want to join with anticipation