Beginner Linux Flashcards

1
Q

Who developed UNIX?

A

Ken Thompson and Dennis Ritchie of Bell Laboratories

It was later rewritten in C to make it more portable.

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

Who created GNU?

A

Richard Stallman

“GNU’s Not Unix”

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

What is the GPL?

A

The GNU General Public License. A free software license

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

The most important piece in the operating system

A

The kernel

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

What is the primary job of the kernel?

A

It allows the hardware to talk to the software

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

Who developed the Linux kernel?

A

Linux Torvalds

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

What year was the Linux kernel developed?

A

1991

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

What is GNU known for?

A

The Free Software Movement. A campaigns to win for the users of computing the freedom to run, copy, distribute, study, change and improve free software.

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

What does the term Linux actually refer to?

A

The Linux kernel

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

Why are distributions referred to as “Linux operating systems”?

A

Because they use the Linux kernel

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

A Linux system is divided into what three main parts?

A
  1. Hardware
  2. Linux kernel
  3. User space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the most popular Linux distributions?

A
Debian
Red Hat Enterprise Linux
Ubuntu
Fedora
Linux Mint
Gentoo
Arch Linux
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A distribution used mostly as an enterprise server OS

A

Red Hat Enterprise Linux (RHEL)

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

A Debian-based operating system developed by Canonical.

A

Ubuntu - One of the most popular Linux distributions for personal machines

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

An upstream RHEL operating system

A

Fedora - RHEL gets updates from Fedora after thorough testing and quality assurance

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

A distribution based off of Ubuntu

A

Linux Mint

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

A flexible OS made for advanced users

A

Gentoo

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

A lightweight and flexible Linux distribution driven 100% by the community

A

Arch Linux

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

Created by a community that promotes the use of Linux everywhere, working together in an open, transparent and friendly manner as part of the worldwide Free and Open Source Software community

A

openSUSE

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

A program that takes your commands from the keyboard and sends them to the operating system to perform

A

The shell

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

Almost all Linux distributions will default to what shell?

A

bash (Bourne Again shell)

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

Common shells

A

bash, bourne, korn, ksh, zsh, tsch

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

What is everything in Linux?

A

Everything in Linux is a file

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

How is every file organized in Linux?

A

In a hierarchical directory tree

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

The first directory in the file system is aptly named?

A

The root directory

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

The location of files and directories are referred to as?

A

paths

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

How to print working directory showing you which directory you are in with a path from root?

A

pwd

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

What command let’s you move around the filesystem?

A

cd (change directory)

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

What are the two ways to specify a path?

A
  1. Absolute path

2. Relative path

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

The path from the root directory

A

Absolute path

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

The path from where you are currently in filesystem

A

Relative path

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

The root directory is commonly shown as what?

A

A slash /

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

Shortcut to the directory you are currently in

A

A single period .

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

Shortcut to the parent directory

A

A double period ..

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

Shortcut to the user’s home directory

A

A tilde ~

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

Shortcut to the previous directory

A

A hyphen -

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

Command to list directory contents and show you detailed information about the files and directories you are looking at

A

ls

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

Not all files in a directory will be visible. Filenames that start with what are hidden?

A

How Filenames that start with a period . are hidden

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

How do you view hidden files?

A

Using the -a flag on the ls command (a for all)

$ ls -a

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

This flag on the ls command will show you detailed information

A

$ ls -l

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

What does the Touch command do?

A

Touch allows you to create new empty files.

Touch is also used to change timestamps on existing files and directories

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

What does the file command do?

A

It’s used to find out what kind of file a file is

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

A simple command to display file contents but it can also combine multiple files and show you the output of them.

A

cat command, short for concatenate

It’s only meant for short content

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

Displays text in a paged manner, so you can navigate through a larger text file page by page

A

less command

There are commands to navigate through less e.g. page up and down, q to quit, g and G to move to the beginning and end of the file

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

Lists the history of the commands that you previously entered

A

