finals Flashcards

1
Q

what does a package manager do?

A

makes it easy for users to manage software on their system. Allows you to do stuff like install, remove, update software

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

What is an advantage of package manager?

A

generally handle dependencies. If a package needs additional software to run, the package manager will install it too

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

What is one of the few tools that makes one Linux distro different from another?

A

the package manager. And diff distros will have different packages in their package repositories

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

What’s the package manager for Arch Linux?

A

pacman

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

What’s the package manager for Ubuntu?

A

apt

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

What’s the package manager for Nix?

A

nix

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

What is one of the reasons Arch Linux is so popular?

A

it has a lot of packages and those packages are generally up-to-date

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

Which distro has the largest package repository? By how much?

A

Nix. By ~30% more

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

pacman command to refresh local package repository?

A

pacman -Sy

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

pacman command to upgrade isntalled packages

A

pacman -Syu

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

pacman command to install one or more packages and any dependencies

A

pacman -S <packages>

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

pacman command to search for a packages

A

pacman -Ss <search term>

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

pacman command to remove a package, configuration files, and package dependencies

A

packman -Rns <packages>

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

pacman command to display remote information about a package. To display extensive info about a given package??

A

pacman -Si <package>

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

what is getopts? What arguments does it take?

A

it’s a shell builtin that can be used to handle options in shells scripts.

it takes 3 arguments:
- valid options that will be handled
- a variable populated with option arguments (ie “${opt}” )
- a list of options and arguments to be processed $@

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

what is optarg?

A

when a flag is set to expect an argument, the argument for that flag is held in the OPTARG variable (eg. my_script -n “ted” <– the OPTARG for -n is the string “ted”)

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

how to tell getopts to run in silent error checking mode?

A

Put a colon in the options string

eg. “:a:b:”
the first : tells it to run in silent error checking mode

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

what does “shift” do?

A

Shift positional parameters n characters to the LEFT (default is 1 character).
Cannot undo it (no “unshift”).
Shifts are cumulative

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

how to shift positional parameters to remove any options handled by getopts

A

shift $(($OPTIND -1))

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

do the flags and flag options come first or the positional arguments?

A

flags and flag options should be provided before positional arguments

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

how to check if there are positional parameters

A

shift $(($OPTIND -1))

