Useful Linux Commands (Linux Forensics Analyst, DevOps Engineer, System Administrator) Flashcards

1
Q

What command repeatedly outputs a string until interrupted?

A

yes

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

What is the purpose of the ‘yes’ command?

A

To automatically provide a repeated response, commonly ‘y’, to prompts.

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

Which command displays text in an ASCII speech bubble spoken by a cow?

A

cowsay

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

What command can be used to print text as if spoken by an ASCII cow?

A

cowsay

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

What command reverses the characters of a string?

A

rev

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

How can you reverse the characters in ‘linux’ using a Linux command?

A

echo ‘linux’ | rev

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

What happens when you run ‘sl’ instead of ‘ls’ by mistake?

A

It shows an animation of a steam locomotive.

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

Which command shows a steam locomotive animation if typed incorrectly?

A

sl

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

Which command builds and executes command lines from input?

A

xargs

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

How do you remove all .txt files using ‘find’ and ‘xargs’?

A

find . -name ‘*.txt’ | xargs rm

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

What cryptic-looking command can crash a system by creating infinite processes?

A

Fork bomb: :(){ :|:& };:

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

What is the purpose of the ‘factor’ command?

A

To output the prime factors of a given number.

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

What command displays the prime factors of a number?

A

factor

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

Which command executes another command repeatedly at specified intervals?

A

watch

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

How do you display disk usage (df) every 2 seconds using ‘watch’?

A

watch -n 2 df -h

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

Which command displays a file in reverse line order?

A

tac

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

How do you reverse the line order of a file using a Linux command?

A

tac filename.txt

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

Which command shuffles the lines of input randomly?

A

shuf

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

What command is used to shuffle the lines in a text file randomly?

A

shuf mylist.txt

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

What does the ‘pv’ command do?

A

Monitors the progress of data through a pipe.

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

Which command allows you to monitor the progress of a file being copied?

A

pv

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

What does the ‘dd’ command do?

A

Converts and copies files in raw byte form.

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

How do you copy disk images using ‘dd’?

A

dd if=/dev/sda of=/dev/sdb bs=64K

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

What is the function of the ‘mkfifo’ command?

A

Creates a named pipe (FIFO).

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

What command creates a named pipe in Linux?

A

mkfifo

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

Which command adds line numbers to text?

A

nl

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

How do you add line numbers to a text file?

A

nl file.txt

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

What command displays how long the system has been running?

A

uptime

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

What is the purpose of the ‘uptime’ command?

A

To display how long the system has been running and load averages.

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

Which command displays random quotes or proverbs?

A

fortune

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

What does the ‘fortune’ command do?

A

Displays random quotes, jokes, or proverbs.

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

Which command pauses execution for a set amount of time?

A

sleep

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

How do you pause a script for 5 seconds in Linux?

A

sleep 5

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

Which command outputs the contents of a gzip-compressed file without decompressing it?

A

zcat

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

What command allows you to view compressed files without decompressing them?

A

zcat

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

Which command translates or deletes characters in text?

A

tr

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

How do you replace spaces with newlines using a Linux command?

A

echo ‘hello world’ | tr ‘ ‘ ‘\n’

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

What is the purpose of the ‘tput’ command?

A

To manipulate terminal settings, such as colors or cursor movement.

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

Which command changes text color to red in a terminal?

A

tput setaf 1

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

Which command displays detailed information about a file, including metadata such as last access and modification times?

A

stat

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

How can you view the detailed metadata of a file in Linux?

A

stat filename

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

Which command is used to show the running processes in Linux?

A

ps

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

How do you view a list of all running processes in Linux?

A

ps aux

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

Which command can show open network connections, listening ports, and other network-related information?

A

netstat

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

What command lists all open network connections and listening ports on a Linux system?

A

netstat -tulnp

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

Which command shows active network connections and related stats, replacing ‘netstat’ in modern systems?

A

ss

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

How do you view active TCP connections using the ‘ss’ command?

A

ss -t

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

Which command lists all open files and the processes that opened them?

A

lsof

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

How do you check which files are open by which processes in Linux?

A

lsof

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