history

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

How to run the same command you did before

A

Press the up arrow

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

What does !! do?

A

Runs the previous command without typing it again

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

How to use the reverse search command?

A

ctrl-R and start typing parts of the command you want and it will show you matches and you can just navigate through them by hitting the ctrl-R key again

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

How to clear up your display

A

clear command

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

If you start typing the beginning of a command, file, directory, etc and hit the Tab key what happens?

A

will autocomplete based on what it finds in the directory you are searching

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

A character that can be substituted for a pattern based selection, giving you more flexibility with searches

A

A wildcard

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

Copy files

A

cp

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

Wildcard used to represent all single characters or any string

A

*

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

Wildcard used to represent one character

A

?

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

Wildcard used to represent a character from a group

A

[ ]

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

How to recursively copy the files and directories within a directory?

A

With the recursive flag and the cp command

$ cp -r

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

How can you ensure that a file you are copying isn’t accidentally overwritten with a file of the same name?

A

With the interactive flag to prompt you before overwriting a file

$ cp -i

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

Used for moving files and also renaming them

A

mv

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

What does the -b flag do when used with the mv command?

$ mv -b directory1 directory2

A

It will make a backup of that file and it will rename the old version with a ~

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

What does mkdir do?

A

Make Directory

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

How can you create directories and subdirectories at the same time?

A

WIth the -p parent flag

$ mkdir -p directory/subdirectory

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

The command that is used to delete files and directories.

A

rm

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

Does Linux have a trash can that you can fish out removed files?

A

No

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

What are some safety measures to prevent files from accidental deletion?

A

Write-protected files will prompt you for confirmation before deleting them

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

What flag tells rm to remove all files, whether they are write protected or not, without prompting the user?

A

The -f or force flag

$ rm -f file1

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

What rm flag will give you a prompt on whether you want to actually remove the files or directories?

A

The -i interactive flag

$ rm -i file1

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

How can you remove a directory and remove all the files and any subdirectories it may have?

A

With the -r recursive flag

$ rm -r directory1

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

How can you remove an empty directory?

A

With the rmdir command

$ rmdir directory

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

A command that allows you to specify a directory to search, and what you’re searching for

A

The find command

$ find /home -name pic.jpg
$ find /home -type d -name MyFolder

type -d is for directory

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

A built-in bash command that provides help for other bash commands (echo, logout, pwd, etc)

A

help

$ help echo

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

For executable programs, it’s a convention to have a help option

A

–help

$ echo –help

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

How to view the manuals for a command?

A

man for the man pages

$ man ls

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

What if you are ever feeling doubtful about what a command does?

A

Use the whatis command

$ whatis ls

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

What can you do if a command is too repetitive to type over and over?

A

Create an alias

$ alias foobar=’ls -la’

75
Q

Alias are temporary and won’t persist after reboot. How can you make an alias permanent?

A

Add the alias to a file like ~/.bashrc

76
Q

How to delete an alias?

A

With the unalias command

$ unalias foobar

77
Q

How can you exit from the shell?

A
  1. ) $ exit
  2. ) $ logout
  3. ) With a terminal GUI, you can just close the terminal,
78
Q

What are the I/O (input/output) streams?

A
  1. stdout (Standard Out)
  2. stdin (Standard In)
  3. stderr (Standard Error)
79
Q

What are the I/O streams used for?

A

Processes use I/O streams to receive input and return output

80
Q

How can we change the default output behavior of a command line program?

A

By using I/O redirection with a redirection operator that allows us the change where standard output goes

81
Q

What does the > operator do?

A

The > is a redirection operator that allows us the change where standard output goes. It allows us to send the output to a file instead of the screen.

If the file does not already exist it will create it for us. However, if it does exist it will overwrite it.

82
Q

What does the&raquo_space; operator do?

A

The&raquo_space; is a redirection operator that allows us the change where standard output goes. It allows us to send the output to a file instead of the screen.

