Intermediate Linux Flashcards

1
Q

Where are device files generally stored?

A

/dev

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

Device files are denoted with what characters in the first bit of the ls command?

A

c - character
b - block
p - pipe
s - socket

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

Devices are characterized using what two numbers?

A

major device number and minor device number

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

How can you interact with device drivers?

A

Through special files that look like regular files called device files or device nodes

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

A device takes all of our input and just discards it, so nothing gets returned

A

/dev/null

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

What are character devices?

A

These devices transfer data, but one a character at a time. These are pseudo devices (e.g. /dev/null) that aren’t really physically connected to the machine, but they allow the operating system greater functionality.

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

What is a block device?

A

These devices transfer data in large fixed-sized blocks. Most commonly devices such as harddrives, filesystems, etc.

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

What is a Pipe Device?

A

They allow two or more processes to communicate with each other, these are similar to character devices, but instead of having output sent to a device, it’s sent to another process.

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

Similar to pipe devices but they can communicate with many processes at once

A

Socket device

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

What does the major device number represent?

A

The device driver that is used

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

What does the minor device number represent?

A

The minor number tells the kernel which unique device it is in this driver class

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

A protocol used for allow communication between disks, printers, scanners and other peripherals to your system

A

SCSI (pronounced “scuzzy”) protocol.

SCSI stands for Small Computer System Interface

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

What does Linux identify with a prefix of sd?

A

sd (SCSI disk)

Linux systems correspond SCSI disks with hard disk drives in /dev

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

What is the name of the first and second hard disks in Linux?

A

First hard disk: /dev/sda
Second hard disk: /dev/sdb

e.g. /dev/sda3 - Third partition on the first hard disk

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

What are some of the most common pseudo devices?

A

The most common pseudo devices are character devices:

/dev/zero - accepts and discards all input, produces a continuous stream of NULL (zero value) bytes
/dev/null - accepts and discards all input, produces no output
/dev/random - produces random numbers

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

Sometimes in older systems you may see hard drives being referred to with what prefix?

A

hd

/dev/hda - First hard disk
/dev/hdd2 - Second partition on 4th hard disk

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

What was created to better manage devices on our system than the /dev directory?

A

A virtual filesystem, Sysfs, most often mounted to the /sys directory

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

What is the difference between /sys and /dev?

A

/sys gives us more detailed information than what we would be able to see in the /dev directory

The /dev directory is simple, and it allows other programs to access devices and interact with them

The /sys filesystem is used to view detailed information about the devices, and to manage the devices

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

$ mknod /dev/sdb1 b 8 3

A

This is the old way of creating a device node.

This command will make a device node /dev/sdb1 and it will make it a block device (b) with a major number of 8 and a minor number of 3.

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

How would you remove a device node using old methods?

A

To remove a device, you would simply rm the device file in the /dev directory

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

Dynamically creates and removes device files for us depending on whether or not they are connected

A

The udev system

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

What does the udevd daemon do?

A

It’s a daemon that is running on the system and it listens for messages from the kernel about devices connected to the system

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

What does udevd do when it finds a new device?

A

Udevd will parse the information and it will match the data with the rules that are specified in /etc/udev/rules.d.

Depending on those rules it will most likely create device nodes and symbolic links for the devices

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

How can you view the udev database and sysfs?

A

By using the udevadm command

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

Name the tools that list information about devices like the ‘ls’ command lists files and directories.

A

Listing USB Devices: lsusb
Listing PCI Devices: lspci
Listing SCSI Devices: lsscsi

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

A tool which reads input from a file or data stream and writes it to a file or data stream

A

dd

e.g. $ dd if=/home/pete/backup.img of=/dev/sdb bs=1024

if - input file
of - output file
bs - bytes

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

What tool can be used to make backups of anything, including whole disk drives?

A

dd

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

Linux filesystems structure should conform to what?

A

Filesystem Hierarchy Standard

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

The character for the root directory of the entire filesystem hierarchy

A

/

Everything is nestled under this directory

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

Essential ready-to-run programs (binaries) including the most basic commands such as ls and cp

A

/bin

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

Contains kernel boot loader files

A

/boot

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

Device files directory

A

/dev

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

Core system configuration directory that should hold only configuration files and not any binaries

A

/etc

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

Personal directories for users, holds your documents, files, settings, etc.

A

/home

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

Holds library files that binaries can use

A

/lib

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

Used as an attachment point for removable media like USB drives

A

/media

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

Temporarily mounted filesystems

A

/mnt

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

Optional application software packages

A

/opt

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

Information about currently running processes

A

/proc

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

The root user’s home directory

A

/root

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

Information about the running system since the last boot

A

/run

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

Contains essential system binaries which usually can only be ran by root

A

/sbin

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

Site-specific data which are served by the system

A

/srv

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

