Zero to Hero Flashcards

1
Q

List out all files in a directory that aren’t all shown in standard ls

A

ls -la

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

Copies file into new directory

A

cp new.txt Desktop/new.txt

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

move file into new directory

A

mv new.txt Desktop/new.txt

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

locate a file

A

updatedb (to update the command)
locate new.txt

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

What does this mean?
-rw-r–r–

A

File owner: read and write
Group Owner: read
All other permissions: read

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

What does {chmod +x new.txt} do?

A

It gives all user levels executable permission
-rw-r–r–
—>
-rwxr-xr-x

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

How can I add a user

A

adduser bob

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

how to see all users on the machine?

A

cat /etc/passwd/

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

How to see the hash for each user

A

cat /etc/shadow/

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

How can I switch users on the machine at the CLI?

A

su bob

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

How can I switch back to root user?

A

su -

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

How to view recent activity via CLI

A

cat auth.log

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

How can I print out my information

A

ifconfig

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

How can I limit a ping to 1 packet

A

ping -c 1 {IP address}

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

what does arp -a do?

A

It associates IP addresses with MAC addresses

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

What does netstat -ano do?

A

Shows you all the ports that are open and what is connected to those ports

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

What does route do?

A

??

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

How do you check the history of all commands you have run?

A

history

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

How can you check the previous times you have run the ping command?

A

history | grep ping

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

How would you write the following text “hello world” into a new file named newFile.txt?

A

echo “hello world” > newFile.txt

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

How can you add more text to a file without overwriting the existing text?

A

echo “hello world again”&raquo_space; newFile.txt

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

what does the {touch} command do?

A

Allows you to create a new file i.e. touch hello.txt

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

How could you get rid of a program i.e. impacket?

A

apt purge impacket

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

How could you find your IP address?

A

ifconfig

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

How do you start a service?

A

service apache2 start
service ssh start
service postgresql start

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

How do you configure your services to start automatically when rebooting your computer?

A

systemctl enable ssh
systemctl enable postgresql

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

How do you configure your services to start automatically when rebooting your computer?

A

systemctl enable ssh
systemctl enable postgresql

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

How could you write the information from a single packet ping into a new text file?

A

ping -c 1 {IP address} > ip.txt

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

From this:

PING 192.168.1.254 56(8) bytes of data.
64 bytes from 192.168.1.254: icmp_sequ=1 ttl=128 time=0.594

How can you extract out the IP address?

A

ping -c -1 192.168.1.254 | grep “64 bytes” | cut -d “ “ -f 4 | tr -d “:”

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

How could you loop through a list of IP addresses that are up on a network and run nmap on each of them?

A

for ip in $(cat iplist.txt); nmap -p 80 -F4 $ip & done

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

What are the five stages of hacking?

A
  1. Reconnaissance (passive and active)
  2. Scanning and enumeration
  3. Gaining access
  4. Maintaining access
  5. Covering tracks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

List the components of passive recon for web/host

A

Target validation - WHOIS, nslookup, dnsrecon
Finding subdomains - Google fu, fig, nmap, sublist3r, bluto, crt.sh
Fingerprinting - nmap, Wappalyzer, WhatWeb, BuiltWith, Netcat
Data breaches - HaveIBeenPwned

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

What are some ls flags and what do they do?

A

-l = lists out long format
-a = lists out all file including hidden files

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

What does theharvester do and what cli do you use?

A

It finds emails, subdomains and hostname IPs with the given domain name
theharvester -d telsa.com -l 500 -b google

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

What does bluto do and what cli do you use?

A

It looks through haveIpwned information, it does active DNS recon (zone transfers) and brute force attacks
bluto
->target Domain: tesla.com

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

What website can you use to search for subdomains via certificates?

A

crt.sh

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

Should you scan TCP, UDP or both?

A

mostly TCP, but should do both

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

What types of applications use UDP? and why?

A

DNS, DHCP, SNMP. Don’t need reliability, just fast connection

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

What is the process of a TCP connection?

A

Three way handshake
SYN ->
<- SYN, ACK
ACK ->

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

How does stealth scanning work?

A

-> SYN
<- SYN ACK
-> RST

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

What does the -T4 flag do?

A

It represents speed T1 - T5 on nmap

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

How many ports are by default scanned using nmap?

Is the default number good or bad? Why?

A

‘Top 1000’
Its better to scan more than the default as you may miss some with open connections

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

