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
Q

systemctl

A

Control the systemd system and service manager

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

How to list services with systemctl

A

systemctl list-units type=service

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

how to get status of a service

A

systemctl status

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

how do you enable a service to start at boot time

A

systemctl enable

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

start or stop a service

A

systemctl start/stop

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

What is init system.

A
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

How do you show ip address of eth0

A

• Ip addr show dev eth0

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

how to you display route information

A

ip route show

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

Know the basics of System D

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What is a linux user made of?

A

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

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

What do you know about PROC?

A

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.

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

How can you check resource utilization

A

top, htop, or atop

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

How do you look for application binary?

A

whereis will show you where the app and man pages live

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

report a snapshot of the current processes.

A

ps

39
Q

How to get open files by process id

A

LSOF -p

40
Q

how to view open ports on a machine

A

netstat -tulpn

41
Q

What can prevent you from writing a file?

A

Ownership in a folder
Permissions
I-node exhaustion…you can run df -i

42
Q

What are I-nodes

A
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
Q

What commands can you use to find i node info on a file

A

stat (various arguments) %i displays inode number

ls -lhi | grep

44
Q

How to check inode usage on a system

A

df -ih

45
Q

What happens to the inode when you copy vs move a file

A

copy creates new inode

move same inode, new info

46
Q

How do you identify where an application is installed

A

use the WHICH or WHEREIS

47
Q

What is cron

A

daemon to execute scheduled commands

48
Q

How to find config files for applications

A

Use Find in the /etc folder

49
Q

You want to check the logs for an apache / nginx server, but you cant find them in /var/log/, where would you look

A

find out where the application is installed and check the .conf file

50
Q

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

A

ssh tunnel using port forwarding -L or proxy socks -D

ssh -L 8080:192.168.1.1:3389 user@192.168.1.1

51
Q

• Difference between a process and a thread?

A

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
Q

What command used to find processes as well as cpu and memory usage?

A

top, htop

53
Q

What is the difference between a L4 and L7 load balancer?

A

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
Q

whats the difference between df and free

A

df is to check free disk space

free is to check free memory

55
Q

how does kill work?

A

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
Q

Which files are open?

A

o lsof

57
Q

Which processes have this file open?

A

o lsof

58
Q

Which files does process X have open

A

lsof -p 1

lsof -p `pgrep ABC

59
Q

Where is the binary for this process

A

o lsof -p ABC | grep bin

60
Q

Which shared libraries is this program using? (manually upgrading software, i.e. openssl)

A

o lsof -p PID | grep .so

61
Q

Where is this thing logging to?

A

o lsof -p ABC | grep log

62
Q

Which processes still have this old library open

A

o lsof grep libname.so

63
Q

Which files does user XYZ have open?

A

o lsof -u XYZ

lsof -u XYZ -i (selects IPv 4/6 files for networking)

64
Q

Which process is listening on Port X (or using Protocol Y)?

A

lsof -i :80

lsof -i tcp

65
Q

what is uptime and how do CPUs affect load averages

A

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
Q

how do you check kernel erros

A

dmesg -T

67
Q

what does vmstat give you

A
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
Q

how to check CPU balance

A

mpstat -P ALL 1

69
Q

how to check process usage at specified intervals

A

pidstat 1

70
Q

how to check disk I/O stats

A

io stat -xz 1

71
Q

how to check memory usage

A

free -m

72
Q

how to check network I/O

how to check TCP stats

A

sar -n DEV 1

sar -n TCP, ETCP 1

73
Q

check performance overview

A

top

74
Q

how to check system calls and signals

A

strace

75
Q

Application Latency Problems

what do you check

A

Disk with iostat
Swaps with vmstat
Network with sar
system calls with strace

76
Q

Slow Performance Troubleshooting steps

A
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
Q

CPU high troubleshooting

A
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
Q

how to grab columns in linux

A

ps | awk ‘{print $1}’ prints first column

79
Q

get every single user on the system

A

awk -F “:” ‘{print $1}’ /etc/passwd

80
Q

how to print multiple columns with separators from a file

A

awk F “:” ‘{print $1”\t”$6”\t”$7}’ /etc/passwd

awk ‘BEGIN{FS=”:”; OFS=”-“} {PRINT $1, $6, $7}’ /etc/passwd

81
Q

how to get unique values

A

uniq

82
Q

what does

drwx—r-x mean

777?

A

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
Q

how do you find hostname based on ip address and vice versa

A

nslookup

84
Q

how to you find hostname for machine

A

hostname

85
Q

how to move or rename a file

A

mv

86
Q

how to make a link file

A

ln

87
Q

tcpdump

A

kinda like wireshark

terrible performance inhibitor

88
Q

advanced networking tools

A

ss gives more socket info

iptraf gives a histogram of network packet size

89
Q

how to check paging information

A

pcstat

90
Q

multi-tool for CPU profiling
PMC profilng
Static/Dynamic Tracing

A

PERF

91
Q

What is a PMC

A

performance monitoring console (counter)

92
Q

how to check and repair filesystem

A

fsck

93
Q

how to set file permission

A

setfacl -m u::rwx filename

-x to remove

94
Q

crontab fields

A

Min/Hour/DOM/Month/DOW/cmd