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
Q

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

A

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

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

How do we match an A followed by p through z followed by le?

A

“Ap[p-z]le”

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

How to write down all words that end with “x”

A

x$

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

How to look for all three-letter words that start with a y or end with a z?

A

grep -E “^y..$|..z$”

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

What does the head command do?

A

Outputs the first 10 lines of a file

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

What does the tail command do?

A

Outputs the last 10 lines of a file

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

How do we go to the top of the file and bottom of the file in vim?

A

gg to the top and G to the bottom

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

How do we add line numbers to vim lines?

A

set nu

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

How do we switch into the insert mode and insert at the cursor in vim?

A

i

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

How do we switch into the insert mode and insert at the start of the line in vim?

A

I

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

How do we switch into the insert mode and insert under the current line in vim?

A

o

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

How do we write a file in vim?

A

:w

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

How do we quit vim?

A

:q

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

How do we write and quit?

A

:wq

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

How do we find the amount of available storage space on the hardware?

A

df -h

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

Where does the CPU information live on a linux machine?

A

cat /proc/cpuinfo

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

How do you find out how much RAM is installed?

A

sudo cat /proc/meminfo

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

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?

A

free

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

How to determine the BIOS version?

A

sudo lshw

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

how do we start a shell script?

A

!/bin/bash

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

What’s the basic syntax for if statements in bash?

A

if [some test]
then
command
fi

46
Q

What’s the basic syntax for for-loops in bash?

A

for variable in list;
do command;
done

— note the use of semicolon!! –

47
Q

What’s the standard distribution release?

A

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
Q

What’s a rolling release?

A

It’s a release that is kept up to date using small and frequent updates to the core of the OS

49
Q

How do we count the number of processes that are currently running in our system?

A

ps aux | wc -l

50
Q

How do we view information about the load of our system?

A

cat /proc/loadavg OR uptime

51
Q

How many processes are running as a default user?

A

ps -U cloud_user | wc -l

52
Q

How do we find a pid of process x?

A

ps aux | grep x

53
Q

Where do we check a process for a number of threads?

A

cat /proc/[PID of a process]/status

54
Q

How do you verify that the web server is running

A

Type curl -I localhost

55
Q

What is stored in the /etc/boot folder?

A

System boot configuration~ contains boot configuration files and parameters, Linux Kernel, and initial RAM disk

56
Q

What is stored in the /etc/fstab folder?

A

Partition Mount Point. it contains a list of local users and their attributes

57
Q

What is stored in the /etc/passwd folder?

A

User Attributes - a list of local users and their attributes

58
Q

What is stored in the /etc/group folder?

A

group attributes

59
Q

What is stored in the /etc/hosts folder?

A

A list of IP addresses and hosts that we want to associate with these addresses

60
Q

What’s stored on the sys directory?

A

Pseudo file system that the kernel uses to give us information about devices

61
Q

What’s sysfs?

A

A virtual file system the purpose of which is to export information about various kernel subsystems and associated drivers

62
Q

How do we get a relatively interactive view of the processes?

A

Use top command

63
Q

Dev file system?

A

A pseudo file system that contains device files - normally with block or character devices; it reads hard drive as a file

64
Q

What does a kernel ring buffer do?

A

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
Q

What is a CPU?

A

Central Processing Unit. It processes computer functions and performs calculations

66
Q

What’s RAM?

A

Random Access Memory. It’s a high-performance, volatile storage

67
Q

What’s secondary storage?

A

HDD/SSD/DVD. It’s persistent storage for data not currently in use

68
Q

What’s an NIC?

A

network interface card. It permits connections to a network

69
Q

What does swap memory do?

A

It uses hard disk as RAM

70
Q

What are hardware drivers?

A

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
Q

How do we determine the user’s IP address?

A

sudo ip addr show

72
Q

How do we determine the user’s MAC address?

A

sudo mac addr show

73
Q

How do we determine the gateway?

A

sudo ip route show

74
Q

How do we determine the DNS server?

A

cat /etc/resolv.conf | grep nameserver

75
Q

How do you perform a DNS lookup and find the IP address given a human-readable name?

A

host www.google.com

76
Q

How do you perform a DNS lookup and find the IP address given a human-readable name USING EXTERNAL DNS?

A

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
Q

How do we test the connectivity to a website?

A

we ping it with a c1 flag:

ping -c1 www.linuxacademy.com

78
Q

How do we view general system logs and messages?

A

/var/log/messages/

79
Q

How do we view general system logs for Debian-based systems?

A

/var/log/syslog

80
Q

How do we view authentication logs?

A

/var/log/auth.log

81
Q

How do we view red-hat-based system logs?

A

/var/log/secure

82
Q

How do we view system boot logs?

A

/var/log/boot.log

83
Q

How do we view system cron job logs?

A

/var/log/cron.log

84
Q

How do we view kernel logs?

A

/var/log/kern.log

85
Q

How do we view authentication failure logs?

A

/var/log/faillog

86
Q

What’s the key distinction between routers and switches?

A

Switches forward packets within a network, routers forward packets between networks

87
Q

Who are system users?

A

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
Q

What privileges does a standard user have?

A

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
Q

What privileges does a root user have?

A

It has full access to all permissions on the system and is used for system-level administration tasks

90
Q

How to identify what group does user_a belong to?

A

id user_a

91
Q

How do you know user_a ‘s home directory?

A

getent passwd user_a

92
Q

What is user_a ‘s login shell?

A

cat /etc/passwd | grep user_a

93
Q

How do we create a user with a default home directory?

A

sudo useradd -m mike

94
Q

How do we display all groups that a user belongs to?

A

groups

95
Q

How do we add a user called michael to the group called linuxacademy?

A

sudo usermod -a -G linuxacademy michael

96
Q

What ID is typically reserved for root account?

A

UID 0

97
Q

Which IDs are typically reserved for system users, or service accounts?

A

0-99

98
Q

Which IDs are typically reserved for standard users?

A

100+

99
Q

Which ID is typically reserved for user nobody?

A

65534

100
Q

What does chown stand for?

A

change ownership

101
Q

What does chmod stand for?

A

Change mode

102
Q

How would you change the group to linuxacademy for file called testfile?

A

chown :linuxacademy testfile

103
Q

How would you change file ownership to be owner by user usr1 for a file f1

A

chown usr1 f1

104
Q

How would you change a file’s user and group ownership to cloud_u for a file called file1?

A

chown cloud_u:cloud_u file1

105
Q

How would you change permissions to be read write execute for all?

A

chmod 777 file1

106
Q

How would you add execute to current permissions?

A

chmod +x file1

107
Q

How would you remove write from current permission?

A

chmod -w file1

108
Q

What is the difference between a /tmp/ and /var/tmp

A

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
Q

What does mktemp do?

A

it creates a temporary file or directory with a randomized file name portion

110
Q

How can we specify the characters in the directory called michael.something through make temp?

A

mktemp /tmp/michael.XXX for 3 random chars

111
Q

How do you make a symbolic link?

A

ln -s [target] [link name]