[2] Linux Flashcards

1
Q

What is the boot process?

A

[1] The BIOS checks the device hardware
[2] The bootloader finds the boot sector on the hard drive which contains the Linux kernel
[3] The Linux kernel is loaded
[4] The Linux kernel starts a RAM disk and loads basic drivers onto it
[5] The drivers on the RAM disk are used to mount the file system
[6] The kernel triggers the initialisation system, which mounts the file system and starts key daemons

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

How do boot logs work?

A

They are stored in the kernel ring buffer which is in RAM

Therefore, they are volatile i.e. do not persist on reboot

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

What command is used to read the boot log?

A

dmesg

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

What is it called when the kernel has an error?

A

Kernel panic

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

What are kernel modules?

A

Extensions to the Linux kernel e.g. third-party device drivers

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

What configuration files are used in Linux to manage DNS resolution?

A

/etc/hosts maps hostnames to IP addresses e.g. localhost -> 127.0.0.1

/etc/resolve.conf contains the IP address of DNS name servers to use

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

What are pseudo file systems?

A

A virtual file system that only exists in RAM. It is created by the kernel and is volatile system is running

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

What are the main pseudo file systems?

A

/proc - contains information about processes running on a system

/sys - contains information about the system hardware and kernel modules

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

What information is included about processes listed in /proc?

A

Their PID (process id), process data and the hardware they are running on

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

What are some key filesystems?

A

/var - the variable location. Stores dynamic content such as websites and logs

/home - the users’ home directories

/boot - Linux kernel and supporting files

/opt - optional software e.g. libraries

/dev - all hardware attached to the computer

  • swap space e.g. if RAM over fills
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can swap space be setup?

A

Either as a swap partition (faster) or a swap file

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

How big should the swap space be?

A

At least 50% of the RAM size

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

How are hard drives represented in the file system?

A

/dev/sda for the first, /dev/sdb for the second.

If the first is partitioned then it’s /dev/sda1, /dev/sda2 etc.

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

What are mountpoints?

A

A mapping from an entire hard disk or partition that maps to a particular directory

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

Which Linux command is used for mounting?

A

The mount command shows existing mounts and can be used to create new mounts

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

Which Linux command shows block devices?

A

lsblk shows all block devices on a system and their names

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

Which Linux command shows swap partitions?

A

swapon –summary

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

What are the primary file systems?

A

Non-journaling: ext2
Journaling: ext3, ext4, xfs
Btrfs

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

What is the difference between Non-Journaling and Journaling filesystems?

A

They keep track in RAM of changes that have not yet been written to the disk

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

How does Btrfs work?

A

It is CoW (copy on write)

When editing a file, it only stores the changes so old versions can be accessed

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

What filesystem do Linux boot partitions use?

A

They must be FAT partitions, although VFAT can be used to allow longer file names

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

What command would mount a second hardrive to /opt?

A

mount /dev/sdb1 /opt

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

Where are mount configurations saved?

A

/etc/fstab

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

How can ls be used to show file sizes?

A

ls -lh gives a long listing in human readable foramt

25
What information does ls -lh include?
Filename, file size, ownership and permissions
26
Which command show the available disk space?
df -h ("disk free") For each filesystem, this shows the size used, the amount available and where it is mounted
27
Which command shows free memory?
free -h This shows both physical memory and swap space
28
Which command shows how much disk space is used by files?
du -h By default this is file size of all files in current directory use du -sh to show a summary i.e. total use for that directory To see another directory, specify it's path e.g. du -sh /home/marrick
29
How can du be used recursively?
du -h --max-depth=2 will recurse to show the current directory and sub directories
30
What is an inode?
A pointer to the file/folder and its ownership/permissions
31
Which command displays locale information?
use locale to view locale
32
Which command shows the current time/date
date date -u for UTC
33
Which command sets the time zone?
tzselect
34
Which command updates the system clock?
timedatactl
35
Where is time / date information stored?
The time itself is at /etc/localtime /etc/timezone stores the time zene /usr/share/zoneinfo is a databse of available timezones
36
Which command creates new users?
useradd -m [username] Note that the -m flag creates a home directory
37
Which command sets the password for an account?
passwd [username] To set your own password, omit the [username]
38
Which command deletes a user?
userdel
39
Does userdel delete the user's home directory?
No. unless the -r flag is used
40
Which command shows the groups that a user is of?
groups [username] omit the [username] to see your users
41
Which command creates groups?
groupadd
42
Which command adds users to a group?
* when creating a user, use -G e.g. useradd -G curators | * usermod -a -G [group] [username]
43
Which command deletes groups?
groupdel
44
Which file stores a list of users?
/etc/passwd Note that password hashes are in /etc/shadow
45
Which file stores a list of groups?
/etc/group contains a list of users and their members
46
How are system accounts distinguished from user accounts?
* root account has id of 0 * system accounts have 1 <= id <= 1000 * user accounts have id > 1000
47
What defaults are used for new users?
/etc/skel is used as a template for the home directory /etc/default/useradd gives user config e.g. groups, andch shell to use
48
Which command displays users that are part of a group?
getent group [group]
49
Where are shell configurations stored?
~/.bashrc or similar for non-bash shells
50
Where should you set persistent environment variables?
In ~/.bashrc e.g. add "export NAME=value
51
Which tools are used to schedule tasks?
cron or systemd
52
How can cron tasks be set?
By using crontab to save tasks into the users cron table
53
Where are cron tabs located?
/etc/cron.hourly | /etc/cron.daily etc
54
How does cron notation work?
You specify the minute of the hour, hour of the day etc. and then the script to run
55
Which command runs a command at a specific time?
The at command
56
Which commands work with directories?
cd / mkdir / rmdir (won't delete directory contents)
57
How does path work?
The $PATH environment variable describes directories that the user can execute the contents without specifying their full path
58
How are file permissions enocoded?
Symbolically: r=read, w=write, x=execute, -=no permission Ocatal: Three bits, corresponding to read, write and execute e.g. read/execute is 011 = 3
59
Which commands change ownership and permissions?
chown changes user ownership chgrp changes group ownership chmode changes the permissions of a file/directory