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
Q

What does the source command do in Bash?

A

The source command reads and executes commands from the file specified as its argument in the current shell environment

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

What’s stored in the /boot directory?

A

Standard boot files

27
Q

What’s stored in the /dev directory?

A

Device files

28
Q

What’s stored in the /etc directory?

A

Configuration files

29
Q

What’s stored in the /mnt directory?

A

Temporary mount points

30
Q

What’s stored in the /opt directory?

A

Optional packages

31
Q

What’s stored in the /proc directory?

A

Kernel and process files

32
Q

What’s stored in the /root directory?

A

Root user home directory

33
Q

What’s stored in the /run directory?

A

Application state files

34
Q

What’s stored in the /sbin directory?

A

System administrator binaries

35
Q

What’s stored in the /srv directory?

A

Service data

36
Q

What’s stored in the /usr directory?

A

User ginaries

37
Q

What’s stored in the /var directory?

A

Variable data files

38
Q

What’s stored in the / directory?

A

Root directory

39
Q

how do we go to the previous directory location?

A

cd -

40
Q

Which ls flag sorts files by the last time the file was modified, newest first?

A

-t

41
Q

How do we view all files except . and .. ones?

A

ls -A

42
Q

how do we view more info about the files using ls?

A

-l

43
Q

How do we sort by file size in ls?

A

-s

44
Q

How do we know last time a file was accessed?q

A

-u

45
Q

How do we know last time a file was modified using ls?

A

-l

46
Q

How do we differentiate between absolute and relative paths?

A

absolute start with a “/” - slash! and relative ones start with a word.. :)

47
Q

What does a recursive specifier do in copying folders and directories? also, what does a recursive specifier look like?

A

it’s an -R flag of the cp command

48
Q

What’s the tag and commands for forced recursive removal?

A

rm -rf directoryname

49
Q

How do we remove any file or folder that starts with a number

A

rm -rf [1-9]*

50
Q

How do we remove any file or folder that END with .conf?

A

rm -rf *.conf

51
Q

What’s the difference between ls -a and ls -A?

A

capital A shows almost everything (everything except the two dots), lower case shows everything everything!

52
Q

How to view all the environment variables?

A

env

53
Q

What is globbing?

A

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
Q

How do we look for a filename with four characters and a “1” at the end?

A

???1

55
Q

What does a question mark do in globbing?

A

It matches any single character

56
Q

What does an asterisk do in globbing?

A

Finds 0 to many matching characters. I.e. file* will match file, file1, file_kseirjnsfjkevn

57
Q

What do brackets [] do?

A

They match character(s) from a range

58
Q

How do we match uppercase characters with brackets? lowercase? digits?

A

[A-Z] [a-z] [1-9]

59
Q

How do we customize which digits we want to match using brackets?

A

[2-5]

60
Q

How do we say we want a character - of either case with brackets?

A

[a-zA-Z]

61
Q

How do we say we want to match any alphanumeric character with brackets?

A

[a-zA-Z0-9]

62
Q

How do we use caret in globbing?

A

We use it to match starting characters

63
Q

How do we use dollar in globbing?

A

To match ending character

64
Q

How do we use curly brace in globbing?

A

We match more than one pattern