This will append output to the end of the file, if the file doesn’t already exist it will create it.

83
Q

What is the < operator used for?

A

< is the stdin redirection operator

84
Q

What is a file descriptor?

A

A file descriptor is a non-negative number that is used to access a file or stream

85
Q

What are the file descriptors for stdin, stdout and stderr?

A

0, 1, and 2 respectively

86
Q

What is the redirection operator 2> file.txt doing?

A

Redirecting stderr output to file.txt rather than the screen

87
Q

What does 2>&1 achieve?

A

2>&1 sends stderr to whatever stdout is pointing to

E.g. $ ls /fake/directory > file.txt 2>&1

Outputs stderr and stdout to file.txt

88
Q

What does &> achieve?

A

Redirects both stdout and stderr to a file

E.g. $ ls /fake/directory &> file.txt

89
Q

How can you get rid of stderr messages completely?

A

Redirect stderr to /dev/null

E.g. $ ls /fake/directory 2> /dev/null

90
Q

How can get the stdout of a command and make that the stdin to another process?

A

Using the pipe operator ‘|’.

E.g. $ cat file.txt | less

91
Q

How can you write the output of a command to two different streams?

A

Using the tee command.

E.g. $ ls | tee file.txt

Will print the output of ls to the screen and to file.txt

92
Q

What command outputs a whole lot of information about the environment variables you currently have set?

A

env

93
Q

What are environment variables?

A

Variables that contain useful information that the shell and other processes can use

94
Q

What is the PATH environment variable?

A

It contains a list of paths separated by a colon that your system searches for binaries when it runs a command

95
Q

What is the cut command?

A

The cut command extracts portions of text from a file

cut by characters with -c
cut by fields with -f
change field delimiter with -d

96
Q

Similar to the cat command, but it can merge lines together in a file

A

The paste command with the -s flag

The -d fag can change the delimiter from the default TAB

97
Q

How can you views the first couple of lines in a text file?

A

Using the head command you see the first 10 lines

You can also modify the line count using the -n flag

e.g. $ head -n 15 /var/log/syslog

98
Q

How can you view the last couple of lines in a text file?

A

The tail command lets you see the last 10 lines of a file

You can also modify the line count using the -n flag

e.g. $ tail -n 10 /var/log/syslog

The -f (follow) flag will follow the file as it grows showing new entries

99
Q

What command is used to convert TABs to spaces?

A

expand

100
Q

What command can convert back each group of spaces to a TAB?

A

unexpand

101
Q

This command allows you to merge multiple files together by a common field

A

join

102
Q

This command will split a file into different files. By default it will split them once they reach a 1000 line limit.

A

split

103
Q

This command is useful for sorting lines in a file

A

sort

The -r flag will reverse sort

The -n flag will sort by numerical value

104
Q

This command allows you to translate a set of characters into another set of characters

A

tr (translate)

105
Q

Let’s say you had a file with lots of duplicates. How can you remove them?

A

uniq (unique)

  • c counts occurrences
  • u shows only unique entries
  • d shows only duplicate entries
106
Q

What is the biggest weakness of the uniq of the command?

A

uniq does not detect duplicate lines unless they are adjacent so it should be used along with the sort command

107
Q

This command shows the total count of words in a file

A

wc

It display the number of lines, number of words and number of bytes or to see a certain field, use the flag -l, -w, or -c respectively

108
Q

How can we number the lines of a file?

A

nl (number lines)

109
Q

What command allows you to search files for characters that match a certain pattern?

A

grep

Search case insensitive with the -i flag

You can even use regular expressions in your pattern

110
Q

A powerful tool to do pattern based selection

A

Regular Expressions

111
Q

The two most popular text editors that are installed by default on most Linux distributions

A

vim and emacs

112
Q

What does vim stand for?

A

vi (Improved)

113
Q

An editor that you can do all your code editing, file manipulation, etc all within

A

emacs

114
Q

Why do traditional operating systems have users and groups?

A

