Chapter 3 Flashcards

1
Q

What does man file do?

A

Determines file type

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

How do we create a directory with a subdirectory?

A

Mkdir -p dir/subdir

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

When working with directories (as opposed to files), which command does not need a recursive flag?

A

mv

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

What are the five key flags in the tar command?

A
  • c create archive
  • x extract archive
  • r append to an archive
  • f read from or write to a file
  • t list the contents of the archive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to get a big picture overview of the filesystem?

A

df -h

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

How to get a big picture overview of the filesystem?

A

df -h

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

How do we create an archive with tar and all the files that are called “file_[smth]?

A

tar cf archive.tar file_*

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

How do we add a file to an archive?

A

tar rf archive.tar

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

How do we check an archive for a specific file with tar? hint: first display the entire archive and then look for what you need

A

tar tvf archive.tar | grep extra.txt

t = tail
v = verbose
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do we compress a normal archive to a maximum degree?

A

gzip -9 archive.tar

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

How do we create a bzip2 archive with tar?

A

tar cjf archive.tar.bz2

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

How to create a zip archive?

A

zip -r archive.zip file1_*

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

How do we determine number of words in a file?

A

wc

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

What does wc do?

A

It counts words

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

How can we count the number of lines rather than words in an input file?

A

wc -l

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

How do we list the recently used commands starting with cat? (or anything else really, cat si just one example)

A

!cat

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

What does the cut command do?

A

It removes sections from lines of files

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

What does the cut command do?

A

It removes sections from lines of files

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

What’s the basic syntax of reading input from a file?

A

command < file

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

What’s the basic syntax of sending input to a file?

A

command > file

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

What’s the basic syntax of appending input to a file?

A

command&raquo_space; file

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

How do we look for all results that end - END! - with Apple or Ball?

A

grep -E “Apple$|Ball$”

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

What do we find when we look for grep -E “Ap*le”

A

A followed by 0 or more p’s followed by “le”

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

What’s the difference between looking for “Ap*le” and “Ap+le”?

A