What command can be used to monitor changes to files and directories in real-time?

A

inotifywait

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

How do you monitor changes in a directory in real-time in Linux?

A

inotifywait -m /path/to/directory

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

Which command is used to create a cryptographic hash (checksum) of a file for integrity verification?

A

sha256sum

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

How do you generate the SHA-256 hash of a file in Linux?

A

sha256sum filename

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

Which command captures all traffic on a network interface and displays it for analysis?

A

tcpdump

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

How do you capture network traffic on interface eth0 and write it to a file using tcpdump?

A

tcpdump -i eth0 -w capture.pcap

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

Which command is used to analyze packet captures (PCAP files) from tools like tcpdump?

A

wireshark

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

How can you visually analyze a pcap file in Linux?

A

wireshark filename.pcap

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

What command is used to securely erase files by overwriting them multiple times?

A

shred

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

How do you securely delete a file in Linux using ‘shred’?

A

shred -u filename

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

Which command provides a forensic timeline of file access, modification, and creation times?

A

sleuthkit ‘fls’

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

How do you create a forensic timeline from an image file using ‘fls’?

A

fls -r imagefile.img

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

Which command allows forensic investigators to extract data from memory dumps?

A

volatility

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

How can you analyze a memory dump for processes using Volatility?

A

volatility -f memory.dmp –profile=Win7SP1x64 pslist

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

Which command provides detailed information about the usage of disk space by files and directories?

A

du

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

How do you check the disk usage of a specific directory?

A

du -sh /path/to/directory

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

What tool allows the recovery of deleted files from an ext3 or ext4 file system?

A

extundelete

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

How do you recover deleted files from a partition using extundelete?

A

extundelete /dev/sda1 –restore-all

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

Which command displays information about USB devices connected to the system?

A

lsusb

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

How do you view a list of USB devices connected to the system?

A

lsusb

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

What command lists all the block devices connected to the system?

A

lsblk

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

How do you list all block devices (like hard drives) in Linux?

A

lsblk

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

Which command provides a hexadecimal and ASCII dump of a file’s content, often used in forensics for low-level data inspection?

A

hexdump

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

How do you display the hexadecimal contents of a file in Linux?

A

hexdump filename

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

Which command is used to create a binary image of an entire drive for forensic analysis?

A

dd

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

How do you create a raw disk image of a drive using ‘dd’?

A

dd if=/dev/sda of=/path/to/output.img bs=64K

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

Which command is used to examine the attributes of ext2, ext3, and ext4 file systems?

A

debugfs

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

How do you open an ext4 filesystem for analysis using ‘debugfs’?

A

debugfs /dev/sda1

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

What command is used to list hidden file attributes on ext file systems, such as immutable or append-only flags?

A

lsattr

79
Q

How do you view the extended file attributes on a file in Linux?

A

lsattr filename

80
Q

What command allows a forensic investigator to examine or mount disk images locally?

A

mount -o loop

81
Q

How do you mount a disk image for analysis using the ‘mount’ command?

A

mount -o loop /path/to/image.img /mnt/analysis

82
Q

Which command is used to monitor real-time system resource usage, including CPU and memory?

A

top

83
Q

How do you monitor CPU, memory, and process usage in real-time in Linux?

A

top

84
Q

Which command shows the current resource usage in a more visually appealing way compared to ‘top’?

A

htop

85
Q

How can you interactively view system resources and processes using a visual interface?

A

htop

86
Q

Which command is used to display or manipulate the routing table in Linux?

A

route

87
Q

How do you view the current routing table in Linux?

A

route -n

88
Q

Which command can check the availability and response time of a network host?

A

ping

89
Q

How do you check if a server is reachable via network in Linux?

A

ping hostname_or_ip

90
Q

Which command is used to trace the path packets take to reach a network host?

A

traceroute

91
Q

How do you trace the route that packets take to a destination?

A

traceroute hostname_or_ip

92
Q

Which command can be used to check the status of a service in systemd-based systems?

A

systemctl status

93
Q

How do you check the status of a service like nginx using ‘systemctl’?

A

systemctl status nginx

94
Q

Which command is used to start a service in systemd-based Linux systems?