They exist solely for access and permissions

115
Q

What is a user’s home directory?

A

A directory where user specific files get stored. This is usually located in /home/username

116
Q

What’s the difference between user ids and usernames?

A

usernames are the friendly way to associate users with identification, but the system identifies users by their UID

117
Q

What are groups in Linux?

A

Sets of users with permission set by that group.

They are identified by the system with their group ID (GID)

118
Q

What are system daemons?

A

They continuously run processes to keep the system functioning

119
Q

The most powerful user on the system

A

The superuser root that can access any file and start and terminate any process

120
Q

If root access is needed you can run a command as root using what command?

A

sudo (superuser do)

121
Q

This command will “substitute users” and open a root shell if no username is specified

A

su (substitute users)

122
Q

if you need to run commands as the superuser should you use su or sudo?

A

sudo

It’s much easier to make a critical mistake running everything in root using su

123
Q

What file called the lists users who can run sudo?

A

/etc/sudoers file

You can edit this file with the visudo command

124
Q

What is the visudo command used for?

A

Editing the /etc/sudoers file that lists users who can run sudo

125
Q

This file shows you a list of users and detailed information about them

A

/etc/passwd

There are many fields separated by colons that tell you additional information about the user

126
Q

Why are there users on a Linux system?

A

Users are really only on the system to run processes with different levels of permissions

127
Q

What is the vipw tool used for?

A

You can edit the /etc/passwd file by hand with the vipw tool but it’s better to use tools such as useradd and userdel

128
Q

This file is used to store information about user authentication. It requires superuser read permissions.

A

/etc/shadow

In most distributions user authentication doesn’t rely on just the /etc/shadow file. There are other mechanisms in place such as PAM (Pluggable Authentication Modules).

129
Q

This file allows for different groups with different permissions.

A

/etc/group

130
Q

You can use what commands to add, delete or change the password of a user if you are root?

A

useradd
userdel
passwd

131
Q

There are what four parts to a file’s permissions?

A

1.) filetype: d for direcotry or - for regular file

The next three parts of the file mode are the permissions (3 bits each).

  1. ) user permissions
  2. ) group permissions
  3. ) other permissions (everyone else)
132
Q

There are 3 bits to represent user permissions. What do these characters represent?

A

r: readable
w: writable
x: executable (basically an executable program)
- : empty

133
Q

Changing permissions can easily be done with what command?

A

chmod

You can add or remove permissions with a + or -

Symbolic way:

e. g. $ chmod u+x myfile
e. g. $ chmod u-x myfile

Add and remove executable permission bit on the user set

134
Q

How can we change permissions all at once instead of using r, w, or x to change a single permission

A

By using the numerical format

4: read permission
2: write permission
1: execute permission

numerical way:
e.g. $ chmod 755 myfile

7 = 4 + 2 + 1, so 7 is the user permissions and it has read, write and execute permissions

135
Q

Why should we take precaution when using the chmod command?

A

You could potentially expose a sensitive file for everyone to modify

136
Q

You can modify the group and user ownership of the file using what two commands?

A

chown and chgrp

e.g. $ sudo chgrp whales myfile

This command will set the group of myfile to whales

137
Q

How can you can set both the user and group at the same time?

A

Add a colon and group name after the user and set both at the same time

e.g. $ sudo chown patty:whales myfile

138
Q

How do you change that default set of permissions used when creating a file?

A

With the umask command

Instead of adding permissions though, umask takes away these permissions

e.g. $ umask 022

All user access (7 - 0 = 7), but no write access for group and other users (7 - 2 = 5 for read and execute)

139
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)

Set User gives us a new permission bit - s.

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

e.g. When a user is running the password command, they are running as root because of SUID and that’s why we are able to access a protected file like /etc/shadow

e. g. $ sudo chmod u+s myfile — Symbolic way
e. g. $ sudo chmod 4755 myfile — Numerical way

The numerical representation for the user bit is 4

140
Q

