Posix + git Flashcards Preview

SWTools > Posix + git > Flashcards

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

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

2

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

3

What port is used by SSH

TCP port 22

4

What does the command uname -a do?

Prints all information about the current operating system

5

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

whoami

6

What command is used to create a new key pair?

ssh-keygen -t ed25519

7

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

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

8

What does the scp command do?

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

9

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

[USERNAME@]HOSTNAME:PATH

10

What is the format of chmod command?

chmod bit_field file_name. I.e. chmod 600 config

11

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)

12

What is vagrant?

A program to manage VMs through another program like virtualbox.

13

What does the which command do?

It tells you the location of a given command

14

What is Busybox

It's a distribution of the common POSIX commands

15

What kind of files are usually stored in /etc?

System wide configuration files usually only editable by root

16

What is musl?

A lightweight implementaiton of the C standard library

17

What kind of files are stored in /lib?

Dynamic libraries like the C library

18

What does /sbin or /usr usually contan?

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

19

What does /tmp store?

Temporary files that may live in RAM

20

What does /var store?

Files that vary over time like caches or logs

21

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

22

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.

23

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

apk info -a [name of package]

24

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

sudo apk update
sudo apk upgrade

25

What are 3 ways of turning off pattern matching?

1. ""
2. ''
3.\

26

What is good practice when setting and using shell variables?

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

27

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

28

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

29

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)

30

How to check if a user has been added?

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

31

How to add a user to a specific group?

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

32

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.

33

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

34

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

35

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

36

What is mount/unmounting for?

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

37

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.

38

What command(s) remove duplicate lines in linux?

... sort | uniq ...

39

What is concurrent programming?

When 2 or more processes are happening at the same time

40

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.

41

How do you extract a tar file?

tar xvf file_name.tar

42

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

bTo run something as a script

43

What's a primary key?

A candidate key designated to uniquely identify each row

44

What's a composite key?

A key conformed by many attributes

45

Define 1NF

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

46

What's a superkey?

A single or set of columns that are unique

47

What's a superkey?

A single or set of columns that are unique

48

What's a key attribute?

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

49

What's a functional dependency?

When one or more columns can uniquely identify another column

50

What's a trivial functional dependency?

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

51

Define 2NF

Conforms to 1NF plus there are no partial functional dependencies

52

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

53

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

54

Define 3NF

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

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

56

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

57

When doesn't 3NF imply BCNF?

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

58

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

59

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

60

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

There's no difference in the output.

61

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

62

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.

63

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

64

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.

65

How is an artefact defined in Maven?

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

66

What do system calls do?

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

67

Which port do databases connect to by default?

TCP 3306

68

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.

69

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.

70

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)

71

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)

72

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)

73

What's asynchronicity?

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

74

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

75

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

76

What's the application layer?

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

77

What's the internet/network layer?

IP - lower level protocol for dealing with data transmission

78

What's the network access layer?

data link and physical network - ready to send the data

79

What's the advantage of using web frameworks?

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

80

What's the disadvantage of using web frameworks?

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

81

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

82

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

83

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

84

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

85

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

86

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

apk info --who-owns [file_path]

87

What are the most common apk commands?

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

88

What are reasons for virtualizing?

- Emulate a different stack
- Cost/scalability

89

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)

90

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.

91

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.

92

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

93

Other commands

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

94

Other commands

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

95

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)

96

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