Technical - Linux/OS Flashcards
Hard vs Soft/Sym Link (+how to create)
Hard Link:
Definition: Filesystem entry pointing directly to the inode of a file.
Deletion Behavior: No problem
Creation: ln <source></source> <target></target>
Soft/Symbolic Link:
Definition: File system entry that creates a new inode that references the path to the target file.
Deletion Behavior: Broken link
Creation: ln -s <source></source> <target></target>
File Descriptor (Explain stdout, stderr, and stdin)
Definition: An integer that uniquely identifies an open file in a process.
Standard Descriptors:
stdin (0): Standard input.
stdout (1): Standard output.
stdout (2): Standard error.
Process vs Thread
Process:
Definition: An independent program in execution, with its own memory space.
Resource Sharing: None, separate memory space and resources.
Thread:
Definition: A smaller unit of execution within a process.
Resource Sharing: Separate registers and stack, but shares memory space.
Linux Boot Process (BIOS > MBR > GRUB/LILO > Kernel > Init System)
BIOS: Initializes hardware, loads and executes bootloader from MBR (Master boot record).
GRUB/LILO: Bootloader(GRUB) loads and executes the Linux kernel and mounts initial RAM disk
Kernel: Initializes system hardware and mounts the root filesystem.
Init System: Starts user-space processes (e.g., systemd, SysVinit).
Full Disk Encryption LUKS (TPM Integration)**
LUKS: Linux Unified Key Setup; provides full disk encryption.
TPM: Trusted Platform Module; stores encryption keys securely.
Integration: LUKS can be used with TPM to protect encryption keys against tampering.
Secure Boot
Purpose: Ensures that only signed and authorized software is loaded during boot.
Mechanism: Checks digital signatures of bootloaders and kernels to prevent unauthorized modifications.
Inode (How to check inode number and inode usage)
Index Node:
Definition: Data structure containing metadata about a file (e.g., size, permissions), but not file name or contents.
Check: ls -i <file> shows the inode number. df -i shows inode usage.</file>
Zombie Process
Definition: A process that has completed execution but still has an entry in the process table.
Cause: Parent process has not yet read the exit status.
Check: ps aux | grep Z
Iptables vs UFW**
Definition: User-space utility for configuring Linux kernel firewall.
Usage: iptables -A INPUT -p tcp –dport 22 -j ACCEPT (Allow SSH)
DF vs DU
DF: Shows filesystem disk space usage.
Command: df -h
DU: Shows disk usage of files and directories.
Command: du -sh <directory></directory>
SELinux**
Definition: Security-Enhanced Linux; provides mandatory access controls.
Commands:
Check Status: sestatus
Manage Policies: semanage, setenforce
How to check disk space, memory, cpu, and io
Disk Space: df -h
Memory: free -h
CPU: top or htop
IO: iostat (requires sysstat package)
How to check open files (+why significant)
Command: lsof
Significance: Identifies files and sockets opened by processes, useful for troubleshooting and security.
How to check open ports on local system
netstat -tuln
How to scan external system for open ports (+flags)
nmap -p <port-range> <target></target></port-range>
Systemd (How to create, status, stop, start)
Create Service: Write a .service file in /etc/systemd/system/
Status: systemctl status <service>
Start: systemctl start <service>
Stop: systemctl stop <service></service></service></service>
How to trace a network path from source to target
traceroute <destination></destination>
How to lookup IP for DNS record and reverse
DNS Record: dig <domain> or nslookup <domain>
Reverse Lookup: dig -x <IP> or nslookup <IP></IP></IP></domain></domain>
Linux Filesystem Architecture
Standard Dirs:
/root - home dir for root user
/bin - essential user command binaries
/boot - static files of boot loader
/dev - rep hardware devices
/etc - system-wide config
/home - user home dirs
/lib - shared libraries and kernel modules
/media - mount point for removable media
/mnt - mount point for temp mounted fs
/sbin - system bins
/srv - data for system services
/opt - add-on optional application pkgs
/root - Home dir for root user
/tmp - temporary fs
/usr - user-related programs
/var - variable data files w/frequent change
Special FSs:
/proc - virtual fs providing process and kernel info
/sys - virtual fs providing info and control over kernels devices and modules
/dev/shm - Temp file storage for inter-process comms
Linux Kernel Architecture**
Monolithic Kernel: A single large kernel that includes the core functionalities and all device drivers.
System Call Interface: Provides the interface between user-space applications and kernel services.
How to configure basic LAN:
Use netplan or ip commands to configure interface, addresses, gateway, and nameservers.
How to check running processes (+how to kill)
Running Processes: ps aux or top
Kill Process: kill <PID> or kill -9 <PID> (force kill)</PID></PID>
/proc**
/sys**
/dev/shm**
Linux Namespaces
Linux Control Groups (cGroups)
AppArmour
RAM Disk
strace
Linux Families/Distros (3)
- Debian: Ubuntu, Mint
- Fedora: RHEL, CentOS
- SUSE: SLES, OpenSUSE
Linux vs Unix
Initialization Systems (SystemD vs InitD vs SystemV)
LVM
whatis vs apropos
man vs info
grep vs egrep (grep “” <>)
How to count words or lines in a file
Redirection:
1. Redirect stdout to file
2. Redirect stderr to file
3. Redirect stdout/stderr to file
4. Redirect stdout to file AND print
5. Redirect stderr to file AND print
6. Redirect stdout/stderr to file AND print
7. Overwrite vs append for both ways
8. Which operators will create file
Permissions:
1. What are the symbolic characters for users, operations, and permissions?
2. What are the octal numbers for permissions
- ugoa +_= rwx
- x=1, w=2, r=4
umask (what, how to set)
Compression vs archive (w/tar + gz & bz2)
journalctl (unit, grep, boot logs, config)
nice/renice
chrt
pgrep/pkill
sysVinit, upstart, and systemd
Tuned
Fdisk vs gdisk vs parted
Swap (what is it and basic steps to setup RHEL vs Ubuntu)
Steps to format and mount block device persistently.
List block devices and check partitions
xfs vs ext4 vs vfat vs ntfs
Brace expansion (list, range)
Paramater expansion (default use, default assign, substring, replace)
autofs and nfs/smb
setgid, setuid, and sticky bit
stat
at vs chrony
Background jobs, shell job table, and SIGHUP:
1. command &
2. nohup command &
3. ctrl-z
4. jobs
5. bg %<id>
6. fg %<id>
7. disown %<id></id></id></id>
useradd, usermod, userdel, groupadd, groupmod, groupdel, passwd, chage
How to enforce password policies in Linux?
How to view and update firewall config:
1. ufw
2. firewalld/firewall-cmd
ACL:
1. setfacl
2. getfacl