Useful Linux Commands Flashcards

You must know all of these 100%

1
Q

Show system information

A

uname -a

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

Display memory usage

A

free -h

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

Show disk space usage

A

df -h

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

Show disk usage per directory

A

du -sh [directory]

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

Show running processes

A

ps aux

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

Show real-time system resource usage

A

top

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

Interactive system monitoring tool

A

htop

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

Show system uptime and load average

A

uptime

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

Display last system boot time

A

who -b

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

Show currently logged-in users

A

who

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

Show last login history

A

last

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

Check system logs

A

journalctl -xe

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

Show kernel logs

A

dmesg

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

Display open network connections

A

netstat -tulnp

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

Display listening ports

A

ss -tulnp

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

Display current network interfaces and IP addresses

A

ip a

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

Restart a service

A

systemctl restart [service]

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

Stop a service

A

systemctl stop <service></service>

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

Start a service

A

systemctl start [service]

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

Enable a service to start on boot

A

systemctl enable [service]

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

Disable a service from starting on boot

A

systemctl disable [service]

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

Check service status

A

systemctl status [service]

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

List all active services

A

systemctl list-units –type=service

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

Show disk partitions

A

lsblk

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

Show detailed partition information

A

fdisk -l

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

Mount a filesystem

A

mount [device] [mount_point]

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

Unmount a filesystem

A

umount <mount_point></mount_point>

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

Check disk health (SMART)

A

smartctl -a /dev/sdX

29
Q

Create a new user

A

useradd -m [username]

30
Q

Delete a user

A

userdel -r [username]

31
Q

Change user password

A

passwd [username]

32
Q

Add a user to a group

A

usermod -aG [groupname] [username]

33
Q

Show group memberships for a user

A

groups [username]

34
Q

Show system resource limits

35
Q

Monitor real-time system logs

A

tail -f /var/log/syslog

36
Q

Shut down the system immediately

A

shutdown -h now

37
Q

Reboot the system

38
Q

Securely delete a file

A

shred -u [file_name]

39
Q

List files in a directory

40
Q

Change directory

A

cd [directory]

41
Q

Create a new directory

A

mkdir [directory]

42
Q

Remove an empty directory

A

rmdir <directory></directory>

43
Q

Remove a directory and its contents

A

rm -rf [directory]

44
Q

Copy a file

A

cp [source] [destination]

45
Q

Move or rename a file

A

mv <source></source> <destination></destination>

46
Q

Create a new empty file

A

touch <file_name></file_name>

47
Q

View file contents

A

cat <file_name></file_name>

48
Q

Display file contents with pagination

A

less <file_name></file_name>

49
Q

Show the first 10 lines of a file

A

head <[file_name]

50
Q

Show the last 10 lines of a file

A

tail <file_name></file_name>

51
Q

Find files by name

A

find /path/to/search -name “<file_name>"</file_name>

52
Q

Find files larger than 1GB

A

find / -size +1G

53
Q

Search for a string inside files

A

grep “pattern” [file]

54
Q

Search recursively in directories

A

grep -r “pattern” /path/to/directory

55
Q

Show file type

A

file [file_name]

56
Q

Change file permissions

A

chmod 755 [file_name]

57
Q

Change file ownership

A

chown user:group [file_name]

58
Q

Compress a file with gzip

A

gzip [file_name]

59
Q

Decompress a gzip file

A

gunzip [file_name.gz]

60
Q

Compress a file with bzip2

A

bzip2 [file_name]

61
Q

Decompress a bzip2 file

A

bunzip2 [bzip file]

62
Q

Create a tar archive

A

tar -cvf archive.tar [directory]

63
Q

Extract a tar archive

A

tar -xvf archive.tar

64
Q

Create a compressed tar.gz archive

A

tar -czvf archive.tar.gz [directory]

65
Q

Extract a tar.gz archive

A

tar -xzvf archive.tar.gz

66
Q

Create a compressed tar.bz2 archive

A

tar -cjvf archive.tar.bz2 [directory]

67
Q

Extract a tar.bz2 archive

A

tar -xjvf archive.tar.bz2

68
Q

How to use scp?

A

scp [user]@[remote ip]:/path/to/file

69
Q

How to add something to $PATH?

A

export PATH=”[new path to add]:$PATH”