What allows a program to run as if it was a member of that group?

A

Set Group ID (SGID) similar to SUID

e. g. $ sudo chmod g+s myfile
e. g. $ sudo chmod 2555 myfile

The numerical representation for the group bit is 2

141
Q

How many UIDS are associated with every process?

A

Three

  1. ) effective user ID - used to grant access rights to a process
  2. ) real user ID - the actual ID of the user that launched the process
  3. ) saved user ID - allows a process to switch between the effective UID and real UID
142
Q

How can we ensure that only the owner or the root user can delete or modify the file?

A

By using the the sticky bit

e. g. $ sudo chmod +t mydir
e. g. $ sudo chmod 1755 mydir

The numerical representation for the sticky bit is 1

143
Q

Another name for the programs that are running on your machine

A

Processes

Processes are managed by the kernel and each process has a process ID (PID). A process is the system allocating memory, CPU, I/O to make the program run.

144
Q

This command gives you real time information about the processes running on your system instead of a snapshot

A

top

145
Q

This command prints a list of running processes

A

ps

146
Q

What is the TTY field in the ps output?

A

The TTY is the terminal that executed the command

147
Q

What are the two types of terminals?

A
  1. ) terminal devices
  2. ) pseudoterminal devices

A pseudoterminal is what we’re used to working in. They emulate terminals with the shell terminal window and are denoted by PTS under TTY in the ps command

148
Q

If you were running a program on your shell window such as find and you closed the window what happens?

A

Your process would also close because processes are usually bound to a controlling terminal

149
Q

What types of processes are not bound to a controlling terminal?

A

Processes that run in the background like daemon processes, which are special processes that are essentially keeping the system running

They are denoted by ? under TTY in the ps command

150
Q

How are new processes created?

A

An existing process clones itself using the fork system call. The new process is given a process ID (PID) and a parent process ID (PPID). The execve system call is used to launch a new program, which frees up the cloned memory resources, and the kernel re-allocates new memory resources for the new program.

151
Q

What is the process that spawns all other processes?

A

When the system boots up, the kernels creates a process called init with a PID of 1. The init process can’t be terminated unless the system shuts down.

152
Q

What occurs when a process is terminated?

A
  1. ) _exit system call which frees up the resources that process was using
  2. ) The kernel receives a termination status from the process (a status of 0 means that the process succeeded)
  3. ) The parent process has to acknowledge the termination of the child process by using the wait system call to check the termination status of the child process
153
Q

What is an orphan processes?

A

When a parent process dies before a child process, the kernel knows that it’s not going to get a wait call, so instead it makes these processes “orphans” and puts them under the care of init. Init will perform the wait call to shutdown the process

154
Q

What are zombie processes?

A

A child process terminates, but the parent process hasn’t called wait yet.

155
Q

A notification to a process that something has happened.

A

A signal

They are basically ways processes can communicate

156
Q

Some of the most 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

Numbers can vary with signals so they are usually referred by their names

157
Q

What signal terminates processes?

A

kill

e.g. $ kill 12445 (PID)

By default it sends a TERM signal but you can also specify a signal with the kill command

e.g. $ kill -9 12445 (SIGKILL along with kill command)

158
Q

Differences between SIGHUP, SIGINT, SIGTERM, SIGKILL, SIGSTOP?

A

SIGHUP - Hangup, sent to a process when the controlling terminal is closed
SIGINT - Is an interrupt signal, so you can use Ctrl-C and the system will try to gracefully kill the process
SIGTERM - Kill the process, but allow it to do some cleanup first
SIGKILL - Kill the process, and don’t cleanup
SIGSTOP - Stop/suspend a process

159
Q

Processes use the CPU for a small amount of time called what?

A

A time slice

Process scheduling of time slices is handled by the kernel

160
Q

What is Niceness?

A

A way to influence the kernel’s process scheduling algorithm with a nice value. Processes have a number to determine their priority for the CPU. High numbers are low priority while low or negative numbers are high priority.

