Beginner Linux Flashcards

(184 cards)

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
The first directory in the file system is aptly named?
The root directory
26
The location of files and directories are referred to as?
paths
27
How to print working directory showing you which directory you are in with a path from root?
pwd
28
What command let's you move around the filesystem?
cd (change directory)
29
What are the two ways to specify a path?
1. Absolute path | 2. Relative path
30
The path from the root directory
Absolute path
31
The path from where you are currently in filesystem
Relative path
32
The root directory is commonly shown as what?
A slash /
33
Shortcut to the directory you are currently in
A single period .
34
Shortcut to the parent directory
A double period ..
35
Shortcut to the user's home directory
A tilde ~
36
Shortcut to the previous directory
A hyphen -
37
Command to list directory contents and show you detailed information about the files and directories you are looking at
ls
38
Not all files in a directory will be visible. Filenames that start with what are hidden?
How Filenames that start with a period . are hidden
39
How do you view hidden files?
Using the -a flag on the ls command (a for all) $ ls -a
40
This flag on the ls command will show you detailed information
$ ls -l
41
What does the Touch command do?
Touch allows you to create new empty files. Touch is also used to change timestamps on existing files and directories
42
What does the file command do?
It's used to find out what kind of file a file is
43
A simple command to display file contents but it can also combine multiple files and show you the output of them.
cat command, short for concatenate It’s only meant for short content
44
Displays text in a paged manner, so you can navigate through a larger text file page by page
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
45
Lists the history of the commands that you previously entered
history
46
How to run the same command you did before
Press the up arrow
47
What does !! do?
Runs the previous command without typing it again
48
How to use the reverse search command?
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
49
How to clear up your display
clear command
50
If you start typing the beginning of a command, file, directory, etc and hit the Tab key what happens?
will autocomplete based on what it finds in the directory you are searching
51
A character that can be substituted for a pattern based selection, giving you more flexibility with searches
A wildcard
52
Copy files
cp
53
Wildcard used to represent all single characters or any string
*
54
Wildcard used to represent one character
?
55
Wildcard used to represent a character from a group
[ ]
56
How to recursively copy the files and directories within a directory?
With the recursive flag and the cp command $ cp -r
57
How can you ensure that a file you are copying isn't accidentally overwritten with a file of the same name?
With the interactive flag to prompt you before overwriting a file $ cp -i
58
Used for moving files and also renaming them
mv
59
What does the -b flag do when used with the mv command? $ mv -b directory1 directory2
It will make a backup of that file and it will rename the old version with a ~
60
What does mkdir do?
Make Directory
61
How can you create directories and subdirectories at the same time?
WIth the -p parent flag $ mkdir -p directory/subdirectory
62
The command that is used to delete files and directories.
rm
63
Does Linux have a trash can that you can fish out removed files?
No
64
What are some safety measures to prevent files from accidental deletion?
Write-protected files will prompt you for confirmation before deleting them
65
What flag tells rm to remove all files, whether they are write protected or not, without prompting the user?
The -f or force flag $ rm -f file1
66
What rm flag will give you a prompt on whether you want to actually remove the files or directories?
The -i interactive flag $ rm -i file1
67
How can you remove a directory and remove all the files and any subdirectories it may have?
With the -r recursive flag $ rm -r directory1
68
How can you remove an empty directory?
With the rmdir command $ rmdir directory
69
A command that allows you to specify a directory to search, and what you’re searching for
The find command $ find /home -name pic.jpg $ find /home -type d -name MyFolder type -d is for directory
70
A built-in bash command that provides help for other bash commands (echo, logout, pwd, etc)
help $ help echo
71
For executable programs, it’s a convention to have a help option
--help $ echo --help
72
How to view the manuals for a command?
man for the man pages $ man ls
73
What if you are ever feeling doubtful about what a command does?
Use the whatis command $ whatis ls
74
What can you do if a command is too repetitive to type over and over?
Create an alias $ alias foobar='ls -la'
75
Alias are temporary and won't persist after reboot. How can you make an alias permanent?
Add the alias to a file like ~/.bashrc
76
How to delete an alias?
With the unalias command $ unalias foobar
77
How can you exit from the shell?
1. ) $ exit 2. ) $ logout 3. ) With a terminal GUI, you can just close the terminal,
78
What are the I/O (input/output) streams?
1. stdout (Standard Out) 2. stdin (Standard In) 3. stderr (Standard Error)
79
What are the I/O streams used for?
Processes use I/O streams to receive input and return output
80
How can we change the default output behavior of a command line program?
By using I/O redirection with a redirection operator that allows us the change where standard output goes
81
What does the > operator do?
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
What does the >> operator do?
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. This will append output to the end of the file, if the file doesn't already exist it will create it.
83
What is the < operator used for?
< is the stdin redirection operator
84
What is a file descriptor?
A file descriptor is a non-negative number that is used to access a file or stream
85
What are the file descriptors for stdin, stdout and stderr?
0, 1, and 2 respectively
86
What is the redirection operator 2> file.txt doing?
Redirecting stderr output to file.txt rather than the screen
87
What does 2>&1 achieve?
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
What does &> achieve?
Redirects both stdout and stderr to a file E.g. $ ls /fake/directory &> file.txt
89
How can you get rid of stderr messages completely?
Redirect stderr to /dev/null E.g. $ ls /fake/directory 2> /dev/null
90
How can get the stdout of a command and make that the stdin to another process?
Using the pipe operator '|'. E.g. $ cat file.txt | less
91
How can you write the output of a command to two different streams?
Using the tee command. E.g. $ ls | tee file.txt Will print the output of ls to the screen and to file.txt
92
What command outputs a whole lot of information about the environment variables you currently have set?
env
93
What are environment variables?
Variables that contain useful information that the shell and other processes can use
94
What is the PATH environment variable?
It contains a list of paths separated by a colon that your system searches for binaries when it runs a command
95
What is the cut command?
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
Similar to the cat command, but it can merge lines together in a file
The paste command with the -s flag The -d fag can change the delimiter from the default TAB
97
How can you views the first couple of lines in a text file?
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
How can you view the last couple of lines in a text file?
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
What command is used to convert TABs to spaces?
expand
100
What command can convert back each group of spaces to a TAB?
unexpand
101
This command allows you to merge multiple files together by a common field
join
102
This command will split a file into different files. By default it will split them once they reach a 1000 line limit.
split
103
This command is useful for sorting lines in a file
sort The -r flag will reverse sort The -n flag will sort by numerical value
104
This command allows you to translate a set of characters into another set of characters
tr (translate)
105
Let's say you had a file with lots of duplicates. How can you remove them?
uniq (unique) - c counts occurrences - u shows only unique entries - d shows only duplicate entries
106
What is the biggest weakness of the uniq of the command?
uniq does not detect duplicate lines unless they are adjacent so it should be used along with the sort command
107
This command shows the total count of words in a file
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
How can we number the lines of a file?
nl (number lines)
109
What command allows you to search files for characters that match a certain pattern?
grep Search case insensitive with the -i flag You can even use regular expressions in your pattern
110
A powerful tool to do pattern based selection
Regular Expressions
111
The two most popular text editors that are installed by default on most Linux distributions
vim and emacs
112
What does vim stand for?
vi (Improved)
113
An editor that you can do all your code editing, file manipulation, etc all within
emacs
114
Why do traditional operating systems have users and groups?
They exist solely for access and permissions
115
What is a user's home directory?
A directory where user specific files get stored. This is usually located in /home/username
116
What's the difference between user ids and usernames?
usernames are the friendly way to associate users with identification, but the system identifies users by their UID
117
What are groups in Linux?
Sets of users with permission set by that group. They are identified by the system with their group ID (GID)
118
What are system daemons?
They continuously run processes to keep the system functioning
119
The most powerful user on the system
The superuser root that can access any file and start and terminate any process
120
If root access is needed you can run a command as root using what command?
sudo (superuser do)
121
This command will "substitute users" and open a root shell if no username is specified
su (substitute users)
122
if you need to run commands as the superuser should you use su or sudo?
sudo It's much easier to make a critical mistake running everything in root using su
123
What file called the lists users who can run sudo?
/etc/sudoers file You can edit this file with the visudo command
124
What is the visudo command used for?
Editing the /etc/sudoers file that lists users who can run sudo
125
This file shows you a list of users and detailed information about them
/etc/passwd There are many fields separated by colons that tell you additional information about the user
126
Why are there users on a Linux system?
Users are really only on the system to run processes with different levels of permissions
127
What is the vipw tool used for?
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
This file is used to store information about user authentication. It requires superuser read permissions.
/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
This file allows for different groups with different permissions.
/etc/group
130
You can use what commands to add, delete or change the password of a user if you are root?
useradd userdel passwd
131
There are what four parts to a file's permissions?
1.) filetype: d for direcotry or - for regular file The next three parts of the file mode are the permissions (3 bits each). 2. ) user permissions 3. ) group permissions 4. ) other permissions (everyone else)
132
There are 3 bits to represent user permissions. What do these characters represent?
r: readable w: writable x: executable (basically an executable program) - : empty
133
Changing permissions can easily be done with what command?
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
How can we change permissions all at once instead of using r, w, or x to change a single permission
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
Why should we take precaution when using the chmod command?
You could potentially expose a sensitive file for everyone to modify
136
You can modify the group and user ownership of the file using what two commands?
chown and chgrp e.g. $ sudo chgrp whales myfile This command will set the group of myfile to whales
137
How can you can set both the user and group at the same time?
Add a colon and group name after the user and set both at the same time e.g. $ sudo chown patty:whales myfile
138
How do you change that default set of permissions used when creating a file?
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
What allows a user to run a program as the owner of the program file rather than as themselves?
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
What allows a program to run as if it was a member of that group?
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
How many UIDS are associated with every process?
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
How can we ensure that only the owner or the root user can delete or modify the file?
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
Another name for the programs that are running on your machine
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
This command gives you real time information about the processes running on your system instead of a snapshot
top
145
This command prints a list of running processes
ps
146
What is the TTY field in the ps output?
The TTY is the terminal that executed the command
147
What are the two types of terminals?
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
If you were running a program on your shell window such as find and you closed the window what happens?
Your process would also close because processes are usually bound to a controlling terminal
149
What types of processes are not bound to a controlling terminal?
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
How are new processes created?
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
What is the process that spawns all other processes?
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
What occurs when a process is terminated?
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
What is an orphan processes?
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
What are zombie processes?
A child process terminates, but the parent process hasn't called wait yet.
155
A notification to a process that something has happened.
A signal They are basically ways processes can communicate
156
Some of the most common signals?
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
What signal terminates processes?
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
Differences between SIGHUP, SIGINT, SIGTERM, SIGKILL, SIGSTOP?
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
Processes use the CPU for a small amount of time called what?
A time slice Process scheduling of time slices is handled by the kernel
160
What is Niceness?
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
How can you change the niceness level?
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
A Linux process can be in a number of different states. What are the most common states?
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
Everything in Linux is a file, even processes. Where is process information stored?
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
What is Job Control?
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
What does the jobs command do?
Allow you to view the jobs you just sent to the background
166
If you already ran a job and want to send it to the background how can you do that?
First suspend the job with Ctrl-Z, then run the bg command to send it to the background.
167
How can you move a job from the background to the foreground?
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
How can you kill background jobs?
Using the kill command and the job id e.g. $ kill %1
169
What do package managers do?
Install and maintain the software on your system
170
What are the two most common variety of packages?
Debian (.deb) (Debian, Ubuntu, LinuxMint, etc.) Red Hat (.rpm) (RHEL, Fedora, CentOS, etc.)
171
What are packages?
Software (Chrome, Photoshop, etc.) consisting of lots of files that have been compiled into one. A package.
172
People that create software packages are also known as?
upstream providers
173
Who reviews, manages and distributes software in the form of packages?
package maintainers
174
A central storage location for packages
package repositories
175
What is an archive of files?
A single file known as an archive contains many files inside of them. Archives have file types such as .rar and .zip.
176
A program used to compress and uncompress files in Linux
gzip and gunzip Files compressed with gzip end in .gz e. g. $ gzip mycoolfile e. g. $ gunzip mycoolfile.gz
177
What is the difference between gzip and tar?
gzip can't add multiple files into one archive
178
What is this command doing? $ tar cvf mytarfile.tar myfile1 myfile2
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
What is this command doing? $ tar xvf mytarfile.tar
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
How can we use tar and gzip together with a file like mycompressedarchive.tar.gz,?
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
How can you install direct packages?
You can use the package management commands rpm for .rpm dpkg for .deb
182
Two of the most popular package management systems
yum for redhat | apt for debian
183
What is the difference between (yum and apt) and (rpm and dpkg)?
yum and apt also include installing package dependencies
184
When building from source, what should you use instead of make install?
$ 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.