if [[ $# -lt 1 ]]; then
echo “….”
exit 1
fi

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

What’s FTP?

A

File Transfer Protocol

Popular method of transferring files to and from remote servers

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

Why was FTP deprecated?

A

Lack of security features

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

What’s SFTP?

A

Secure(or SSH) File Transfer Protocol

provides functionality similar to FTP, but uses SSH for security

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

How to get the help menu for sftp?

A

?
or
help

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

What’s the sftp command to make a local directory? To make a remote directory?

A

local directory:
lmkdir dir-name

remote directory:
mkdir dir-name

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

how to download a file from remote server?

A

Connect via sftp. Then:
get file-path

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

How to upload a file via sftp?

A

put file-path

file will be uploaded to the users home directory

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

Vim: what does gg do?

A

go to beginning of file

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

Vim: what does =G do?

A

indent and go to file end

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

Vim: how do you move to the first instance of a character in a line?

A

f <character>

eg. f g
will move to the first instance of the letter g on the current line

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

What can pacman do?

A

can install, update, remove packages

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

What’s a package and what does it contain?

A

A package is an archive.
It contains:
o All of the compiled files of an application
o Metadata about the app (eg. app name, version, dependencies, etc)
o Installation files and directives for pacman
o (optionally) extra files to make your life easier (eg. a start/stop script)

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

benefits of using packages instead of compiling and installing programs yourself

A

o Easily updatable
o Dependency checks
o Clean removal

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

why should you use “pacman -Syu package_nam” instead of “pacman -Sy package_name”

A

in practice, do not run “pacman -Sy package_name” cuz it can lead to dependency issues

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

How to install single package or list of packages?

A

pacman -S package_name1 package_name2

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

What’s a virtual package?

A

Special package that does not exist by itself but is provided by 1 or more other packages. Virtual packages cannot be installed by their name; they’re installed when you have installed a package providing the virtual package

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

To remove a single package but leave its dependencies installed

A

pacman -R package_name

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

To remove package and its dependencies not required by other packages

A

pacman -Rs package_name

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

To remove package that’s required by another packages without removing the dependent package

A

pacman -Rdd package_name

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

To search for already installed package

A

pacman -Qs string1 string2

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

To list all packages no longer required as dependencies (orphans)

A

pacman -Qdt

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

Pacman stores downloaded packages where?

A

/var/cache/pacman/pkg/

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

Does pacman remove old or uninstalled versions automatically? Yes or no, and what are the advantages?

A

No.
o Allows downgrade without having to retrieve previous version through other means
o Package that has been uninstalled can easily be reinstalled directly from cahce directory without new download from the repository

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

How to delete all cached versions of installed and uninstalled packages except for the most recent 3

A

paccache -r

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

To remove all cached packages not currently installed and unused sync databases

A

pacman -Sc

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

How to download package without installing it

A

pacman -Sw package_name

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

What is a “unit”?

A

any resource/object that systemd knows how to manage

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

What is a unit file?
Where are systemd unit files found?

A

unit file is a plain text ini-style file that encodes information about a service, socket, device,… controlled and supervised by systemd

/usr/lib/systemd/system
/run/systemd/system
/etc/systemd/system

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

Where are the system’s copy of unit files? The systemd unit files distributed with installed RPM

A

/usr/lib/systemd/system

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

Where are dynamically created unit files created at runtime

A

/run/systemd/system

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

What should you do if you need to modify the system’s copy of a unit file?

A

create a unit file here: /etc/systemd/system

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

Order of precedence for unit files?

A
  1. /etc/systemd/system
  2. /run/systemd/system
  3. /usr/lib/systemd/system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

How can you override specific directives from the system’s unit file?

A

Create subdirectory named after the unit file with .d appended to the end

eg. for unit called example.service, create a subdir called example.service.d and in this directory a file ending with .conf will override or extend the attributes of the system’s unit file

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

What are the types of unit files?

A

.service
.socket
.device
.mount
.automount
.swap
.target
.path
.timer
.snapshot
.slice
.scope

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

what do service files do?

A

Manages services/applications (start/stop, auto-start conditions, dependencies, ordering info for related software).

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

what are the sections of a service unit file?

A

[Unit]

[Service]

[Install]

58
Q

What is “WantedBy=” in a unit file? Which section does it go in?

A

In [Install]
Specifies how unit should be enabled. Lets you specify dependency relationship.

eg. WantedBy=multi-user.target

59
Q

What are template unit files? How do you identify it?

A

can be used to make multiple instances of units. They have a @ after base unit file and before unit (eg. example@.service)

60
Q

What is systemd?

A

it’s an init system and system manager

61
Q

what’s the fundamental purpose a an init system?

A

initialize components that must be started after linux kernel is booted

62
Q

How to start service?

A

sudo systemctl start application.service

63
Q

how to stop service

A

sudo systemctl stop application.service

64
Q

how to restart or reload a service?

A

sudo systemctl reload-or-restart application.service

65
Q

How to enable service? Disable?

A

sudo systemctl enable application.service
sudo systemctl disable application.service

66
Q

What does enabling a service do?

A

Tells systemd to start the service automatically at boot. It will create a symbolic link from the system’s copy of the service file (usually at /usr/lib/systemd/system or /etc/systemd/system) into a location where systemd looks for autostart files (usually etc/systemd/system/some_target.target.wants)

67
Q

how to check status of service?

A

systemctl status application.service

68
Q

how to check if unit is currently active?

A

systemctl is-active application.service

exit code 0 if it’s active

69
Q

How to check if unit is enabled?

A

systemctl is-enabled application.service

exit code 0 if enabled, exit code 1 if disabled

70
Q

How to get a list of all “active/running” units that systemd knows about?

How to see every available unit file within systemd path (all installed; including those systemd didn’t try to load)?

A

systemctl list-units

systemctl list-unit-files

71
Q

how to show process status for a PID? Status of a unit?

A

systemctl status <pid></pid>

systemctl status <unit></unit>

72
Q

what is systemctl?

A

a tool used to manage services. eg. find information about services, start/stop service, enable/disable service

73
Q

How to see unit’s dependency tree?

A

systemctl list-dependencies sshd.service

74
Q

What is masking a unit and how do you do it?

A

sudo systemctl mask nginx.service

marks the unit as completely unstartable

75
Q

Command that will open a unit file snippet? What does it do?

A

sudo systemctl edit nginx.service

make a blank file that can be used to override or add directives. A dir is created in /etc/systemd/system that contains the name of the unit w/ .d appended. In that dir, a snippet called override.conf is created

76
Q

how to reload systemd manager configuraiton? (reload configuration files)

A

sudo systemctl daemon-reload

Reload the systemd manager configuration. When you modify unit files or other systemd configuration files

77
Q

What is a target?

A

A group of services that are attached through dependencies that start all of the services required to meet some sort of system state. Special unit files that describes a system state or synchronization point.
Have suffix .target

78
Q

How to find default target for system?

A

systemctl get-default

79
Q

how to list available targets?

how to see current targets loaded into memory?

A

systemctl list-unit-files –type=target

systemctl list-unit –type=target

80
Q

list all active targets

A

systemctl list-units –type==target

81
Q

How to isolate a target?

A

sudo systemctl isolate multi-user.target

82
Q

how to restart systemctl?

A

sudo systemctl reboot

83
Q

how to put system into rescue (single-user) mode?

A

sudo systemctl rescue

84
Q

What’s nginx?

A

open-source, high-performance HTTP web server

85
Q

What’s a web server? What’s the purpose of it?

A

a web server is software we can run on our hardware server. The purpose is to server documents over the internet. Usually using HTTP(s). Web severs help provide secure access to documents. Many provide additional features like load balancing and proxy forwarding

86
Q

What is a firewall?

A

A security system which monitors and governs the network traffic. Kind of like having a gatekeeper. Allows certain things in and out.

87
Q

What port is SSH?

A

22

88
Q

What’s port number for HTTP?

A

80

89
Q

Why use a firewall?

A

Main use care is for security. It can intercept incoming malicious traffic before it reaches network. Can prevent sensitive information from leaving network.

Also filters content.W

90
Q

What’s UFW?

A

a program that makes it easier to manage a netfilter firewall. UFW manages nftables or iptables

91
Q

how to install ufw?

A

sudo pacman -S ufw

92
Q

what are the 2 parts to enabling ufw?

A
  1. enable ufw service managed by systemd
  2. enable configured firewall (managed by ufw utility itself)
93
Q

how to enable and start ufw with systemctl? When happens when you use this command?

A

sudo systemctl enable –now ufw.service

creates a symbolic link: /etc/systemd/system/multi-user.target.wants/ufw.service -> /usr/lib/systemd/system/ufw.service

94
Q

where are the system-wide configuration files for ufw?

A

/etc/ufw

95
Q

how to check status of ufw? What does it show?

A

sudo ufw status verbose

shows port it’s connecting to (“To”), if it’s allowing/denying/etc (“Action”), and connection from where (“From”)

96
Q

what’s the defult ufw configuration?

A

deny all incoming traffic
allow all outgoing traffic

97
Q

how to set default for ufw? eg. default to not allow anything in?

A

sudo ufw default…

sudo ufw default deny incoming
sudo ufw default allow outgoing

98
Q

what happens when you use “sudo ufw limit ssh”?

A

UFW sets up rules to limit new incoming connections to the SSH port (port 22) to a threshold that typically allows 6 connections from a single IP address within a period of 30 seconds. If this rate is exceeded, subsequent connection attempts are blocked for a period of time

99
Q

how to allow addresses in the range 203.0.113.0/24 to connect via ssh?

A

sudo ufw allow from 203.0.113.0/24 to any port 22

100
Q

how to deny traffic from the address 203.1.113.4?

A

sudo ufw deny from 203.1.113.4

101
Q

how to rate limit ssh connection?

how to allow ssh from anywhere?

A

ufw limit ssh

sudo ufw allow ssh

102
Q

what’s port 22?

A

ssh

103
Q

what’s port 80?

A

http

104
Q

ufw - how to see list of application commands?

A

sudo ufw app list

105
Q

ufw how to allow http connections?

A

sudo ufw allow http

106
Q

how to turn on firewall?

A

sudo ufw enable

107
Q

how to delete a rule in ufw? Eg. delete ssh

A

sudo ufw delete allow SSH

108
Q

how to get number list/status of ufw rules?

A

sudo ufw status numbered

shows the rules but numbered and you can remove it with its number (eg. sudo ufw delete 2)

109
Q

what’s an advantage of cloud service provider offering a firewall over a tool like UFW?

A

you can configure a firewall in the cloud service provider than put it in front of multiple servers

110
Q

when would you use UFW instead of a cloud service providers firewall?

A
  • need firewall rules for specific application (lets you manage rules tailored to the needs of the applications on that server without affecting the other systems)
  • When you don’t have a cloud firewall tool you can use.
111
Q

what’s a proxy server?

A

intermediary server that sits b/w the client and destination server on the internet. It acts on behalf of the client, making requests to resources on other servers and then returning the data back to the client.

112
Q

describe where a REVERSE proxy sits. What does it do? Benefits?

A

user’s device –> internet –> reverse proxy –> original server

Reverse proxy sits in front of 1 or more web servers. It receives requests intended for the servers, processes them, then forwards it to the appropriate server. Client doesn’t know anything about the actual server.

Useful for load balancing, web acceleration, security

113
Q

describe where a FORWARD proxy sits. What does it do? benefits?

A

user’s device <– forward proxy <– internet <– server

sits between client and internet. Retrieves data from internet on behalf of client.

Useful for: privacy/anonymity, malware prevention, content control/filtering, caching

114
Q

what is “proxy_pass”? Where is it used/set?

A

It’s a directive used in web server configuration (like nginx) to forward requests received by server to another server. “proxy_pass” is key component to set up reverse proxy. Enables nginx to act on behalf of the client to retrieve resources from another server (the proxy server or backend server) and then send t back to the client.

Configured in location blocks in nginx configuration file. In a server block

115
Q

What is the “proxy_set_header”?

A

it’s a directive used to pass headers from the original request to the proxy server.
In the nginx configuration –> in the server block –> in the location block

116
Q

vim: what does 0 do?

A

go to start of line

117
Q

vim: what does $ do?

A

go to end of a line

118
Q

vim: what does M do?

A

move to middle of screen

119
Q

What has a PID 1?

A

systemd

120
Q

how to create symlink?

A

ln -s /source/location /destination/location

121
Q

how to disable a site?

A

unlink the active symlink in /etc/nginx/sites-enabled

eg.
unlink /etc/nginx/sites-enabled/example.conf

122
Q

what is the SaaS version of nginx?

A

the .com version

123
Q

what is the .org version of nginx?

A

open source web server

124
Q

how to start nginx service?

A

sudo systemctl start nginx.service

125
Q

where is the main nginx configuration file?

A

/etc/nginx/nginx.conf

126
Q

what’s a common dir for storing web content served by nginx? (There’s no default, it’s based on the distro)

A

/var/www/html

127
Q

what’s https port number?

A

443

128
Q

what command validates nginx.conf file for syntax errors?

A

sudo nginx -t

129
Q

Where is the HTML document nginx is serving by default? (But it depends on the distro)

A

/usr/share/nginx/html/index.html

130
Q

when do you use “sudo systemctl reload nginx”

A

reloads the configuration of the Nginx

131
Q

where is default configuration of systemd?

A

/etc/systemd/system. conf

132
Q

vim: what’s gg

A

go to the file beginning

133
Q

what’s a service? what are 2 examples of services?

A

any background process that runs without a user interface. Services generally wait for events to occur that trigger some response. “Service” sometimes used interchangeably with “daemons”.

2 examples: web server (waits for response from client before returning response), sshd (waits for remote user to login via ssh)

134
Q

what is multi-user.target?

A

when all of the services needed for a minimal working server have started. this is a common one for servers

135
Q

what’s grphical.target?

A

when all services needed for graphical login have started. when you can login through graphical login manager. this is a common one for desktop. graphical.target first loads the multi-user.target and adds several additional dependencies to tit

136
Q

What does in the /etc/systemd/system/ directory?

A
  • Systemd files created by “systemctl enable”
  • unit files added for extending a service
137
Q

How do you handle dependency when: unit A needs unit B to be running before A is started?

A

in [Unit] section of A, add Requires=B and After=B

Note: with After= then the two units can be started in parallel

138
Q

What happens with WantedBy= ?

A

When unit with this directive is enabled, a dir will be made in /etc/systemd/system named after the specified unit (that you want) with .wants appended to the end. Then a symbolic link to the current unit will be placed inside.

139
Q

What are some thing in the [Unit] section of a unit file?

A

usually used for metadata and configuring relationships

eg.
Description=
Requires=
Before=

140
Q

vim: c, ci”, ca”

A

c key in normal mode is “change”.

ci” will delete contents inside of matching quotes as long as cursor is anywhere inside of the quotes.

ca” will also delete the quotation marks

can also be ci( and stuff. a = around, i=inside

Eg. when you press c then w, it deletes from the cursor position to the end of the word under the cursor.