A

systemctl start

95
Q

How do you start the Apache (httpd) service in Linux?

A

systemctl start httpd

96
Q

Which command is used to stop a service in systemd-based Linux systems?

A

systemctl stop

97
Q

How do you stop the MySQL service in Linux?

A

systemctl stop mysql

98
Q

Which command is used to restart a service in Linux?

A

systemctl restart

99
Q

How do you restart the nginx service in Linux?

A

systemctl restart nginx

100
Q

Which command is used to enable a service to start on boot in Linux?

A

systemctl enable

101
Q

How do you enable the Apache service to start on boot?

A

systemctl enable httpd

102
Q

Which command is used to check system logs managed by systemd?

A

journalctl

103
Q

How do you view system logs from the last boot using ‘journalctl’?

A

journalctl -b

104
Q

Which command lists all the open ports and the services listening on them?

A

netstat -tulnp

105
Q

How do you list all open TCP and UDP ports and their associated services?

A

netstat -tulnp

106
Q

Which command can be used to manage Docker containers, images, and volumes?

A

docker

107
Q

How do you list all running Docker containers?

A

docker ps

108
Q

Which command is used to build a Docker image from a Dockerfile?

A

docker build

109
Q

How do you build a Docker image from a Dockerfile?

A

docker build -t imagename .

110
Q

Which command is used to start a Docker container from an image?

A

docker run

111
Q

How do you run a container from a Docker image in Linux?

A

docker run imagename

112
Q

Which command is used to manage Kubernetes clusters and resources?

A

kubectl

113
Q

How do you list all pods in a Kubernetes cluster?

A

kubectl get pods

114
Q

Which command is used to update Kubernetes deployments or configurations?

A

kubectl apply

115
Q

How do you apply a configuration file to update a Kubernetes deployment?

A

kubectl apply -f deployment.yaml

116
Q

Which command is used to view the current disk space usage on Linux?

A

df -h

117
Q

How do you check available disk space in a human-readable format?

A

df -h

118
Q

Which command can recursively show disk usage for directories and files?

A

du

119
Q

How do you check the disk usage of a specific directory?

A

du -sh /path/to/directory

120
Q

Which command is used to monitor network interface statistics in real-time?

A

ifstat

121
Q

How do you monitor network interface usage in real-time in Linux?

A

ifstat

122
Q

Which command is used to display network interface configuration details?

A

ifconfig

123
Q

How do you view the IP address of network interfaces on Linux?

A

ifconfig

124
Q

Which command displays system hardware information, such as CPU, memory, and disk details?

A

lshw

125
Q

How do you display detailed hardware information about your system?

A

lshw

126
Q

Which command is used to view memory usage and swap information in Linux?

A

free -h

127
Q

How do you check the memory usage on your system in human-readable format?

A

free -h

128
Q

Which command allows a DevOps engineer to synchronize or backup files between two locations?

A

rsync

129
Q

How do you synchronize files from a local directory to a remote server?

A

rsync -av /local/dir user@remote:/remote/dir

130
Q

Which command can be used to automate tasks based on time or intervals?

A

cron

131
Q

How do you edit the cron jobs for the current user?

A

crontab -e

132
Q

Which command is used to list all cron jobs for the current user?

A

crontab -l

133
Q

Which command can show the status of SELinux on a system?

A

getenforce

134
Q

How do you check whether SELinux is enforcing, permissive, or disabled?

A

getenforce

135
Q

Which command is used to display detailed information about the system, including hostname, kernel version, and more?

A

uname -a

136
Q

How do you view the kernel version and system information in Linux?

A

uname -a

137
Q

Which command can be used to change the hostname of the system?

A

hostnamectl

138
Q

How do you change the hostname of a Linux system?

A

hostnamectl set-hostname new-hostname

139
Q

Which command is used to view the current IP addresses assigned to network interfaces?

A

ip addr show

140
Q

How do you display the IP addresses of all network interfaces in Linux?

A

ip addr show

141
Q

Which command allows you to change the IP address of a network interface?

A

ip addr add

142
Q

How do you assign a new IP address to the eth0 interface?

A

