Commands Flashcards

1
Q

Head -n 5 filename.txt
Tail -n 5 filename.txt

A

Head
Tail

-n (number)
The first 5 lines
and the last 5 lines

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

Head -n +3 filename.txt
Tail -n +3 filename.txt

A

Head
Tail

-n (number)

Go to the third line and show us everything above that

Go to the third line and show us everything above that

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

Sort filename.txt
Sort -r filename.txt

A

Sorts by alphabetical order
Sort reverse

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

Cut -c 1-3 filename.txt
Cut -d, -f 2 filename.txt

A

Cut (By character) first three
Cut (delimiter) (field) by comma field 2

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

Grep red filename.txt
Grep -i red filename.txt

A

Grep red in file
Grep same thing case insensitive

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

Grep -E el?o filename.txt

A

Grep (extended regex) el?o
(Means zero or one times)

Extended regex only for the ? Not for
[ ], ., or *

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

Wc -c -m -l filename.txt

A

Word count (bytes) (characters) (lines)

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

Ln originalfile.txt linkfile.txt
Ln - s originalfile.txt linkfile.txt

A

Hard link two files
Symbolic link two files

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

ID

A

Uid=1000(zahir) gid=1000(zahir) groups=1000(zahir),4(adm),24(cdrom),27(sudo) etc

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

Last

A

Shows the last users that logged in

Zahir :1 :1 Mon Mar 4 17:29

Has a still logged in column,
9 columns deep

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

Who

A

Shows who’s logged in

Zahir :1 2024-03-04 17:29 (:1)

5 columns deep

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

W

A

Shows what they are doing

20:41:08 up 3:12, 1 user, Load average

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

Free -h

A

Shows how much memory is available
-h human readable

Total used free shared (header)

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

Ps aux

A

Process status (in terminal)
Aux shows all processes

Ps has a small header, top has a giant header

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

Top

A

Current running processes live

Top has a huge header

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

Useradd -m -d -g -G username

A

Create user
-make home dir
-d specify home dir
-g group
-G supplementary groups

17
Q

Userdel -f -r

A

Delete user
-f force
-r remove home dir + mail

18
Q

Chmod ugo+rwx or -rwx filename.txt
Also +t

A

Change file permissions
Add sticky bit

19
Q

Chown owner.group filename.txt

A

Change file owner and group

20
Q

Env

A

Shows environmental variables
Including PATH

21
Q

Ls -R

A

List recursive

22
Q

Passwd or passwd username

A

Reset password

23
Q

rm -r

A

Remove recursive

24
Q

mv filename destination

A

Move a file

25
Q

cp -R

A

Copy recursive (entire tree)

26
Q

Which

A

Where does a command live?

27
Q

History -c

A

Every command typed and how to clear

28
Q

Du -h —summarize

A

Disk usage human readable, summarize

29
Q

Tar -z -j -J

A

Tar flags

30
Q

Ls -d

A

List directories not their contents

31
Q

Locate filename.txt

A

Locate a file