[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
Q

What information does ls -lh include?

A

Filename, file size, ownership and permissions

26
Q

Which command show the available disk space?

A

df -h (“disk free”)

For each filesystem, this shows the size used, the amount available and where it is mounted

27
Q

Which command shows free memory?

A

free -h

This shows both physical memory and swap space

28
Q

Which command shows how much disk space is used by files?

A

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
Q

How can du be used recursively?

A

du -h –max-depth=2 will recurse to show the current directory and sub directories

30
Q

What is an inode?

A

A pointer to the file/folder and its ownership/permissions

31
Q

Which command displays locale information?

A

use locale to view locale

32
Q

Which command shows the current time/date

A

date

date -u for UTC

33
Q

Which command sets the time zone?

A

tzselect

34
Q

Which command updates the system clock?

A

timedatactl

35
Q

Where is time / date information stored?

A

The time itself is at /etc/localtime

/etc/timezone stores the time zene

/usr/share/zoneinfo is a databse of available timezones

36
Q

Which command creates new users?

A

useradd -m [username]

Note that the -m flag creates a home directory

37
Q

Which command sets the password for an account?

A

passwd [username]

To set your own password, omit the [username]

38
Q

Which command deletes a user?

A

userdel

39
Q

Does userdel delete the user’s home directory?

A

No. unless the -r flag is used

40
Q

Which command shows the groups that a user is of?

A

groups [username]

omit the [username] to see your users

41
Q

Which command creates groups?

A

groupadd

42
Q

Which command adds users to a group?

A
  • when creating a user, use -G e.g. useradd -G curators

* usermod -a -G [group] [username]

43
Q

Which command deletes groups?

A

groupdel

44
Q

Which file stores a list of users?

A

/etc/passwd

Note that password hashes are in /etc/shadow

45
Q

Which file stores a list of groups?

A

/etc/group contains a list of users and their members

46
Q

How are system accounts distinguished from user accounts?

A
  • root account has id of 0
  • system accounts have 1 <= id <= 1000
  • user accounts have id > 1000
47
Q

What defaults are used for new users?

A

/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
Q

Which command displays users that are part of a group?

A

getent group [group]

49
Q

Where are shell configurations stored?

A

~/.bashrc or similar for non-bash shells

50
Q

Where should you set persistent environment variables?

A

In ~/.bashrc e.g. add “export NAME=value

51
Q

Which tools are used to schedule tasks?

A

cron or systemd

52
Q

How can cron tasks be set?

A

By using crontab to save tasks into the users cron table

53
Q

Where are cron tabs located?

A

/etc/cron.hourly

/etc/cron.daily etc

54
Q

How does cron notation work?

A

You specify the minute of the hour, hour of the day etc. and then the script to run

55
Q

Which command runs a command at a specific time?

A

The at command

56
Q

Which commands work with directories?

A

cd / mkdir / rmdir (won’t delete directory contents)

57
Q

How does path work?

A

The $PATH environment variable describes directories that the user can execute the contents without specifying their full path

58
Q

How are file permissions enocoded?

A

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
Q

Which commands change ownership and permissions?

A

chown changes user ownership

chgrp changes group ownership

chmode changes the permissions of a file/directory