Chapter 2 Flashcards

1
Q

What’s the standard Linux shell?

A

Ha! It’s both a command line interpreter and a programming language

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

How do we check the exit status? (print it to the command line)

A

echo $?

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

How do we search for a term within a man page?

A

/ (forward slash) term (e.g. /nana) and then ‘n’ for next entry ahead ‘N’ for next entry behind

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

How to search for a specific keyword?

A

man -k wordToSearch

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

What are info pages and how are they different from man pages? How do you get around there?

A

They are additional documentation with more robust capability and detail than man. You can enter into page, hit next and previous with ‘n’ and ‘p’ keys

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

How to count the number of lines in a file?

A

wc -l file.txt

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

How to count the total number of characters in a file?

A

wc -m file.txt

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

How to count the number of characters on the longest line in a file?

A

wc -L file.txt

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

How to append some stuff to an existing file?

A

use&raquo_space; file.txt (rather than ‘>’)

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

How do we view all files that start with a dot?

A

ls -a

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

How do we view all files?

A

ls -all

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

How do we view a more detailed listing of files, including their sizw?

A

ls -lh

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

How do we handle variables in shell?

A

We do not have to store them anywhere - just declare them in a window, like so:
test_var=”this is a var”
To show it, do
echo $test_var

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

How do we display a home directory?

A

$HOME

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

Which variable shows the user’s home directory?

A

$HOME

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

Which variable is the primary prompt string?

A

$PS1

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

Which variable is a colon-separated list of directories where the shell looks for commands?

A

$PATH

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

How can we store the contents of a “list files” command in a variable?

A

var1=$(ls)

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

How are bash single quotes different from double quotes?

A

Single quotes ‘ preserve the literal value of every character contained within the quotes, including the escape character
Double quotes ‘’ preserve the literal value of most characters contained within the quotes, exceptions include $ for variables, ‘ for single quoting, and \ for escaping a character

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

What is an escape character, what does it do?

A

A non-quoted backslash \ is the bash escape character; it preserves the literal value of the next following character, with the single exception of newline

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

How do we change the current directory to the user’s home directory?

A

cd ~

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

How do we print the current directory?

A

pwd

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

Show the list of users currently logged in to the system

A

w

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

How to append something to the path variable? or any other variable, same difference

A

PATH=”$PATH:$HOME/scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the source command do in Bash?
The source command reads and executes commands from the file specified as its argument in the current shell environment
26
What's stored in the /boot directory?
Standard boot files
27
What's stored in the /dev directory?
Device files
28
What's stored in the /etc directory?
Configuration files
29
What's stored in the /mnt directory?
Temporary mount points
30
What's stored in the /opt directory?
Optional packages
31
What's stored in the /proc directory?
Kernel and process files
32
What's stored in the /root directory?
Root user home directory
33
What's stored in the /run directory?
Application state files
34
What's stored in the /sbin directory?
System administrator binaries
35
What's stored in the /srv directory?
Service data
36
What's stored in the /usr directory?
User ginaries
37
What's stored in the /var directory?
Variable data files
38
What's stored in the / directory?
Root directory
39
how do we go to the previous directory location?
cd -
40
Which ls flag sorts files by the last time the file was modified, newest first?
-t
41
How do we view all files except . and .. ones?
ls -A
42
how do we view more info about the files using ls?
-l
43
How do we sort by file size in ls?
-s
44
How do we know last time a file was accessed?q
-u
45
How do we know last time a file was modified using ls?
-l
46
How do we differentiate between absolute and relative paths?
absolute start with a "/" - slash! and relative ones start with a word.. :)
47
What does a recursive specifier do in copying folders and directories? also, what does a recursive specifier look like?
it's an -R flag of the cp command
48
What's the tag and commands for forced recursive removal?
rm -rf directoryname
49
How do we remove any file or folder that starts with a number
rm -rf [1-9]*
50
How do we remove any file or folder that END with .conf?
rm -rf *.conf
51
What's the difference between ls -a and ls -A?
capital A shows almost everything (everything except the two dots), lower case shows everything everything!
52
How to view all the environment variables?
env
53
What is globbing?
Globbing is using partial matching to work with groups of files and directories. Matching patterns in fileframes or text by using a wildcard char to create a pattern
54
How do we look for a filename with four characters and a "1" at the end?
???1
55
What does a question mark do in globbing?
It matches any *single* character
56
What does an asterisk do in globbing?
Finds 0 to many matching characters. I.e. file* will match file, file1, file_kseirjnsfjkevn
57
What do brackets [] do?
They match character(s) from a range
58
How do we match uppercase characters with brackets? lowercase? digits?
[A-Z] [a-z] [1-9]
59
How do we customize which digits we want to match using brackets?
[2-5]
60
How do we say we want a character - of either case with brackets?
[a-zA-Z]
61
How do we say we want to match any alphanumeric character with brackets?
[a-zA-Z0-9]
62
How do we use caret in globbing?
We use it to match starting characters
63
How do we use dollar in globbing?
To match ending character
64
How do we use curly brace in globbing?
We match more than one pattern