Linux Flashcards

(40 cards)

1
Q

Find current kernel version ?

A

(sudo) uname -a for full, -r for just version

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

Find list of kernels available

A

(sudo) ls /boot

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

Install packages on the box

A

(sudo) apt install

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

Remove a file forever

A

shred <filename></filename>

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

Find your own username

A

whoami

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

Add a new user

A

(sudo) useradd john . Note: he has no password, so use passwd to set the password before login.

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

Add a new user who will not have login access

A

(sudo) useradd -s /sbin/nologin john OR
(sudo) useradd -s /bin/false

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

Open a shell as different user

A

su john

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

Get a list of all users authorized to this box

A

ls /etc/passwd

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

Change a password

A

passwd

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

Find information about a user

A

finger john

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

Find what an executable is and the path where it is located

A

whatis , whereis

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

Do an HTTP GET

A

wget https://… or curl 172.45.23.2

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

Compare see difference between files

A

cmp , diff

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

Make a file executable

A

chmod

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

Make someone owner of a file

A

chown

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

Find the IP address of current box

A

ip addr , ifconfig

18
Q

Search using a regex expression

19
Q

Get the DNS configuration for the server

A

resolvectl status , cat /etc/resolv.conf

20
Q

Determine reachability and network routing

A

ping -n 172.3.4.5 , traceroute

21
Q

Find the open ports, ports being used by specific protocols

A

netstat -tulpn , ss

22
Q

(Dis) Allow traffic on specific ports

A

iptables, ufw status/allow/enable/disable..

23
Q

Find available memory

24
Q

Find available disk space

25
Pull a list of processes running on the system
(sudo) ps -aux
26
Find processes consuming most resources
top, htop
27
Terminate a process
kill -9 , first find pid using ps -aux | grep name
28
List services running on box
systemctl list-units
29
Start / Stop / Restart services
systemctl start / stop / restart
30
Find the recursively total space under a folder
du -sh /etc/abc
31
See current mounts on startup
ls /etc/fstab
32
See all current mounts
mount
33
What does ip 0.0.0.0 denote
All public addresses
34
A service keeps restarting, how to debug
journalctl -f -u servicename (then systemctl restart)
35
How do you check and ensure the linux server is synchronizing its clock (time) correctly
ntpq -p reports on the NTP servers it is synching with Install and configure ntpd or chrony to fix Also make sure timezone is set right with timezonectl
36
How do you implement disk quotas by user
Enable them in /etc/fstab edquota to edit them quotaon to switch them on
37
A service needs to start on booting up. How to configure ?
systemctl enable svcname
38
How would you clean files from a temp folder periodically
#/bin/bash \n rm -rf /tmp/* chmod +x script crontab -e 0 0 * * * /path/to/script
39
Kill all processes by a certain user
ps -u ubuntu | grep -v PID | awk '{print $1}' | xargs kill -9
40
How do you generate a core file file (dump) of a running process in linux
gcore [-o filename] pid