ip addr add 192.168.1.10/24 dev eth0

143
Q

Which command displays the status of all active and inactive network interfaces?

A

ifconfig

144
Q

How do you bring a network interface up or down using ‘ifconfig’?

A

ifconfig eth0 up/down

145
Q

Which command shows a list of all logged-in users?

A

w

146
Q

How do you view a list of users currently logged into the system?

A

w

147
Q

Which command is used to reboot a Linux system immediately?

A

reboot

148
Q

How do you reboot the system from the command line?

A

reboot

149
Q

Which command is used to shut down a Linux system?

A

shutdown

150
Q

How do you shut down a system after a delay of 10 minutes?

A

shutdown +10

151
Q

Which command is used to manage user accounts, including creating or deleting users?

A

useradd / userdel

152
Q

How do you create a new user account in Linux?

A

useradd username

153
Q

Which command is used to change a user’s password?

A

passwd

154
Q

How do you change or set the password for a user in Linux?

A

passwd username

155
Q

Which command is used to modify user account details, such as group membership or shell access?

A

usermod

156
Q

How do you add a user to a group using ‘usermod’?

A

usermod -aG groupname username

157
Q

Which command displays the disk usage of a directory or filesystem in human-readable format?

A

df -h

158
Q

How do you check disk space usage on all mounted filesystems?

A

df -h

159
Q

Which command can be used to view file and directory permissions?

A

ls -l

160
Q

How do you list files with detailed permissions in Linux?

A

ls -l

161
Q

Which command changes file ownership in Linux?

A

chown

162
Q

How do you change the owner of a file to a specific user and group?

A

chown user:group filename

163
Q

Which command is used to change file permissions in Linux?

A

chmod

164
Q

How do you set the permission for a file to be executable by the owner?

A

chmod u+x filename

165
Q

Which command shows the last login times of users?

A

last

166
Q

How do you view the login history of users on the system?

A

last

167
Q

Which command is used to view system resource usage, such as CPU, memory, and disk I/O?

A

vmstat

168
Q

How do you monitor system performance metrics using ‘vmstat’?

A

vmstat

169
Q

Which command displays system messages and logs?

A

dmesg

170
Q

How do you view system boot logs or kernel messages?

A

dmesg

171
Q

Which command is used to monitor real-time log entries from system logs?

A

tail -f

172
Q

How do you monitor real-time updates to a log file?

A

tail -f /var/log/syslog

173
Q

Which command can be used to schedule future tasks in Linux?

A

at

174
Q

How do you schedule a command to run at 2 PM using ‘at’?

A

echo ‘command’ | at 14:00

175
Q

Which command is used to list or remove scheduled ‘at’ jobs?

A

atq / atrm

176
Q

How do you view the list of scheduled ‘at’ jobs?

A

atq

177
Q

Which command is used to monitor system load, including load averages and CPU usage?

A

uptime

178
Q

How do you check system uptime and current load averages?

A

uptime

179
Q

Which command allows you to synchronize file changes to disk manually?

A

sync

180
Q

How do you manually flush file system buffers to disk?

A

sync

181
Q

Which command shows the current system time and allows time configuration?

A

timedatectl

182
Q

How do you view or set the system time in Linux?

A

timedatectl

183
Q

Which command can check for bad blocks on a storage device?

A

badblocks

184
Q

How do you check a disk for bad blocks in Linux?

A

badblocks /dev/sda

185
Q

Which command allows you to mount a filesystem to a specific directory?

A

mount

186
Q

How do you mount a partition to the /mnt directory?

A

mount /dev/sda1 /mnt

187
Q

Which command unmounts a mounted filesystem?

A

umount

188
Q

How do you unmount a filesystem from /mnt?

A

umount /mnt

189
Q

Which command is used to view or configure firewall settings in Linux (using UFW)?

A

ufw

190
Q

How do you allow traffic on port 80 using UFW?

A

ufw allow 80

191
Q

Which command lists the active firewall rules in UFW?

A

ufw status

192
Q

Which command allows you to check the status of SELinux?

A

sestatus

193
Q

How do you view the current status of SELinux on a system?

A

sestatus