What does the -A flag enable in nmap scan?

A

It enables OS detection, version detection, script scanning and traceroute
It basically means ‘intense’

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

what does -p- flag do in nmap?

A

It makes the nmap scan all ports

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

Explain the concept of staging with nmap.

A

First, scan all ports to see which are open.
nmap T4 -p- {IP Address}
THEN, scan the ports that are open more intensely.
nmap T4 -p53, 404, 80, 111 {IP Address}

This avoids unnecessarily intensely scanning all unopened ports.

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

What kind of output does -oA give you with nmap?

A

normal, XML, s|<rIpt kIddi3, Grepable format

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

How would you check was rwx right each file has

A

use ls -l or ls -a

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

how do you change your password?

A

passwd

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

If you have a command in mind, but don’t know exactly what it is, how can you figure it out using the cli?

A

apropose copy

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

How do you find out who is logged into your system?

A

w or who

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

What does TTY mean and where can you find it?

A

TTY = teletype and stands for user sessions
You can find it using command w

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

How do you find the kernal version and name

A

uname

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

what does the uptime command do?

A

Tells you how long the machine has been up, the number of users sessions and average load

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

How do you find every log in and reboot that has happened in the system

A

last

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

How can you find the total storage left in the linux system?

A

df -h (h = human-readable)

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

Imagine you need to connect to one of your machines, somewhere in the cloud. How would you go about connecting to that machine securely and getting a shell on it?

A

Is there a VPN to connect to first?
SSH is standard tool to connect to remote host?
What does the SSH command look like?
How would you authenticate? password/key?
Don’t want root login enabled

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

what directory am i in?

A

pwd

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

how to copy text into an existing file?

A

echo “G’day” > file.txt

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

How to copy a file into another directory?

A

cp {filename} {path}

i.e.

cp file.txt /test/putHere

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

How would you copy a file from the remote host to another remote host or the work laptop you are currently using?

A

rsync root@{IP address}:/root/myfile.txt

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

Say we are on a box that is running Ubuntu, how would you manage services on this box?

A

systemctl start nginx
systemctl status nginx
curl localhost (check access)
systemctl stop

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

What is the difference between starting a service and enabling it?

A

Starting = just starts it for that session
Enabling = starts automatically upon each boot up

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

How would you see what all the files in var/log are taking up space?

A

