Intro to the Command Line Flashcards

1
Q

What does bash display as the default prompt

A

$

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

What does Zsh display at the default prompt?

A

%

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

What do both Zsh and bash if you are logged into root?

A

#

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

What is the command to show the current shell?

A

echo $SHELL

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

What form do CLI commands always take?

A

[command] [arguments…]

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

What can the first portion of a CLI command be?

A

An existing command like echo or a file path

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

What is a flag?

A

a flag is a special argument, passed first to the command. They start with - for abreviated flags like -a, or – for full word flags like –format

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

command: change directory

A

cd name

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

command: list files in current directory

A

ls

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

command: display the path of the current directory

A

pwd

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

command: create a file

A

touch

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

command: create a directory

A

mkdir

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

command: remove a file or directory

A

rm

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

command: copy a file or directory

A

cp

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

command: print text to STDout

A

echo

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

command: display contents of a file

A

cat

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

command: display the contents of a file starting at the top with page flip option

A

more

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

command: display contents of a file with multi-directional scroll

A

less

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

command: display the first part of a file

A

head

20
Q

command: display the last part of a file

A

tail

21
Q

command: display the documentation of a command

A

man [command]

22
Q

Where must flags be placed?

A

before other arguments (w/ some exceptions)

23
Q

Can arguments be wrapped in quotes?

A

yes but they dont need to be

24
Q

what are the dangers of misplaced arguments and flags?

A

can change output

25
Q

what pattern does mv use?

A

mv [source] [destination]

26
Q

What flag is used with rm to delete everything contained in a directory?

A

-r (recursive)

27
Q

How do you represent the cwd as a destination?

A

./

28
Q

Represents the root directory

A

/

29
Q

represents the current directory or same level

A

./ or .

30
Q

represents the directory 1 level up

A

../ or ..

31
Q

represents the directory 2 levels up

A

../..

32
Q

represents the home directory

A

~

33
Q

The glob/splat operator

A

*

34
Q

what does the glob operator do

A

represents any number or chars and it used to select all options that fit a certain pattern

35
Q

/abc vs abc/

A

/abc is an absolute path. abc/ is relative

36
Q

cd without arguments

A

takes you to the home directory

37
Q

using glob operator with ls

A

sudo ls /*ot

38
Q

copying a directory to a new place

A

cp -r [directory] ../[new directory] MUST use -r when copying directory

39
Q

copy the contents of a directory to a new directory

A

cp ../[directory]/* ./

40
Q

what are all commands

A

files

41
Q

What are command files called

A

executables

42
Q

What makes executables different than other files?

A
  1. They have special characters at the beginning to tell the computer how to execute them.
  2. They have scripts or machine language as their content.
  3. They have the executable permission
43
Q

How do you exit from an exicutable that is taking too long to run or is in infinite loop?

A

Ctrl + c

44
Q

How do you list hidden files in a directory?

A

ls -a

45
Q

Command: find the path to default exicutables

A

which

46
Q

Suppose you are in a directory with 7 files. You need to move 6 of them into a “tmp” directory, that you have yet to create. How do you do that?

A

mkdir ~/tmp
mv * ~/tmp
mv ~/tmp/1.file ./

47
Q

Suppose you have two directories called xyz/ and abc/. How do you move all the files in abc/ that end with “.txt” into xyz/?

A

mv abc/*.txt xyz/