The Terminal Flashcards

1
Q

Lists files in current directory… or a directory specified

A

ls
ls FOLDER_NAME

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

Change Directory (literally)
You start out in your “~” (home) directory and use this to move to a different one

A

cd FOLDER_NAME

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

Make Directory (literally)
Create a directory folder

A

mkdir FOLDER_NAME

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

Remove (literally)/Delete
Delete/Remove a file or a directory.

If you try it on a file, you must add this as a parameter.

WARNING: Action is permanent

A

rm FOLDER_NAME
rm -r FOLDER_NAME

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

Move (literally)/Rename

Move a file or a directory.

It also serves as the way to rename a file to another name.

A

mv OLD_NAME
NEW_NAME

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

Manual (literally)

Type this along with another command and (usually) a page will appear telling you how to use that command.

It is, as the name implies, a manual page that is a quick resource for help.

Press “q” to quit when open.

A

man COMMAND_NAME

Examples:

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

Difference (literally)

Will tell you the difference between two files.

If there is no difference, nothing is printed out.

A

diff FILE1 FILE2

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

Nano (literally) Text Editor

Dr. Marz’s preferred Terminal Text Editor.

Commands are shown at the bottom of the screen (e.g. Ctrl+X = Exit)

A

nano FILE

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

Vim (literally) Text Editor
Writer’s preferred “(and clearly superior)” text editor

A

vi FILE
vim FILE

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

Gedit (literally) Text Editor

This one actually isn’t a terminal application. It will execute a graphical text editor kind of like TextEdit on Mac and Notepad on Windows.

You cannot use your terminal while Gedit is open.

A

gedit FILE

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

A C++ Compiler

You will be using this for pretty much your entire time here.

It will make an executable from your C++ source code files.

A

g++ -o EXECUTABLE SOURCE

Examples:

  • g++ -o test test.cpp
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Secure Shell

Allows you to remotely connect to other machines.

i.e., connect to UTK’s Hydra machines from your personal computer.

A

ssh USERNAME@ADDRESS

Examples:

  • ssh cnguyen@hydra0.eecs.utk.edu
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Description:

Writes a file to the disk.

A

Command:

:w

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

Description:

Quits Vim. If you made changes to a file, you must put “!” after in order to quit without saving changes. Otherwise it’ll refuse to quit.

A

Command:

:q
:q!

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

Description:

Writes to disk, and then Quits Vim.

A

Command:

:wq

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

Description:

Triggers Insert Mode

A

Command:

i

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

Description:

Triggers Visual Mode

A

Command:

v

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

Description:

Triggers Visual Block Mode

A

Command:

V

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

Description:

Yank: grabs a line and puts it in clipboard (For Copy and Paste).

A

Command:

yy

20
Q

Description:

Yank. Grabs 2 lines and puts them in clipboard (For Copy and Paste).

A

Command:

y2y

21
Q

This is the mode you start out in. You may use the arrow buttons (or Vi’s HJKL setup) to navigate around.

You may also press the colon button
“ : “ (Shift + ;) on USA keyboards in order to input a command (more on that below). Press “ i “ to enter Insert Mode, etc.)

A

Normal Mode

22
Q

Pressing “ i “ while in Normal Mode triggers this mode. This is where Vim acts like a text editor that you’re used to.

Type stuff on your keyboard and it types.

Press esc (Escape key) to exit Insert Mode and go back to Normal Mode.

A

Insert Mode

23
Q

Pressing “ v “ while in Normal Mode triggers this mode.

Pressing “ V “ will trigger this mode.

(Both to be covered in a more advanced guide)

A

Visual (and Visual Block Mode)

24
Q

In Normal Mode (of Vim), this is one of the commands which you can execute by typing in the “ : “ character.

This command writes a file to the disk.

A

:w

25
Q

In Normal Mode, this is one of the commands which you can execute by typing in the “ : “ character.

This command Quits Vim.

Also, note: “If you made changes to a file, you must put “ ! “ after in order to quit without saving changes. Otherwise, it’ll refuse to quit.”

A

:q
:q!

26
Q

In Normal Mode, this is one of the commands which you can execute by typing in the “ : “ character.

This command writes to disk, and then Quits Vim.

A

:wq

27
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode that does not require it.

Description:

Triggers Insert Mode

A

i

28
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode that does not require it.

Description:

Triggers Visual Mode

A

v

29
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode that does not require it.

Description:

Triggers Visual Block Mode

A

V

30
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Yank. Grabs a line and puts it in clipboard (For Copy and Paste)

A

yy

31
Q

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Yank. Grabs 2 lines and puts them in clipboard (For Copy and Paste)

A

y2y

32
Q

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Cut. Grabs a line and puts it in clipboard (For Cut and Paste). It will also delete that line.

A

cc

33
Q

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Cut. Grabs 2 lines and puts them in clipboard (For Cut and Paste). It will also delete that line.

A

c2c

34
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Delete. Deletes the current line.

A

dd

35
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Delete. Deletes 2 lines starting from the current one.

A

d2d

36
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Paste. Pastes whatever was inside the clipboard from the above commands.

A

p

37
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Undo. Undoes the last action performed.

A

u

38
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Redo. Redoes the last action performed if undone.

A

C-R (Ctrl+R)

39
Q

Note: this command does not use “ : “.

It is a command bound to buttons in Normal Mode (of Vim) that does not require it.

Description:

Any changes done in Insert Mode are done again.

A

.

40
Q

Not necessary to remember

A form of string replacement via regular expression commands.

What does the following command do?

:s/old/new

A

Description:

Substitution. Replaces one case of “old” with “new”

41
Q

Not necessary to remember

A form of string replacement via regular expression commands.

What does the following command do?

:%s/old/new

A

Description:

Substitution. Replaces one case of “old” with “new”… for each line (%).

42
Q

Not necessary to remember

A form of string replacement via regular expression commands.

What does the following command do?

:s/old/new/g

A

Description:

Substitution. Replaces ALL (g) cases of “old” with “new” in a line.

43
Q

Not necessary to remember

A form of string replacement via regular expression commands.

What does the following command do?

:%s/old/new/g

A

Description:

Substitution: Replaces ALL (g) cases of “old” with “new” in a line… for ALL lines (%).

44
Q

Note: this command does not use “ : “.

This is a Unix command that allows one to copy files to and from remote places easily.

A

Command:

scp FROM_PATH TO_PATH

45
Q

Shorthand (the character) for:

The home directory

/home/USERNAME

A

~ (tilde)

46
Q

Directory abbreviation for:

Another user’s home directory

A

~username

47
Q

Directory abbreviation for:

Current working directory

A

.