Storage for temporary files

A

/tmp

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

User installed software and utilities

A

/usr

Inside this directory are sub-directories for /usr/bin, /usr/local, etc.

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

Used for anything that is subject to change all the time like system logging, user tracking, caches, etc.

A

/var

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

A layer between applications and the different filesystem types, so no matter what filesystem you have, your applications will be able to work with it

A

Virtual File System (VFS) abstraction layer

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

What is a journaled system?

A

The system keeps a log file (journal) in order to keep track of tasks. The filesystem is always in a consistent state because of this, so it will know exactly where you left off if your machine shutdown suddenly.

This also decreases the boot time because instead of checking the entire filesystem it just looks at your journal.

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

The most current version of the native Linux filesystems

A

ext4

Compatible with the older ext2 and ext3 versions

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

A new filesystem for Linux that comes with snapshots, incremental backups, performance increase and much more

A

Btrfs - “Better or Butter FS”

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

High performance journaling file system, great for a system with large files such as a media server

A

XFS

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

Windows filesystems

A

NTFS or FAT

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

Macintosh filesystem

A

HFS+

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

This command reports file system disk space usage and other details about your disk

A

df

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

Hard disks can be subdivided into what?

A

Partitions

This is essentially making multiple block devices

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

What is a partition table?

A

This table tells the system how the disk is partitioned

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

The two main partition table schemes used

A
  1. ) Master Boot Record (MBR)

2. ) GUID Partition Table (GPT)

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

Space on a disk that is not allocated to a partition

A

Free space

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

Can partitions overlap?

A

No

You can have multiple partitions on a disk and they can’t overlap each other

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

What is becoming the new standard for disk partitioning?

A

GUID Partition Table (GPT)

61
Q

What is a filesystem?

A

An organized collection of files and directories

It is comprised of a database to manage files and the actual files themselves

62
Q

This is located in the first few sectors of the filesystem

A

Boot block

This is not really used the by the filesystem. Rather, it contains information used to boot the operating system.

63
Q

This is a single block that comes after the boot block, and it contains information about the filesystem

A

Super block

It contains information such as the size of the inode table, size of the logical blocks and the size of the filesystem

64
Q

The database that manages our files

A

Inode (index node) table

Each file or directory has a unique entry in the inode table and it has various information about the file

65
Q

This is the actual data for the files and directories

A

Data blocks

66
Q

The parts of a Filesystem Structure

A
  1. Boot block
  2. Super block
  3. Inode table
  4. Data blocks
67
Q

Common disk partitioning tools

A

fdisk - No GPT support
parted - Supports both MBR and GPT
gparted - The GUI version of parted
gdisk - fdisk, but only supports GPT

68
Q

What is the parted command to make a partition?

A

mkpart

69
Q

This tool allows us to create a filesystem, specify the type of filesystem we want, and where we want it

A

The mkfs (make filesystem) tool

e.g. $ sudo mkfs -t ext4 /dev/sdb2

70
Q

What happens if you try to create a filesystem on top of an existing one?

A

You’ll most likely leave your filesystem in a corrupted state

You only want to create a filesystem on a newly partitioned disk or if you are repartitioning an old one

71
Q

A directory on the system where the filesystem is going to be attached

A

The mount point

72
Q

How to create a mount point?

A

With the mount command

e.g. $ sudo mount -t ext4 /dev/sdb2 /mydrive

Or to unmount

e. g. $ sudo umount /mydrive
e. g. $ sudo umount /dev/sdb2

73
Q

How do you view the UUIDS on your system for block devices?

A

With the blkid (block identification) command

74
Q

How can we automatically mount filesystems at startup?

A

We can add them to a file called /etc/fstab

(pronounced “eff es tab” not “eff stab”)

short for filesystem table

75
Q

What is a swap partition?

A

Swap is used to allocate virtual memory to our system.

The system uses this partition to “swap” pieces of memory of idle processes to the disk, so you’re not bogged for memory on systems with low memory

76
Q

What commands are used to create a swap partition?

A

mkswap to initialize swap areas
swapon to enable the swap device
swapoff to remove swap

If you want the swap partition to persist on bootup, you need to add an entry to the /etc/fstab file

77
Q

How much swap space should you allocate compared to memory?

A

You should generally allocate about twice as much swap space as you have memory

78
Q

Why is swap space not as important on modern systems?

A

Modern systems have enough RAM and low memory is usually not an issue

79
Q

What command shows you the utilization of your currently mounted filesystems?

A

disk free: df -h

(h flag gives you a human readable format)

This shows the device, and how much capacity is used and available

80
Q

This command shows you the disk usage of the current directory you are in

A

disk usage: du -h

h flag gives you a human readable format

81
Q

What is the difference between du and df commands?

A

To see how much of your disk is free use df

To check disk usage use du

