Posix + git Flashcards

1
Q

What is SSH?

A

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

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

What is SSHD?

A

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

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

What port is used by SSH

A

TCP port 22

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

What does the command uname -a do?

A

Prints all information about the current operating system

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

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

A

whoami

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

What command is used to create a new key pair?

A

ssh-keygen -t ed25519

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

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

A
  1. File type
  2. Owner
  3. Group
  4. Everyone else
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the scp command do?

A

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

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

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

A

[USERNAME@]HOSTNAME:PATH

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

What is the format of chmod command?

A

chmod bit_field file_name. I.e. chmod 600 config

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

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

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is vagrant?

A

A program to manage VMs through another program like virtualbox.

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

What does the which command do?

A

It tells you the location of a given command

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

What is Busybox

A

It’s a distribution of the common POSIX commands

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

What kind of files are usually stored in /etc?

A

System wide configuration files usually only editable by root

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

What is musl?

A

A lightweight implementaiton of the C standard library

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

What kind of files are stored in /lib?

A

Dynamic libraries like the C library

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

What does /sbin or /usr usually contan?

A

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

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

What does /tmp store?

A

Temporary files that may live in RAM

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

What does /var store?

A

Files that vary over time like caches or logs

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

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

A
  • /dev - interface for devices like hard disks
  • /sys - system functions (i.e. changing screen brightness)
  • /proc - running processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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

A

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

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

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

A

apk info -a [name of package]

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

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

A

sudo apk update

sudo apk upgrade

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

What are 3 ways of turning off pattern matching?

A
  1. ””
  2. ’’
  3. \
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is good practice when setting and using shell variables?

A

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

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

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

A

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

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

What’s the difference between git revert and git reset

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How do you show the current user in the prompt?

A

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

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

How to check if a user has been added?

A
  • tail /etc/passwd

- tail /etc/group

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

How to add a user to a specific group?

A

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

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

What is the setuid used for?

A

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.

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

What does the sticky bit do in a directory file?

A

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

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

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

A

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

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

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

A

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

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

What is mount/unmounting for?

A

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

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

What does a rebase do?

A

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

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

What command(s) remove duplicate lines in linux?

A

… sort | uniq …

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

What is concurrent programming?

A

When 2 or more processes are happening at the same time

40
Q

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

A

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

41
Q

How do you extract a tar file?

A

tar xvf file_name.tar

42
Q

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

A

bTo run something as a script

43
Q

What’s a primary key?

A

A candidate key designated to uniquely identify each row

44
Q

What’s a composite key?

A

A key conformed by many attributes

45
Q

Define 1NF

A

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

46
Q

What’s a superkey?

A

A single or set of columns that are unique

47
Q

What’s a superkey?

A

A single or set of columns that are unique

48
Q

What’s a key attribute?

A

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

49
Q

What’s a functional dependency?

A

When one or more columns can uniquely identify another column

50
Q

What’s a trivial functional dependency?

A

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

51
Q

Define 2NF

A

Conforms to 1NF plus there are no partial functional dependencies

52
Q

What’s a partial functional dependency?

A

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

53
Q

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

A

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

54
Q

Define 3NF

A

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

55
Q

How to achieve lossless decompisition?

A

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

56
Q

Describe BCNF

A

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
Ex:
{A} -> B. where A is superkey

57
Q

When doesn’t 3NF imply BCNF?

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

What’s the difference between the “WHERE” and “HAVING” clauses in SQL?

A

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

59
Q

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

A

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

60
Q

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

A

There’s no difference in the output.

61
Q

What are the steps involved in building a C program?

A

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

62
Q

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

A

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.

63
Q

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

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

What does the ./configure file check for specifically?

A

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

65
Q

How is an artefact defined in Maven?

A
  • groupId (provider)
  • artifactId (specific artifact/package)
  • version
66
Q

What do system calls do?

A

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

67
Q

Which port do databases connect to by default?

A

TCP 3306

68
Q

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

A

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.

69
Q

What’s JDBC and how do you use it?

A

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.

70
Q

What does statelessness mean?

A

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)

71
Q

What is REST?

A

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)
72
Q

What is REST?

A

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)
73
Q

What’s asynchronicity?

A

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

74
Q

JDBC vs Hibernate

A

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

75
Q

What’s TCP?

A

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

76
Q

What’s the application layer?

A

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

77
Q

What’s the internet/network layer?

A

IP - lower level protocol for dealing with data transmission

78
Q

What’s the network access layer?

A

data link and physical network - ready to send the data

79
Q

What’s the advantage of using web frameworks?

A

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

80
Q

What’s the disadvantage of using web frameworks?

A

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

81
Q

What are UNIX’s principles?

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

Why is UNIX separated into kernel and userland?

A

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

83
Q

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

A

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

84
Q

What’s the line discipline?

A

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

85
Q

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

A
  • 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
86
Q

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

A

apk info –who-owns [file_path]

87
Q

What are the most common apk commands?

A
apk search
apk list
apk info
apk
sudo apk add
sudo apk update
sudo apk upgrade
88
Q

What are reasons for virtualizing?

A
  • Emulate a different stack

- Cost/scalability

89
Q

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

A

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)

90
Q

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

A

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

91
Q

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

A

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.

92
Q

How are natural joins used?

A

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

93
Q

Other commands

A

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

94
Q

Other commands

A

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

95
Q

How does Hibernate work?

A

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)

96
Q

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

A

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