Linux Flashcards

1
Q

How to check the kernel version of a Linux system?

A

Uname -a

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

How to see the current IP address on Linux?

A

Ip a

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

How to check for free disk space in Linux?

A

df -ah

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

How to see if a Linux service is running?

A

Service –status-all

Service

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

How to check the size of a directory in Linux?

A

Du -sh foldername

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

How to check for open ports in Linux?

A

Netstat -tulpn

ON REMOTE HOST
telnet 8.8.8.8 53
nc -w5 -z -v (AKA NETCAT)

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

How to check Linux process information (CPU usage, memory, user information, etc.)?

A

Ps aux
Top
htop

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

How to deal with mounts in Linux

A

mount

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

what does LSOF return

A
the list of open files
COMMAND
PID
TID
TASKCMD
USER
FD (file descriptor)
TYPE
DEVICE
SIZE
NODE
NAME
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Difference b/t CTRL-C and CTRL-Z in linux

A

CTRL - C sends SIGINT which interrupts the application, usually cause process abort and give you a blank prompt

CTRL - Z send SIGSTP which sends the application to suspend mode on the backend to be continued later with fg

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

Difference between Tar and ZIP

A

tar is only an archiver while zip archives and compresses.

tar preserves setuid, setgid, and sticky bit

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

SETUID

A

Setuid is a Linux file permission setting that allows a USER to execute that file or program with the permission of the owner of that file. This is primarily used to elevate the privileges of the current user.

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

SETGUID

A

Setuid is a Linux file permission setting that allows a USER to execute that file or program with the permission of the owner of that file. This is primarily used to elevate the privileges of the current user.

Same as SETUID except with GROUPS

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

STICKY BIT

A

Prevents everyone except the OWNER of a directory from deleting a file…like on tmp folders.

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

How to check open ports on a remote server without NET CAT or NMAP

A

echo > /dev/tcp// && echo “GOOD” || “BAD”

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

5 ways to secure an SSH connection.

A

Disable Password Based Logins and Allow Key based logins
Disable root login
Change the standard port number
Force the service to use only SSH v2
White List users or servers “Allowed List” is the new PC term.

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

LVM

A

Logical Volume Manager
LV-extend / LV-reduce to extend or reduce partition sizes
create/resize/delete LVM partitions while the server is running.

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

How would you connect to a machine in the cloud

A

Is there a VPN…connect to it.

SSH @

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

CD

A

change directory

CD /

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

LS

A

list directory contents.

ls [flags] [directory]

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

PWD

A

print working directory (path of current directory or the one you choose)

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

echo

A

Displays a line of txt

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

grep

A

print lines to match patterns
If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard
input.

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

cp

A

Copy file

