Terminal 101 Flashcards

learn basic terminal commands

1
Q

man [command]

A

displays manual of specific commands

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

[command] –h

A

displays a short description of the command

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

pwd

A

prints working directory

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

cd

A

Changes directory.
[cd - ] to navigate back to the previous working directory
[cd, cd ~] to navigate to the home directory
[cd / ] to navigate to the root directory
[cd .. ] to navigate back of one directory

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

ls

A

Lists contents of current w.d
[-l] lists contents in a table format
[-t] lists contents based on the timestamp

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

*

A

Allows to select file or directory names based on patterns
[] all files
[b
] all files starting with b
[b.txt] all files starting with b and ending with .txt
[[abc]
] all files starting with a b or c

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

?

A

Allows for one char to have any value

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

cp

A

copies files or directories
[cp file1 file2]creates file2 and copies contents of file1 into it
[cp file1 file2 dir1] copies file1/2 into dir1
[cp dir1/* dir2] copies all files from dir1 to dir 2
[cp -r dir1/* dir2] copies all files and directories of dir1 into dir2

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

mv

A

Moves files and directories
[mv file1 file2]
- renames file1 to file2
- moves file1 to file2 (which is overwritten if already existing)
[mv file1 file2 dir1] moves file1/2 into dir1 (must already exist)
[mv dir1 dir2] moves all files from dir1 to dir 2 (dir1 is erased)

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

rm

A

Removes files or directories
[rm file1]
[rm -r dir1]

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

mkdir [directory_name]

A

creates directory in current w.d

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

touch [file_name]

A

Updates timestamp of the file
[touch -a file1] updates last access timestamp
[touch -m file1] updates last modified timestamp

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

-i & -n

A

[-i] adds a prompt to confirm the action before modifying a file
[-n] defines that no files can be overwritten

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

cat

A

Concatenates files
[cat file1] shows the contents of file1
[cat > file1] will create file1 + add contents through terminal prompt
[cat -n file1] prints file contents with line numbers
[cat file1 > file2] creates or overwrites file2 with contents of file1
[cat file1&raquo_space; file2] appends contents of file1 to file2
[cat file1 file2 | sort > file4] sorts contents of file1 and file2 and appends to file4

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

uniq

A

removes duplicate files or contents

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

grep [“pattern”] file1

A

Prints lines containing “pattern” in file1
[-i] ignores case
[-r] recursive search (into sub dir)
[-c] outputs number of times pattern was found in file1

17
Q

echo

A

[echo “text”] outputs text
[echo $VAR] outputs value of var
[echo *] outputs all files or directories in w.d
[echo “text” > file1] writes or overwrites text into file1
[echo “text”&raquo_space; file1] appends text into file1