the plus means 1 or more p’s and the star means 0 or more p’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What's the difference between looking for "Ap?le" and "Ap+le"?
question mark means looking for "maybe another p" followed by le; plus means 1 or more ps the ? won't grep apple because we can only keep results with 1 or no p's (but not 1+)
26
How do we match an A followed by p through z followed by le?
"Ap[p-z]le"
27
How to write down all words that end with "x"
x$
28
How to look for all three-letter words that start with a y or end with a z?
grep -E "^y..$|..z$"
29
What does the head command do?
Outputs the first 10 lines of a file
30
What does the tail command do?
Outputs the last 10 lines of a file
31
How do we go to the top of the file and bottom of the file in vim?
gg to the top and G to the bottom
32
How do we add line numbers to vim lines?
set nu
33
How do we switch into the insert mode and insert at the cursor in vim?
i
34
How do we switch into the insert mode and insert at the start of the line in vim?
I
35
How do we switch into the insert mode and insert under the current line in vim?
o
36
How do we write a file in vim?
:w
37
How do we quit vim?
:q
38
How do we write and quit?
:wq
39
How do we find the amount of available storage space on the hardware?
df -h
40
Where does the CPU information live on a linux machine?
cat /proc/cpuinfo
41
How do you find out how much RAM is installed?
sudo cat /proc/meminfo
42
which command displays the total amount of free and used physical and swap mem‐ ory in the system, as well as the buffers and caches used by the ker‐ nel?
free
43
How to determine the BIOS version?
sudo lshw
44
how do we start a shell script?
#!/bin/bash
45
What's the basic syntax for if statements in bash?
if [some test] then command fi
46
What's the basic syntax for for-loops in bash?
for variable in list; do command; done --- note the use of semicolon!! --
47
What's the standard distribution release?
a release made available after a development period. during this time, all software is updated to a version and then frozen and tested to verify that all software versions work well together.
48
What's a rolling release?
It's a release that is kept up to date using small and frequent updates to the core of the OS
49
How do we count the number of processes that are currently running in our system?
ps aux | wc -l
50
How do we view information about the load of our system?
cat /proc/loadavg OR uptime
51
How many processes are running as a default user?
ps -U cloud_user | wc -l
52
How do we find a pid of process x?
ps aux | grep x
53
Where do we check a process for a number of threads?
cat /proc/[PID of a process]/status
54
How do you verify that the web server is running
Type curl -I localhost
55
What is stored in the /etc/boot folder?
System boot configuration~ contains boot configuration files and parameters, Linux Kernel, and initial RAM disk
56
What is stored in the /etc/fstab folder?
Partition Mount Point. it contains a list of local users and their attributes
57
What is stored in the /etc/passwd folder?
User Attributes - a list of local users and their attributes
58
What is stored in the /etc/group folder?
group attributes
59
What is stored in the /etc/hosts folder?
A list of IP addresses and hosts that we want to associate with these addresses
60
What's stored on the sys directory?
Pseudo file system that the kernel uses to give us information about devices
61
What's sysfs?
A virtual file system the purpose of which is to export information about various kernel subsystems and associated drivers
62
How do we get a relatively interactive view of the processes?
Use top command
63
Dev file system?
A pseudo file system that contains device files - normally with block or character devices; it reads hard drive as a file
64
What does a kernel ring buffer do?
The kernel ring buffer holds messages related to the operation of the kernel - a ring buffer is simply a buffer of a constant size
65
What is a CPU?
Central Processing Unit. It processes computer functions and performs calculations
66
What's RAM?
Random Access Memory. It's a high-performance, volatile storage
67
What's secondary storage?
HDD/SSD/DVD. It's persistent storage for data not currently in use
68
What's an NIC?
network interface card. It permits connections to a network
69
What does swap memory do?
It uses hard disk as RAM
70
What are hardware drivers?
These are the devices that reside in the running kernel (or are loaded as a module) and they enable the OS to use the hardware
71
How do we determine the user's IP address?
sudo ip addr show
72
How do we determine the user's MAC address?
sudo mac addr show
73
How do we determine the gateway?
sudo ip route show
74
How do we determine the DNS server?
cat /etc/resolv.conf | grep nameserver
75
How do you perform a DNS lookup and find the IP address given a human-readable name?
host www.google.com
76
How do you perform a DNS lookup and find the IP address given a human-readable name *USING EXTERNAL DNS*?
You add the address of the external DNS server to the host command, e.g. like so: host www.google.com 1.1.1.1
77
How do we test the connectivity to a website?
we ping it with a c1 flag: | ping -c1 www.linuxacademy.com
78
How do we view general system logs and messages?
/var/log/messages/
79
How do we view general system logs for Debian-based systems?
/var/log/syslog
80
How do we view authentication logs?
/var/log/auth.log
81
How do we view red-hat-based system logs?
/var/log/secure
82
How do we view system boot logs?
/var/log/boot.log
83
How do we view system cron job logs?
/var/log/cron.log
84
How do we view kernel logs?
/var/log/kern.log
85
How do we view authentication failure logs?
/var/log/faillog
86
What's the key distinction between routers and switches?
Switches forward packets within a network, routers forward packets between networks
87
Who are system users?
Users generally deployed when the applications are installed; their home directories are set to application folders and they normally do not have a login shell
88
What privileges does a standard user have?
They are provided with a login shell, a home directory, limited permissions to view file system configurations, and no permission for modifying system configurations.. They may be granted the ability to perform privileged actions using sudo
89
What privileges does a root user have?
It has full access to all permissions on the system and is used for system-level administration tasks
90
How to identify what group does user_a belong to?
id user_a
91
How do you know user_a 's home directory?
getent passwd user_a
92
What is user_a 's login shell?
cat /etc/passwd | grep user_a
93
How do we create a user with a default home directory?
sudo useradd -m mike
94
How do we display all groups that a user belongs to?
groups
95
How do we add a user called michael to the group called linuxacademy?
sudo usermod -a -G linuxacademy michael
96
What ID is typically reserved for root account?
UID 0
97
Which IDs are typically reserved for system users, or service accounts?
0-99
98
Which IDs are typically reserved for standard users?
100+
99
Which ID is typically reserved for user nobody?
65534
100
What does chown stand for?
change ownership
101
What does chmod stand for?
Change mode
102
How would you change the group to linuxacademy for file called testfile?
chown :linuxacademy testfile
103
How would you change file ownership to be owner by user usr1 for a file f1
chown usr1 f1
104
How would you change a file's user and group ownership to cloud_u for a file called file1?
chown cloud_u:cloud_u file1
105
How would you change permissions to be read write execute for all?
chmod 777 file1
106
How would you add execute to current permissions?
chmod +x file1
107
How would you remove write from current permission?
chmod -w file1
108
What is the difference between a /tmp/ and /var/tmp
all content in /var/tmp persists through a system boot. this directory is used by programs or scripts that require more persistent temporary storage than /tmp which clears out upon system boot
109
What does mktemp do?
it creates a temporary file or directory with a randomized file name portion
110
How can we specify the characters in the directory called michael.something through make temp?
mktemp /tmp/michael.XXX for 3 random chars
111
How do you make a symbolic link?
ln -s [target] [link name]