du -sh var/log/*

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

how to find IP address of the eth0 interface

A

ip addr show

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

What is your default route?

A

ip route show

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

What is an init system?

A

init is the first real process that the kernel starts
init is responsible for starting all of the services, units that you expect to have running
init is responsible for reparenting orphaned processes

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

What is a linux user made of?

A

It is an entry in a few different text file etc/group, etc/shadow, etc/passwd

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

What is the shell?

A

Program that takes your commands and sends them to the operating system. These are launched by the Terminal.

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

How do you create a file called myfile?

A

touch myfile

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

What command can you use to find the file type of a file?

A

file

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

How can you read the contents of two files, file1 and file2 combined together?

A

cat file1 file 2

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

How do you quit out of a less command?

A

q

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

How do you copy myfile into another directory while making sure to notify yourself if there is a file in that directory with another name?

A

cp -i myfile /home/pictures

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

How do you copy over all files that have the extension .jpg into another file?

A

cp *.jpg home/pictures

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

How do you copy over a directory into another directory?

A

cp -r directorytoCopy home/directorycopyto

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

how do you move two files into another directory?

A

mv file1 file2 /home/..

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

How do you rename a file or directory?

A

mv oldfile newfile
mv olddir newdir

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

how do you make a backup of a folder when moving it?

A

mv -b dire1 dire2

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

How do you make subdirectories when making a new directory?

A

mkdir -p books/hemmingway/favourites

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

how do you remove a file
and how do you remove a directory?

A

rm file
rmdir directory

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

What protection level must a file have to restrict from straight out removing?
and how can you overcome the restriction?

A

Write-protected
you can overcome it by using the -f flag for force i.e.
rm -f file

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

How do you find a file in your home folder called puppies.jpg?

A

find /home -name puppies.jpg

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

How do you search for a folder called MyFolder in your home directory? You only want to search for directories. How can you do this?

A

find /home -type d -name Myfolder

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

What are the 4 main ways you can find information about a command?

A

pwd –help
help pwd
whatis
man

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

How do you set an alias for command?

A

alias foobar=’ls -la’
Note, this wont be saved after reboot

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

How do you exit from the shell?

A

exit
or
logout

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

how to append this text: “sample text” to a file named ‘Mate.txt’?

A

echo sample text&raquo_space; Mate.txt

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

How would you redirect an ls call to be printed into a text file?

A

ls var/log > output.txt

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

How would you create an empty file?

A

> someFile.txt

or

touch someFile.txt

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

how would you read in from one file and paste it into another new file?

A

cat file1.txt > file2.txt

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

What are streams?

A

I/O streams are things like stdin, stdout and stderr

They can be called using file descriptors:

0 = stdin
1 = stdout
2 = stderror

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

How would you send a stderror to a file?

A

ls fake/directory 2> peanuts.txt

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

How would you direct both stdout and stderr to a file?

A

ls fake/directory &> peanuts.txt

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

How would you redirect stderror outputs to a special file call?

A

ls fake/directory 2> /dev/null

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

How can you see all items in a directory AND stdout it into a file?

A

ls | tee peanuts.txt

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

How do find the path to your home directory?

A

echo $HOME

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

How do you see your username?

A

echo $USER

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

Where do things like $HOME and $USER come from?

A

environment variables (env)

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

I have some text in a text file test.txt:

hello world; test

I want to cut out and present the part after ‘;’. how do I do it?

A

cut -f 2 -d ‘;’ test.txt

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

how do you paste content?

A

paste -d ‘ ‘ -s sample2.txt

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

how do you just display the first, say 20 lines of a cat?

A

head -n 20 /var/log/syslog

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

What is the default number of lines shown by the head command?

A

10

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

How do you just display the last, say 20 last lines of cat?

A

tail -n 20 /var/log/syslog

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

What does the following command do?

$ tail -f /var/log/syslog

A

It follows the file such that you can see everything that is getting added to that file

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

How do you join two files by field?

A

The two files must be ordered i.e.

1 Zac
2 Jack
3 Mack

Simunovic 1
Thackrey 2
James 3

Then do:
join -1 2 -2 1 text1.txt text2.txt

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

How do you sort text in a file?
How do you reverse sort?
How do you sort via numerical value?

A

sort file.txt

sort -r file.txt

sort -n file.txt

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

How do you translate from lower case to upper case?

A

tr a-z A-Z
hello

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

How can you remove duplicates from a text file?

A

unique text.txt

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

How do you get the number of occurances of a line?

A

unique -c text.txt

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

How do you return unique values?

A

uniq -u text.txt

110
Q

How do you return duplicate values?

A

uniq -d text.txt

111
Q

How would you overcome the limitation of uniq not picking up non-adjacent duplicates?

A

sort text.txt | uniq

112
Q

How do you get the word count of a line?

A

wc

113
Q

What does grep do

A

Is searches through text and returns matches

114
Q

How can you use grep case insensitively?

A

grep -i hello helloWorld.txt

115
Q

How would you use grep to search for all files in a directory with a .txt ending?

A

ls /directory | grep ‘.txt$’

116
Q

Where can you find the UID for users?

A

cat /etc/passwd

117
Q

What does each of these fields mean?

root:x:0:0:root:/root:/bin/bash

A

root = username
x = user’s password (stored in /etc/shadow)
0 = UID
0 = Group ID
root = GECOS field (comments about user)
/root = user’s home directory
/bin/bash = user’s shell

118
Q

Where could you find this sort of information?

root:MyEPTEa$6Nonsense:15000:0:99999:7:::

A

sudo cat /etc/shadow

119
Q

what do each of these fields stand for?

root:MyEPTEa$6Nonsense:15000:0:99999:7:::

A
  1. Username
  2. Encrypted password
  3. Date of last password changed (expressed as number of days since jan 1 1970)
  4. Minimum password age i.e. number of days a user has to change their password
  5. Max password age
  6. password warning period
  7. password inactivity period
  8. account expiration date
120
Q

What is /etc/group for?

A

Used for user management, that is, different groups with different permissions

121
Q

in /etc/group, what do these fields stand for?

root:*:0:pete

A
  1. Group name
  2. group password. Note, * = default value
  3. Group ID
  4. List of users
122
Q

how do you add users?

A

sudo useradd bob

123
Q

how do you remove users?

A

sudo userdel bob

124
Q

How do you change password for a user

A

passwd bob

125
Q

explain this:

drwxr-x-r-x

A

d = directory
rwx = user permissions include read, write, executable
r-x = group permissions include read and executable
r-x = other permissions include read and executable

126
Q

how can you add user executable permissions to a file?

A

chmod u+x myfile

127
Q

How do you remove user executable permissions to a file?

A

chmod u-x myfile

128
Q

How do you add write permissions for user and groups?

A

chmod ug+w

129
Q

what are the numeric representations for read, write, executable?

A

read = 4
write = 2
executable = 1

130
Q

What does:
chmod 755 myfile
do?

A

7 = 4 + 2 + 1, so user has rwx

5 = 4 + 1, so groups have r-x

5 = 4 + 1, so other users have r-x

131
Q

how do you modify the user ownership of a file?

A

sudo chown zac myfile

132
Q

How do you modify the group ownership of a file?

A

sudo chgrp imogen myfile

133
Q

How do you modify both user and group ownership at the same time?

A

sudo chown zac:imogen myfile

134
Q

How do you reset permission back to default?

A

unmask 022
This sets the following:
user = wrx
group = -rx
others = -rx

135
Q

What allows a user to run a program as the owner of the program file rather than as themselves?

A

Set User ID (SUID)

-rws

When this permission is set, it allows the users who launched the program to get the file owner’s permission as well as execution permission.

136
Q

How do you modify the SUID permission?

A

sudo chmod u+s myfile

of

sudo chmod 4755 myfile

137
Q

How do you modify the SGID?

A

sudo chmod g+s myfile

or sudo chmod 2555 myfile

138
Q

What are the three process permissions?

A
  1. effective user ID = ID of the user that is normally the owner
  2. Real user ID = ID of the user that launched the process
  3. Saved User ID = Temporary switching from privileged to non-privileged permissions and the elevated user id is waved to SUID so that it can be used for switching back to privileged account
139
Q

What is the sticky bit? and what is it defined as in the permissions?

A

It is a permission bit that sticks to a file/directory such that only the owner or root can delete or modify the file.

rwxt

140
Q

How do you modify the sticky bit?

A

sudo chmod +t mydir

or sudo chmod 1755 mydir

141
Q

What are processes and what manages them?

A

the programs running on your machine. More specifically its where the system allocates memory, CPU, I/O to make the program run. They are managed by the kernel.

142
Q

How do you see what processes are running on your machine?

A

ps

143
Q

What can you see when you run ps?

A

PID = process id
TTY = Controlling terminal asociated with the process
STAT = Process status code
TIME = total CPU usage time
CMD = Name of executable / command

144
Q

What can you see when you run ps?

A

PID = process id
TTY = Controlling terminal asociated with the process
STAT = Process status code
TIME = total CPU usage time
CMD = Name of executable / command

145
Q

what does ps aux do?

A

Show info on
a = all processes running inc. those run by others
u = shows more details about the process
x = lists all processes that don’t have a TTY associated with it

146
Q

What are the fields that you can see in ps aux?

A

USER: Effective user
PID
%CPU = CPU time used divided by the time the process has been running
%MEM = Ratio of the process’s resident set size to the physical memory on the machine
VSZ = Virtual memory usage
RSS = Resident Set Size, the non-swapped physical memory that the task has used
et al

147
Q

How can you get real time information about the processes running on your system?

A

top

148
Q

What is the difference between a terminal device and a psuedoterminal device?

A

terminal device is a native hardware device running directly on a console

a psuedoterminal is a software emulation of a terminal - this is the terminal you are used to working in.

149
Q

What is in charge of processes and how does it work?

A

Kernel is in charge of processes

When a program is run, the kernel loads up the code of the program in memory, determines and allocates resources and then keeps tabs on each process.

150
Q

What does the kernel know about a process?

A
  1. Status
  2. The resources the process is using and receives
  3. Process owner
  4. Signal handling
151
Q

How is a new process created?

A

An existing process clones itself using the fork system call, creating a mostly identical child process.

The child process takes on a new ID (PID) and the parent, the PPID

the execve system call is then called to launch a new program on that process.

152
Q

What is the init process?

A

It is like the parent of all processes, which is created by the kernel upon boot up, and assigned a PID of 1. It is given root privileges and runs many processes that keep the system running.

can only be terminated when system shuts down.

153
Q

How do you terminate a process?

A

use the _exit system call. This will free up the resources that process was using.

154
Q

What does a termination status 0 mean?

A

It lets the kernel know that the process succeeded.

155
Q

Why is it not enough to simply _exit system call a process?

A

Because the parent process must first acknowledge the termination of the child process by using the wait system call to check termination.

156
Q

What happens when a parent process ends before a child process?

A

They become orphan processes and placed under the care of init, until init calls the wait system call.

157
Q

What happens when a child terminates and the parent process hasn’t called wait yet?

A

The kernel turns the child process into a zombie process. The resources are freed up, but the zombie process is still present on the process table.

158
Q

Why is it bad if there are many zombie processes?

A

Its bad because they take up space in the process table which may prevent other processes from running.

159
Q

What are the 6 common signals?

A

SIGHUP or HUP or 1: Hangup

SIGINT or INT or 2: Interrupt

SIGKILL or KILL or 9: kill

SIGSEGV or SEGV or 11: Segmentation fault

SIGTERM or TERM or 15: Software termination

SIGSTOP or STOP: stop

160
Q

What are two common special terminal characters that kill / interrupt / suspend a process?

A

crtl+z
ctrl+c

161
Q

how do you kill a process?

A

kill -9 PID

162
Q

what are the differences between SIGHUP, SIGINT, SIGTERM, SIGKILL, SIGSTOP?

A

SIGHUP = if a terminal is closed while a process is running
SIGINT = ctrl+c
SIGTERM = kill the process, but allows it to do some cleanup first
SIGKILL = kill the process without any cleanup
SIGSTOP = stop/suspend process

163
Q

When multiple processes are running, how is the CPU used amongst them?

A

in ‘time slices’ like a round robin, where each processes has a time slice to complete a process.

This time slicing is handled by the kernel.

164
Q

What does niceness mean?

A

It is a way to influence a kernel’s scheduling algorithm for time slicing for different processes.

165
Q

What does a low niceness level indicate and what does a high niceness level indicate?

A

High = low priority for the CPU

low = high priority, as much as possible

166
Q

How can you change the niceness level?

A

nice -n 5 someprocess upgrade

167
Q

what is renice used for?

A

renice 10 -p 3245

It is for setting priority on an existing service.

168
Q

Where is process information stored?

A

/proc

There is a subdirectory for every process.

169
Q

Let’s say you’re working on a single terminal window and you’re running a command that is taking forever. How can you continue interacting with the shell while that command is running?

A

You can use the & symbol to tell the command to run in the background.

170
Q

How do you send a job to the background after you have already started running it?

A

you suspend it with ctrl+z, then run the bg command to send it to the background

171
Q

How do you move a job from the background to the foreground?

A

fg %{job number}

i.e.

fg %1

172
Q

What is the ‘/’ directory called? and what does it contain?

A

root. It contains the entire filesystem hierarchy

173
Q

What does the ‘/bin’ directory contain?

A

Essential, ready-to-run programs

174
Q

What does the ‘/boot’ directory contain?

A

kernel boot loader files

175
Q

What does the ‘/dev’ directory contain?

A

device files

176
Q

What does the ‘/etc’ directory contain?

A

core system configuration directory, should hold only config files and not any binaries

177
Q

What does the ‘/home’ directory contain?

A

personal directories for users

178
Q

What does the ‘/lib’ directory contain?

A

holds library files that binaries can use

179
Q

What does the ‘/media’ directory contain?

A

used as an attachment point for removable media like USB drives

180
Q

What does the ‘/mnt’ directory contain?

A

temporary mounted filesystems

181
Q

What does the ‘/opt’ directory contain?

A

optional application software packages

182
Q

What does the ‘/root’ directory contain?

A

root user’s home directory

183
Q

What does the ‘/run’ directory contain?

A

info about the running system since the last boot

184
Q

What does the ‘/sbin’ directory contain?

A

essential system binaries, usually can only be ran by root

185
Q

What does the ‘/srv’ directory contain?

A

site-sepcific data which are served by the system

186
Q

What does the ‘/tmp’ directory contain?

A

Storage for temporary files

187
Q

What does the ‘/usr’ directory contain?

A

user installed software and utilities

188
Q

What does the ‘/var’ directory contain?

A

variable directory used for system logging, user tracking, caches

189
Q

hard disks can be subdivided into ________

A

partitions

e.g.
/dev/sda1
/dev/sda2

190
Q

What are partitions useful for?

A

separating data, and if you need a certain filesystem, you can easily create a partition instead of making the entire disk one filesystem type

191
Q

What are the two main partition table schemes used

A

Master boot record (MBR) and GUID Partition Table (GPT)

192
Q

What are disks comprised of ?

A

partitions, that help organise our data.

193
Q

What can you have inside a partition?

A

filesystem or dedicate a par

194
Q

What is a filesystem?

A

organised collection of files and directories. Comprised of a database to manage files and the files themselves

195
Q

What are some different filesystems?

A

ext4 - most current and standard choice for linuc systems

Btrfs - filesystem with snapshots, incremental backups, performance increases

XFS - High performance journaling file system

NTFS and FAT - windows filesystem

HFS+ - Macintosh filesystem

196
Q

How do you make a file system

A

sudo mkfs -t ext4 /dev/sdb2

197
Q

What must you do before you can view the contents of your filesystem?

A

mount it. Do mount you need a device location, filesystem type and mount point.

198
Q

What is a mount point?

A

directory on the system where the filesystem will be attached.

199
Q

How do you mount a new filesystem?

A

sudo mount -t ext4 /dev/sdb2 /mydrive

200
Q

How do you unmount a filesystem?

A

sudo unmount /mydrive

201
Q

How can we automatically mount filesystems at startup?

A

add them to /etc/fstab

202
Q

What is a swap partition?

A

Swap is what we use to allocate virtual memory to our system, and so if you are low on memory, the system uses this partition to swap pieces of memory of idle processes to the disk, so that you’re not bogged down for memory.

203
Q

How do you see the utilisation of your disks

i.e. check how much of your disk is free

A

df -h

-h = gives the human readable format

use to check how much of your disk is free

204
Q

Let’s say your disk is getting full and you want to know what files or directories are taking up that space, what command do you run?

i.e. check how much of your disk is being used

A

du -h

205
Q

what does the fsck /dev/sda command do?

A

It checks the consistency of a filesystem and can try to repair it for us.

206
Q

What is an inode

A

It describes everything about a file inc.

file type, owner, group, permissions, size, number of block allocated to the file, pointers to the data blocks etc.

207
Q

When are inodes created?

A

when a filesystem is created, so is the space for inodes.

208
Q

How do you see how many inodes are left on your system?

A

df -i

209
Q

how do you view inode numbers?

A

ls -li

210
Q

How do inodes locate files?

A

inodes point to the actual data blocks of your files

211
Q

what are the 4 stages of the boot process?

A
  1. BIOS (basic input/output system
  2. Bootloader
  3. kernel
  4. init
212
Q

What is BIOS?

A

Basic input / output system initialises the hardware and makes sure wuth a power-on self test that all hardware is good to go

213
Q

What is Bootloader?

A

loads the kernel into memory and then starts the kernel with a set of kernel parameters

214
Q

What is kernel responsible for in the boot process?

A

It initialises devices and memory. The main job of the kernel is to load up the init process

215
Q

What is init responsible for in the boot process?

A

init is the first process that starts and stops essential services process on the system.

216
Q

When using Sys V, what are the 7 different runlevels?

A

0: shutdown
1: Single user mode
2: Multiuser mode w/o networking
3: Multiuser mode with networking
4: unused
5:Multiuser mode with networking and GUI
6: reboot

217
Q

How do you list all services?

A

system –status-all

218
Q

How do you start, stop and restart a service?

A

sudo service networking start

and

sudo service networking stop

and

sudo service networking restart

219
Q

How do you shutdown your system in 2 minutes?

A

sudo shutdown -h -2

220
Q

How do you restart your system now?

A

sudo shutdown -r now

221
Q

how do you reboot your system>

A

sudo reboot

222
Q

what does the lsof command do?

A

It shows what is in use in a process including all open files and their associated processes.

223
Q

What does the fuser command do?

A

It is short for file user and tracks infomration about teh process that is using the file or the file user

224
Q

What is example of multi-threading?

A

Editing and saving simultaneously in a writing application

225
Q

Is it more efficient to have a multi-threaded application or multi-process application?

A

Multi-threaded

226
Q

What happens in multithreading?

A

multithreading is where two or more applications with otherwise isolated system resources share these resources, making it easier for them to communicate among each otehr.

227
Q

how can you view process threads?

A

ps m

228
Q

how can you see the load averages on your system?

A

uptime

229
Q

how can you monitor CPU usage and disk usage?

A

iostat

230
Q

What types of information can you see with iostat?

A

CPU usages at the user level, usage with nice priority, system level, iowait (CPU idle time during an oustanding disk I/O request
etc

231
Q

How can you monitor your memory usage?

A

vmstat

232
Q

What specifically does VMstat show?

A

number of processes
amount of used and free memory, memory used as buffers / cache

amount of memory swapped in and out of disk

Amount of blocks received in from a block device, sent out to a block device

number of interrupts per second, number of context switches per second

time spent in user, kernel time, idle

233
Q

What is kept in teh /var directory?

A

logs

234
Q

What does var/log/syslog contain?

A

one this is that there is daemon running called syslogd, which waits for event messages to occur.

235
Q

what are the two most important log files in /var/log/..

A

/messages for messages logged during bootup, auth, cron, daemon

/syslog for everything except auth messages

236
Q

What is contained in /var/log/dmesg?

A

information logged about the kernel ring buffer. Useful for hardware and bootup troubleshooting

237
Q

Where can you find authentication logging?

A

/var/log/auth.log

info such as authorisation logs, user login and authentication method.

238
Q

Where can you find authentication logging?

A

/var/log/auth.log

info such as authorisation logs, user login and authentication method.

239
Q

what does the scp stand for and do?

A

scp = secure copy. It works the exact same way as the cp command does, but lets you copy from one host to another on the same network.

240
Q

How can you copy a file over from local host to a remote host?

A

scp myfile.txt username@remotehost.com:/remote/directory

241
Q

How can you copy a file over from a remote host to your local host?

A

scp username@remotehost.com:/remote/directory/myfile.txt/local/directory

242
Q

how do you copy a directory from local host to remote host?

A

scp -r …..

243
Q

What does rsync do?

A

It uses a special algorithm that checks in advance if there is already data that you are copying to and will only cover over the difference. It also checks the intergity with checksum

244
Q

how can you set up a NFS client?

A

sudo service nfsclient start

sudo mount server:/directory /mount_directory

245
Q

how do you view your IP address?

A

ifconfig -a

246
Q

What does CIDR stand for?

A

classless inter-domain routing

used to represent a subnet mask in a more compact way

247
Q

A network interface is how ______

A

the kernel links up the software side of networking to the hardware side

248
Q

What does the ifconfig tool allow us to do>

A

Configure our network interfaces.

249
Q

What does ifconfig do during bootup?

A

ifconfig runs on bootup and configures our interfaces through config files

250
Q

What does ifconfig show?

A
  1. MAC address
  2. inet address (IPv4)
  3. inet6 address (IPv6)
  4. subnet mask
  5. broadcast address
251
Q

How do you create an interface?

A

ifconfig eth0 {IP address} netmask {subnet} up

252
Q

How do you bring up or bring down an interface?

A

ifup eth0

ifdown eth0

253
Q

what does the ip command do?

A

allows us to manipulate the networking stack of a system.

254
Q

What does ip link show do?

A

shows interface information for all interfaces

255
Q

How do you show the statistics of an interface?

A

ip -s link show eth0

256
Q

how do you show ip addresses allocated to interfaces?

A

ip address show

257
Q

How do you add or delete a route ?

A

sudo route add -net {IP address} …

sudo route del -net …

258
Q

What is the ICMP?

A

internet control message protocol

used to send updates and error messages and is extremely useful protocol used for debugging network issues

259
Q

how do you check if a packet can reach a host?

A

ping {ip address}

260
Q

What does traceroute do?

A

it follows the routing of packets to a domain i.e. google.com

261
Q

How does traceroute work?

A

it works by sending packets with increasing TTL values, starting with 1. it send message back once the TTL is decremented to zero, thus building a trail.

262
Q

what port is ftp on?

A

21/tcp

263
Q

ssh port?

A

22/tcp

264
Q

port 25/tcp

A

smtp

265
Q

53/tcp

A

domain

266
Q

http port

A

80/tcp

267
Q

https port?

A

443/tcp

268
Q

how can you get information about the various network related information such as network connections, routing tables, interfaces etc?

A

netstat

269
Q

what does the netstat -a command show?

A

the listening and non-listening sockets for network connections.

270
Q

how can you map a hostname to an IP address?

A

put it into /etc/hosts

127.0.1.1 icebox

271
Q

What does nslookup do?

A

used to query name servers to find information about resource records i.e. gives info about address, server, location etc

272
Q

What is a poweful tool for getting information about DNS name servers>

A

dig