161
Q

How can you change the niceness level?

A

The nice command is used to set priority for a new process

e.g. $ nice -n 5 apt upgrade

The renice command is used to set priority on an existing process

e.g. $ renice 10 -p 3245

162
Q

A Linux process can be in a number of different states. What are the most common states?

A

R: running or runnable, it is just waiting for the CPU to process it
S: Interruptible sleep, waiting for an event to complete, such as input from the terminal
D: Uninterruptible sleep, processes that cannot be killed or interrupted with a signal, usually to make them go away you have to reboot or fix the issue
Z: Zombie, terminated processes that are waiting to have their statuses collected
T: Stopped, a process that has been suspended/stopped

163
Q

Everything in Linux is a file, even processes. Where is process information stored?

A

In a special filesystem known as the /proc filesystem

The /proc directory is how the kernel views the system. There is a lot more information here than what you would see in ps.

164
Q

What is Job Control?

A

We can control how our processes run with jobs so that we don’t lose control of our shell while waiting on a slow process to complete.

Appending an ampersand (&) to the command will run it in the background so you can still use your shell.

165
Q

What does the jobs command do?

A

Allow you to view the jobs you just sent to the background

166
Q

If you already ran a job and want to send it to the background how can you do that?

A

First suspend the job with Ctrl-Z, then run the bg command to send it to the background.

167
Q

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

A

Run the fg command along with a specific job ID

e.g. $ fg %1

Leaving off the id will bring back the most recent background job

168
Q

How can you kill background jobs?

A

Using the kill command and the job id

e.g. $ kill %1

169
Q

What do package managers do?

A

Install and maintain the software on your system

170
Q

What are the two most common variety of packages?

A

Debian (.deb) (Debian, Ubuntu, LinuxMint, etc.)

Red Hat (.rpm) (RHEL, Fedora, CentOS, etc.)

171
Q

What are packages?

A

Software (Chrome, Photoshop, etc.) consisting of lots of files that have been compiled into one. A package.

172
Q

People that create software packages are also known as?

A

upstream providers

173
Q

Who reviews, manages and distributes software in the form of packages?

A

package maintainers

174
Q

A central storage location for packages

A

package repositories

175
Q

What is an archive of files?

A

A single file known as an archive contains many files inside of them. Archives have file types such as .rar and .zip.

176
Q

A program used to compress and uncompress files in Linux

A

gzip and gunzip

Files compressed with gzip end in .gz

e. g. $ gzip mycoolfile
e. g. $ gunzip mycoolfile.gz

177
Q

What is the difference between gzip and tar?

A

gzip can’t add multiple files into one archive

178
Q

What is this command doing?

$ tar cvf mytarfile.tar myfile1 myfile2

A

Creating an archive with tar

c - create
v - be verbose and let us see what it’s doing
f - the filename of the tar file has to come after this option

179
Q

What is this command doing?

$ tar xvf mytarfile.tar

A

Unpacking archives with tar

x - extract
v - be verbose and let us see what it’s doing
f - the file you want to extract

180
Q

How can we use tar and gzip together with a file like mycompressedarchive.tar.gz,?

A

First remove the compression with gunzip and then you can unpack the tar file. Or you can alternatively use the z option with tar, which just tells it to use the gzip or gunzip utility.

e. g. $ tar czf myfile.tar.gz creates a compressed tar
e. g. $ tar xzf file.tar uncompress and upack the file

eXtract all Zee Files

181
Q

How can you install direct packages?

A

You can use the package management commands

rpm for .rpm
dpkg for .deb

182
Q

Two of the most popular package management systems

A

yum for redhat

apt for debian

183
Q

What is the difference between (yum and apt) and (rpm and dpkg)?

A

yum and apt also include installing package dependencies

184
Q

When building from source, what should you use instead of make install?

A

$ sudo checkinstall

This command will essentially “make install” and build a .deb package and install it. This makes it easier to remove the package later on.