diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-01-19 21:14:51 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-01-19 21:14:51 +0100 |
commit | 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 (patch) | |
tree | ae25c3b0db7ae4c23186b294c6d000073f085c2d /3 resources/linux | |
parent | 969b96c2531fb986f6c7f21fd544391b439defd7 (diff) |
vault backup: 2025-01-19 21:14:51
Diffstat (limited to '3 resources/linux')
-rw-r--r-- | 3 resources/linux/APT.md | 5 | ||||
-rw-r--r-- | 3 resources/linux/Definitions.md | 6 | ||||
-rw-r--r-- | 3 resources/linux/Device drivers.md | 22 | ||||
-rw-r--r-- | 3 resources/linux/Device mapper.md | 28 | ||||
-rw-r--r-- | 3 resources/linux/LSOF.md | 69 | ||||
-rw-r--r-- | 3 resources/linux/Users.md | 22 | ||||
-rw-r--r-- | 3 resources/linux/Watch.md | 4 | ||||
-rw-r--r-- | 3 resources/linux/filesystems/Tmpfs.md | 16 | ||||
-rw-r--r-- | 3 resources/linux/networking/DHCP.md | 5 | ||||
-rw-r--r-- | 3 resources/linux/networking/IP masquerade.md | 17 | ||||
-rw-r--r-- | 3 resources/linux/networking/PXE.md | 18 |
11 files changed, 0 insertions, 212 deletions
diff --git a/3 resources/linux/APT.md b/3 resources/linux/APT.md deleted file mode 100644 index 9231d40..0000000 --- a/3 resources/linux/APT.md +++ /dev/null @@ -1,5 +0,0 @@ -#linux #packages #how-to - ---- -reinstall packages: -`apt reinstall <pkg>`
\ No newline at end of file diff --git a/3 resources/linux/Definitions.md b/3 resources/linux/Definitions.md deleted file mode 100644 index c0ca4dd..0000000 --- a/3 resources/linux/Definitions.md +++ /dev/null @@ -1,6 +0,0 @@ -#linux #definitions - ---- -NBP = Network Bootstrap Program -PXE = Preboot Execution Environment -NIC = Network Interface Card
\ No newline at end of file diff --git a/3 resources/linux/Device drivers.md b/3 resources/linux/Device drivers.md deleted file mode 100644 index 95f1a75..0000000 --- a/3 resources/linux/Device drivers.md +++ /dev/null @@ -1,22 +0,0 @@ -#linux #devices - ---- -major, minor numbers -major = driver (used by kernel when opening device to dispatch to correct driver) -minor = used by driver to differentiate device(s) - -after disk the major, minor numbers are shown: -``` -[jasras@n04.compute.vps2-lej1 ~]$ ls -l /dev/dm-* -brw-rw---- 1 root disk 253, 0 Oct 25 10:10 /dev/dm-0 -brw-rw---- 1 root disk 253, 1 Oct 25 10:11 /dev/dm-1 -brw-rw---- 1 root root 253, 11 Oct 28 19:58 /dev/dm-11 -brw-rw---- 1 root root 253, 12 Oct 28 19:58 /dev/dm-12 -``` - -available devices: `cat /proc/devices` - -character devices vs block devices; what is the difference? - ---- -[oreilly-device-drivers](https://www.oreilly.com/library/view/linux-device-drivers/0596000081/ch03s02.html)
\ No newline at end of file diff --git a/3 resources/linux/Device mapper.md b/3 resources/linux/Device mapper.md deleted file mode 100644 index 059a0d1..0000000 --- a/3 resources/linux/Device mapper.md +++ /dev/null @@ -1,28 +0,0 @@ -#linux #device-mapper - ---- -Device mapper is a kernel driver to map physical block devices to virtual ones; this means that for example we can have many physical devices be represented by a single virtual one (linear mapping). - -How does it work? -[[1 projects/Inwerken Mohammed/TODO]] -What is its function in relation to multipath? - -Logical devices using device-mapper can be managed using `man 8 dmsetup` -``` -[jasras@n04.compute.vps2-lej1 ~]$ sudo dmsetup info 3600a098038314d736724566a67346538 -Name: 3600a098038314d736724566a67346538 -State: ACTIVE -Read Ahead: 256 -Tables present: LIVE -Open count: 1 -Event number: 3 -Major, minor: 253, 12 -Number of targets: 1 -UUID: mpath-3600a098038314d736724566a67346538 -``` - -If dmsetup cannot remove a device because a process still has it open, but lsof does not show any processes that open it, use `-f` which replaces the device with a fake that rejects all I/O. - ---- -[device-mapper](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/device_mapper#device_mapper) -[dmsetup](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/dmsetup#dmsetup)
\ No newline at end of file diff --git a/3 resources/linux/LSOF.md b/3 resources/linux/LSOF.md deleted file mode 100644 index 5a3aa95..0000000 --- a/3 resources/linux/LSOF.md +++ /dev/null @@ -1,69 +0,0 @@ -#linux #how-to - ---- - -``` -lsof -p 1111 # show open files for this PID -lsof /path/to/file # show which process has this open -``` - -A usage in the wild; using lsof to find the qemu process for a specific base image and using that to get instance name and disk path: -``` -lsof -F p {{ item['path'] }} | cut -b 2- | head -1 | xargs ps | grep -oP '(instance\\-[a-z0-9]+)|(\\/var\\/lib\\/nova\\/instances\\/[a-z0-9\\-]+\\/disk)' | uniq -``` - -(man lsof: search "OUTPUT FOR OTHER PROGRAMS") -output for other programs -``` -specify -F -These are the fields that lsof will produce. The single character listed first is the field identifier. - a file access mode - c process command name (all characters from proc or - user structure) - C file structure share count - d file's device character code - D file's major/minor device number (0x<hexadecimal>) - f file descriptor (always selected) - F file structure address (0x<hexadecimal>) - G file flaGs (0x<hexadecimal>; names if +fg follows) - g process group ID - i file's inode number - K tasK ID - k link count - l file's lock status - L process login name - m marker between repeated output - M the task comMand name - n file name, comment, Internet address - N node identifier (ox<hexadecimal> - o file's offset (decimal) - p process ID (always selected) - P protocol name - r raw device number (0x<hexadecimal>) - R parent process ID - s file's size (decimal) - S file's stream identification - t file's type - T TCP/TPI information, identified by prefixes (the - `=' is part of the prefix): - QR=<read queue size> - QS=<send queue size> - SO=<socket options and values> (not all dialects) - SS=<socket states> (not all dialects) - ST=<connection state> - TF=<TCP flags and values> (not all dialects) - WR=<window read size> (not all dialects) - WW=<window write size> (not all dialects) - (TCP/TPI information isn't reported for all supported - UNIX dialects. The -h or -? help output for the - -T option will show what TCP/TPI reporting can be - requested.) - u process user ID - z Solaris 10 and higher zone name - Z SELinux security context (inhibited when SELinux is disabled) - 0 use NUL field terminator character in place of NL - 1-9 dialect-specific field identifiers (The output - of -F? identifies the information to be found - in dialect-specific fields.) - -```
\ No newline at end of file diff --git a/3 resources/linux/Users.md b/3 resources/linux/Users.md deleted file mode 100644 index 885a7cc..0000000 --- a/3 resources/linux/Users.md +++ /dev/null @@ -1,22 +0,0 @@ -#linux #user-management - -Change uid/gid of user -`usermod -u newnumber user` -`groupmod -g newnumber user` - -File permissions in homedir will be automatically updated; file perms outside home dir will not be automatically updated. - -Finding files of a specific user, and printing their uid/gid; -`sudo find / -user 4109 -printf '%p %u(%U) %g(%G)\n'` - -To change only the group: `chgrp`. - -Or using find to chmod/chgrp: -`sudo find / -user 4109 -group 4109 -exec chmod 998:998 {} \;` -`sudo find / -group 4109 -exec chgrp 998 {} \;` - -Dirty way to find "system users" (uid < 999) - note that this is not fool-proof, it also lists groups -`getent passwd | grep -oP '\b[0-9]{3}\b' | uniq | sort` - ---- -https://www.cyberciti.biz/faq/linux-change-user-group-uid-gid-for-all-owned-files/ diff --git a/3 resources/linux/Watch.md b/3 resources/linux/Watch.md deleted file mode 100644 index 0c167b7..0000000 --- a/3 resources/linux/Watch.md +++ /dev/null @@ -1,4 +0,0 @@ -#linux #how-to - ---- -`watch (1)` periodically executes the executable on argv. It can be used to reload the output of a command, like `sudo watch ovs-dpctl dump-flows` . diff --git a/3 resources/linux/filesystems/Tmpfs.md b/3 resources/linux/filesystems/Tmpfs.md deleted file mode 100644 index b8fe839..0000000 --- a/3 resources/linux/filesystems/Tmpfs.md +++ /dev/null @@ -1,16 +0,0 @@ -#linux #filesystem - ---- -Is a [[virtual filesystem]] that is stored in memory; it uses both RAM and swap space. -> Kernel option: CONFIG_TMPFS - -`mount -t tmpfs source target` - -A tmpfs can only grow to 50% of RAM avail. unless overridden with size=nbytes mount option. -Only consumes RAM for actual usage. -Data is ephemeral/volatile. - -Mount stacking: mount over existing /tmp, to improve speed of apps using alot of tmp files, then unmount to delete data. - -Kernel uses tmpfs for [[system v shared memory]] and [[shared anonymous memory mappings]]. -`/dev/shm` or `/run/shm`: [[glibc]] of [[POSIX]] shared memory and [[POSIX]] semaphores.
\ No newline at end of file diff --git a/3 resources/linux/networking/DHCP.md b/3 resources/linux/networking/DHCP.md deleted file mode 100644 index e7e8e38..0000000 --- a/3 resources/linux/networking/DHCP.md +++ /dev/null @@ -1,5 +0,0 @@ -#networking #linux - ---- -Dynamic Host Configuration Protocol -Allows hosts dynamically receive an IP address.
\ No newline at end of file diff --git a/3 resources/linux/networking/IP masquerade.md b/3 resources/linux/networking/IP masquerade.md deleted file mode 100644 index 2ccc8e6..0000000 --- a/3 resources/linux/networking/IP masquerade.md +++ /dev/null @@ -1,17 +0,0 @@ -#linux #networking - ---- -A function in the kernel that allows guests with internal/private IPs to access the internet by using the hosts' public IP similar to 1 to many NAT. - -Differences with Proxy, IP Masq, NAT: - -**Proxy** -Requires special configuration on internal client side. Can be used for caching. - -**IP Masq** -A form of NAT used primarily in Linux devices. Translates IP address and uses the connection tracking table and ports to map responses back to the internal connection. - -**NAT** -Has different types with different use-cases. -Static NAT: 1-1 mapping of pub/private IP. Dynamic NAT: pool of pub ips to dynamically map private IPs to based on availability. -PAT (Port): similar to IP Masq; 1-many using ports.
\ No newline at end of file diff --git a/3 resources/linux/networking/PXE.md b/3 resources/linux/networking/PXE.md deleted file mode 100644 index d5fe4d1..0000000 --- a/3 resources/linux/networking/PXE.md +++ /dev/null @@ -1,18 +0,0 @@ -#linux #pxe - ---- -The NBP is a bootloader that is obtained via the network typically via [[TFTP]]. It handles setting up an environment in which an OS can run or install. For example, it displays a boot menu and downloads the kernel images. It sets up hardware, for example the [[NIC]]s. - -PXE boot process: -1. Modified [[DHCP]] request: request to include boot information (PXE boot request). -2. Process DHCP response which includes an IP address of [[TFTP]] server and filename of [[NBP]]. -3. Download NBP over TFTP. -4. NBP executes - 1. Loads additional stuff over network, like kernel images. - 2. Handles the boot menu -5. Kernel takes over boot process and potentially downloads additional files required to complete booting. - -Popular NBP's: -- PXELINUX -- iPXE -- GRUB2 |