cp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
systemctl
Control the systemd system and service manager
26
How to list services with systemctl
systemctl list-units type=service
27
how to get status of a service
systemctl status
28
how do you enable a service to start at boot time
systemctl enable
29
start or stop a service
systemctl start/stop
30
What is init system.
``` o Init is the first process o Starts all services and units o Reparening orphaned processes o Systemctl enable/start services o Journalctl -fu nginx (logs) ```
31
How do you show ip address of eth0
• Ip addr show dev eth0
32
how to you display route information
ip route show
33
Know the basics of System D
``` Contains Init which boots the rest of the system Collection of programs and libraries systemctl and journalctl init process management network management login management logs etc ```
34
What is a linux user made of?
Bascially a bunch of lines in a bunch of different files Passwd gives username UID password or reference to the hashed password file remove user from all groups before deleting
35
What do you know about PROC?
Proc file system (procfs) is virtual file system created on fly when system boots and is dissolved at time of system shut down. It contains useful information about the processes that are currently running, it is regarded as control and information center for kernel.
36
How can you check resource utilization
top, htop, or atop
37
How do you look for application binary?
whereis will show you where the app and man pages live
38
report a snapshot of the current processes.
ps
39
How to get open files by process id
LSOF -p
40
how to view open ports on a machine
netstat -tulpn
41
What can prevent you from writing a file?
Ownership in a folder Permissions I-node exhaustion...you can run df -i
42
What are I-nodes
``` Linux datastructure that contains info on files When are they created. File type Permissions Owner ID Group ID Size of file Time last accessed Time last modified Soft/Hard Links Access Control List (ACLs) ```
43
What commands can you use to find i node info on a file
stat (various arguments) %i displays inode number | ls -lhi | grep
44
How to check inode usage on a system
df -ih
45
What happens to the inode when you copy vs move a file
copy creates new inode | move same inode, new info
46
How do you identify where an application is installed
use the WHICH or WHEREIS
47
What is cron
daemon to execute scheduled commands
48
How to find config files for applications
Use Find in the /etc folder
49
You want to check the logs for an apache / nginx server, but you cant find them in /var/log/, where would you look
find out where the application is installed and check the .conf file
50
How would you access a web service running in server B only accessible from server A, to which you have access, but from your local machine
ssh tunnel using port forwarding -L or proxy socks -D ssh -L 8080:192.168.1.1:3389 user@192.168.1.1
51
• Difference between a process and a thread?
Process is an instance of a computer program that is being executed, while a thread is a component of a process which is the smallest execution unit. Processes have their own memory space, which the thread, in turn, use. In a multi-processing environment, each process executes independently. But a thread can read, write or modify data of another thread.
52
What command used to find processes as well as cpu and memory usage?
top, htop
53
What is the difference between a L4 and L7 load balancer?
Layer 4 load balancing takes place at the transport layer of the OSI model, which is in charge of delivering messages regardless of their content. Layer 4 load balancers simply route network packets to and from the upstream server without inspecting them. By reviewing the initial few packets in the transmission control protocol (TCP) stream, they can only make limited routing decisions. It is still the heart of the OSI. QUICK, EFFICIENT, SECURE.....NO SMARTBALANCING, NO MICROSERVICES Layer 7 load balancing works at the application layer of the OSI model, which is in charge of the message’s actual content. Application Load Balancers route network traffic in a more complex way, typically for TCP-based traffic such as HTTP or HTTPS. A Layer 7 load balancer, unlike a Layer 4 load balancer, disconnects network traffic and processes the message inside. BASED ON URL, SMART ROUTING, CACHING...EXPENSIVE, NEEDS DECRYPTION
54
whats the difference between df and free
df is to check free disk space | free is to check free memory
55
how does kill work?
The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Al‐ ternate signals may be specified in three ways: -9, -SIGKILL or -KILL. Negative PID values may be used to choose whole process groups; see the PGID column in ps command output. A PID of -1 is special; it indicates all processes except the kill process itself and init.
56
Which files are open?
o lsof
57
Which processes have this file open?
o lsof
58
Which files does process X have open
lsof -p 1 | lsof -p `pgrep ABC
59
Where is the binary for this process
o lsof -p ABC | grep bin
60
Which shared libraries is this program using? (manually upgrading software, i.e. openssl)
o lsof -p PID | grep .so
61
Where is this thing logging to?
o lsof -p ABC | grep log
62
Which processes still have this old library open
o lsof grep libname.so
63
Which files does user XYZ have open?
o lsof -u XYZ | lsof -u XYZ -i (selects IPv 4/6 files for networking)
64
Which process is listening on Port X (or using Protocol Y)?
lsof -i :80 | lsof -i tcp
65
what is uptime and how do CPUs affect load averages
tells uptime of machine and session time of use load averages if 1 CPU .5 is 50% load load averages if 4 CPUS 1 is 25% aggregated load of 4 CPUs
66
how do you check kernel erros
dmesg -T
67
what does vmstat give you
``` overal stats by time memory swpd=paging...free,buff,cache swap in and out io -disk bits in and bits out system cpu looking at user, system, idel and steal ```
68
how to check CPU balance
mpstat -P ALL 1
69
how to check process usage at specified intervals
pidstat 1
70
how to check disk I/O stats
io stat -xz 1
71
how to check memory usage
free -m
72
how to check network I/O | how to check TCP stats
sar -n DEV 1 | sar -n TCP, ETCP 1
73
check performance overview
top
74
how to check system calls and signals
strace
75
Application Latency Problems | what do you check
Disk with iostat Swaps with vmstat Network with sar system calls with strace
76
Slow Performance Troubleshooting steps
``` overview with vmstat mpstat for cpu usage pidstat to check when ps is hogging resources check disk with iostat run strace -tp 'pgrep ' | head 100 ```
77
CPU high troubleshooting
``` top (not always super usefull) mpstat 1 iostat -x 1 sar -n DEV 1 vmstat 1 perf record -F 99 -a -g --sleep 10 perf report -n --stdio ```
78
how to grab columns in linux
ps | awk '{print $1}' prints first column
79
get every single user on the system
awk -F ":" '{print $1}' /etc/passwd
80
how to print multiple columns with separators from a file
awk F ":" '{print $1"\t"$6"\t"$7}' /etc/passwd awk 'BEGIN{FS=":"; OFS="-"} {PRINT $1, $6, $7}' /etc/passwd
81
how to get unique values
uniq
82
what does drwx---r-x mean 777?
d=directory- -=file l=link read write execute for user/owner....no permissions for group...and read and execute for everyone else 777 is rwx for all three r=4 w=2 x=1
83
how do you find hostname based on ip address and vice versa
nslookup
84
how to you find hostname for machine
hostname
85
how to move or rename a file
mv
86
how to make a link file
ln
87
tcpdump
kinda like wireshark | terrible performance inhibitor
88
advanced networking tools
ss gives more socket info | iptraf gives a histogram of network packet size
89
how to check paging information
pcstat
90
multi-tool for CPU profiling PMC profilng Static/Dynamic Tracing
PERF
91
What is a PMC
performance monitoring console (counter)
92
how to check and repair filesystem
fsck
93
how to set file permission
setfacl -m u::rwx filename -x to remove
94
crontab fields
Min/Hour/DOM/Month/DOW/cmd