82
Q

What command is used to check the consistency of a filesystem and can even try to repair it for us?

A

fsck (filesystem check)

Usually when you boot up a disk, fsck will run before your disk is mounted to make sure everything is ok

83
Q

A filesystem is comprised of all our actual files and a database that manages these files? The database is known as what?

A

The inode table

84
Q

What is an inode?

A

An inode (index node) is an entry in this table and there is one for every file. It describes everything about the file

inodes store everything about the file, except the filename and the file itself

85
Q

When are inodes created?

A

When a filesystem is created, space for inodes is allocated as well

86
Q

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

A

df -i

87
Q

How can you view the inode number of a file?

A

ls -li

88
Q

This command is used to see detailed information about a file

A

stat

89
Q

How do inodes locate files?

A

Inodes point to the actual data blocks of your files using 15 pointers. 12 direct pointers and pointers to pointers.

90
Q

In the Windows operating system, there are aliases to files known as shortcuts. What is the Linux equivalent?

A

symbolic links (or soft links or symlinks)

91
Q

What are Linux hardlinks?

A

A file with a link to an inode

92
Q

Symbolic links are denoted by what?

A

myfilelink -> myfile

93
Q

When you modify a symlink what happens to the file it points to?

A

The file also gets modified

94
Q

What is the link count in the ls command?

A

The link count is the number of hardlinks that an inode has

95
Q

What is the difference between symlinks and hardlinks?

A

symlinks are just files that point to filenames so they can be referenced across different filesystems

hardlinks create another file with a link to the same inode. hardlinks do not span filesystems because inodes are unique to the filesystem

96
Q

How do you create a symlink?

A

With the ln command with -s for symbolic and you specific a target file and then a link name

e.g. $ ln -s myfile mylink

97
Q

How to create a hardlink?

A

With the ln command, but without the -s flag

e.g. $ ln somefile somelink

98
Q

What are the 4 stages of the Linux boot process?

A
  1. ) BIOS
  2. ) Bootloader
  3. ) Kernel
  4. ) Init
99
Q

What does BIOS stand for?

A

BIOS stands for “Basic Input/Output System”

100
Q

What happens during the BIOS phase of the boot process?

A

BIOS is a firmware that comes most common in IBM PC compatible computers

BIOS performs system integrity checks with power-on self test (POST)

BIOS’s main goal is to find the system bootloader. Once the BIOS boots up the hard drive, it searches for the boot block to figure out how to boot up the system. It will look to the master boot record (MBR) or GPT

The MBR contains the code to load another program somewhere on the disk, this program in turn actually loads up our bootloader

101
Q

What does POST stand for?

A

Power-on self test (POST) which checks that all the hardware is good to go for system startup

102
Q

What does the bootloader do?

A

Boots into an operating system

Selects a kernel to use

Specifies kernel parameters

103
Q

What is the kernel doing during the boot process?

A

When the kernel is loaded, it immediately initializes devices and memory using initramfs to get the necessary drivers.

Then it creates a root device and mount the root partition in read-only mode first so that fsck can run safely and check for system integrity. Afterwards it remounts the root filesystem in read-write mode.

Then the kernel locates the init program and executes it

104
Q

What is init?

A

The init process is the first process that gets started, init starts and stops essential service process on the system

105
Q

The successor to BIOS

A

UEFI (stands for “Unified extensible firmware interface”)

The GPT format was intended for use with EFI

The first sector of a GPT disk is reserved for a “protective MBR” to make it possible to boot a BIOS-based machine

UEFI stores all the information about startup in an .efi file stored on a special partition called EFI system partition

This partition contains the bootloader

106
Q

The most common bootloader for Linux?

A

GRUB

107
Q

The kernel manages our systems hardware, however not all drivers are available to the kernel during bootup. How is this resolved?

A

There is a temporary root filesystem that contains just the essential modules that the kernel needs to get to the rest of the hardware

108
Q

Initrd vs Initramfs

A

initrd (initial ram disk) has been replaced by initramfs

In older versions of Linux the kernel would mount the initrd, a temporary root filesystem, get the necessary bootup drivers, then when it was done loading everything it needed, it would replace the initrd with the actual root filesystem.

Now we use initramfs, a temporary root filesystem that is built into the kernel itself to load all the necessary drivers for the real root filesystem

109
Q

What are the three major implementations of init in Linux?

A
  1. ) System V init (sysv)
  2. ) Upstart
  3. ) Systemd
110
Q

System V init (sysv)

pronounced as ‘System Five’

A

The traditional init system. It sequentially starts and stops processes, based on startup scripts. The state of the machine is denoted by runlevels, each runlevel starts or stops a machine in a different way.

111
Q

Upstart

A

This is the init you’ll find on older Ubuntu installations. Upstart uses the idea of jobs and events and works by starting jobs that performs certain actions in response to events.

