Lesson 2 Flashcards

1
Q

What is the shell?

A

A program that enables text based communication between the OS and the user

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

Name a few popular shells

A

BASH, csh, ksh, zsh

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

Describe the basic command line structure for a command

A

command <options> <arguments></arguments></options>

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

What are internal shell commands?

A

Built into the shell itself, things like echo, exit and cd

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

What are external shell commands?

A

Reside in binary files added to the PATH variable

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

What does the type command do?

A

Shows where the binary is located if external command or shows if it’s built in shell command

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

What do double quotes tell the shell?

A

To use the text in between the “…” as regular characters. All special characters lose their meaning except $ and \

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

What do single quotes tell the shell?

A

They revoke any special characters, it will take the string as a literal

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

What do escape characters tell the shell?

A

To remove special meaning of certain characters, for example $ removes the builtin meaning on $

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

How could you with touch create a file 5 times with one command?

A

Using the {..} operator… touch foo{1..5}

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

With rm how can you delete all files matching a pattern?

A

rm foo? deletes anything with foo and 1 additional character

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

When creating a local variable how can you access it’s value?

A

using echo and then $…so echo $foo

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

How to remove a local variable?

A

With the unset command

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

How can you make a local variable global?

A

By using the “export” command

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

What is the PATH variable?

A

stores a list of directories separated by a colon that contains executable programs eligible as external commands to the shell

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

what does the which command do?

A

Shows the path to where the binary is stored

17
Q

What is the command for creating a time variable?

A

date for timezone TZ=GMT date or EST

18
Q

what does the wc command do?

A

used to find out the number of newline count, word count, byte and character count in the files specified by the File arguments to the standard output and hold a total count for all named files.

19
Q

What does the –help command do?

A

Most command have a –help option but it’s normally pretty brief and limited

20
Q

What does the man command do?

A

man displays a manual for a given command like man mkdir

21
Q

If something has more than 1 man page, how do you need to refer to it?

A

Using the category syntax, example passwd(1) vs passwd(5)

22
Q

What is the difference between man and info?

A

info is normally more detailed than man pages and are formatted in hypertext.

23
Q

What does the locate command do?

A

Quickly locates anything matching a given string in the file system. Also supports wildcards for pattern matching, for example astericks

24
Q

How does find differ from locate?

A

find searches a directory tree recursively, it doesn’t maintain a database like locate, but it does support wildcards

25
Q

what does updatedb command do?

A

updates the locate command database

26
Q

when running ls -lh will the directory sizes be correct?

A

No because directories are always shown as 4096 bytes, this is the size of the link

27
Q

What is globbing?

A

Globbing is a simple pattern matching language. Linux shells use this language to refer to groups of files whos names patch a specific pattern

  • matches any number of characters
    ? matches 1 character (not numbers)
    [] matches a class of characters
28
Q

what does -v do for mkdir, rm and cp?

A

Turns on verbose output mode

29
Q

What happens if you move the mv command to move a directory into itself?

A

You will get an error message that it is a subdirectory of itself

30
Q

how would you delete all files starting with “foo” in a directory?

A

rm foo*

31
Q

Using cp, how can we have the copied file retain the permissions and modification time of the original?

A

By using the -p or –preserver options

32
Q

When using mv how can you prevent overwriting files?

A

By using -n or –no-clobber