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.

25
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.”
:q :q!
26
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.
:wq
27
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
i
28
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
v
29
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
V
30
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)
yy
31
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)
y2y
32
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.
cc
33
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.
c2c
34
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.
dd
35
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.
d2d
36
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.
p
37
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.
u
38
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.
C-R (Ctrl+R)
39
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.
.
40
*Not necessary to remember* A form of string replacement via regular expression commands. What does the following command do? :s/old/new
Description: Substitution. Replaces one case of “old” with “new”
41
*Not necessary to remember* A form of string replacement via regular expression commands. What does the following command do? :%s/old/new
Description: Substitution. Replaces one case of “old” with “new”… for each line (%).
42
*Not necessary to remember* A form of string replacement via regular expression commands. What does the following command do? :s/old/new/g
Description: Substitution. Replaces ALL (g) cases of “old” with “new” in a line.
43
*Not necessary to remember* A form of string replacement via regular expression commands. What does the following command do? :%s/old/new/g
Description: Substitution: Replaces ALL (g) cases of “old” with “new” in a line… for ALL lines (%).
44
Note: this command does not use “ : “. This is a Unix command that allows one to copy files to and from remote places easily.
Command: scp FROM_PATH TO_PATH
45
Shorthand (the character) for: The home directory /home/USERNAME
~ (tilde)
46
Directory abbreviation for: Another user’s home directory
~username
47
Directory abbreviation for: Current working directory
.