112
Q

Systemd

A

This is the new standard for init, it is goal oriented. Basically you have a goal that you want to achieve and systemd tries to satisfy the goal’s dependencies to complete the goal.

113
Q

The core of the operating system

A

The kernel

114
Q

The Linux operating system can be organized into what three different levels of abstraction

A
  1. ) Hardware. The physical layer. CPU, memory, hard disks, networking ports, etc
  2. ) Kernel. It handles process and memory management, device communication, system calls, sets up our filesystem, etc. It’s the software / hardware interface.
  3. ) User space. This includes the shell, the programs that you run, the graphics, etc.
115
Q

What are the privilege levels (protection rings)?

A

Ring #0 - Ring #3

  1. ) Kernel Mode - the kernel has complete access to the hardware, it controls everything
  2. ) User Mode - there is a very small amount of safe memory and CPU that you are allowed to access
116
Q

What allows us to perform a privileged instruction in kernel mode and then switch back to user mode?

A

System calls (syscall)

Systems calls provide user space processes a way to request the kernel to do something

117
Q

The kernel makes certain services available to user space processes through what?

A

The system call API

These services allow us to read or write to a file, modify memory usage, modify our network, etc.

118
Q

You can view the system calls that a process makes with this command

A

strace

e.g. $ strace ls

119
Q

Can you install multiple kernels on your system?

A

Yes

During the boot process in our GRUB menu we can choose which kernel to boot to

120
Q

This command show what kernel version you have on your system

A

uname

  • r command will print out all of the kernel release version
    e. g. $ uname -r
121
Q

How can you install the Linux kernel?

A
  1. ) Download the source package and compile from source
  2. ) Install it using package management tools
  3. ) Upgrade kernel version with $ sudo apt dist-upgrade

You’ll need to also install some other linux packages

122
Q

What is the actual linux kernel file named?

A

vmlinuz

123
Q

Where are kernel related files usually stored?

A

Usually the /boot directory

124
Q

Pieces of code that can be loaded and unloaded into the kernel on demand

A

Kernel modules

Modules allow us to extend the functionality of the kernel without actually adding to the core kernel code

125
Q

How can you view a list of currently loaded modules?

A

lsmod

126
Q

How to load a kernel module?

A

modprobe

e.g. $ sudo modprobe bluetooth

127
Q

How to remove a kernel module?

A

modprobe with the -r flag

e.g. $ sudo modprobe -r bluetooth

128
Q

How to load a kernel module on bootup?

A

Modify the /etc/modprobe.d directory and add a configuration file

129
Q

How to ensure that a kernel module does not load on bootup?

A

Modify the /etc/modprobe.d directory and add a configuration file to blacklist the module

130
Q

Under this version of init the state of the machine is denoted by runlevels, each runlevel starts or stops a machine in a different way.

A

System V

131
Q

This is the init that uses jobs and events and works by starting jobs that performs certain actions in response to events. Found on older Ubuntu installations

A

Upstart

132
Q

The new, goal oriented, standard for init

A

Systemd

133
Q

The main purpose of init?

A

To start and stop essential processes on the system

134
Q

The most traditional version of init

A

System V

135
Q

How to find out if you are using the Sys V init implementation?

A

If you have an /etc/inittab file you are most likely running System V

136
Q

Why is performance bad with System V?

A

Usually only one thing is starting or stopping at a time

137
Q

When using this version of init, the state of the machine is defined by runlevels which are set from 0 to 6

A

System V

138
Q

What scripts are located at /etc/rc.d/rc[runlevel number].d/ or /etc/init.d?

A

Scripts that are run based on the runlevel of the system (Sys v)

Scripts that start with S(start) or K(kill) will run on startup and shutdown, respectively. The numbers next to these characters are the sequence they run in.

139
Q

How can you see the default runlevel?

A

In the /etc/inittab file

140
Q

$ service –status-all

A

List the status of Sys V services

141
Q

$ sudo service networking start

A

Start the networking service

This could also be stop or restart

142
Q

Who developed Upstart?

A

Canonical, and it was used in Unbuntu

143
Q

How can you tell if your system is using Upstart?

A

If you have a /usr/share/upstart directory

144
Q

With Upstart, what’s the difference between jobs and events?

A

Jobs are the actions that Upstart performs and events are messages that are received from other processes to trigger jobs

145
Q

How can you view a list of jobs (Upstart) and their configurations?

A

$ ls /etc/init

146
Q

What does this do: initctl list

A

Lists Upstart jobs

147
Q

initctl status networking

A

View the Upstart status of the networking job

148
Q

How to manually start a job?

A

$ sudo initctl start networking

You can also stop, restart, or emit an event

149
Q

How can you tell if your system is using Systemd?

A

You have a /usr/lib/systemd directory