# Linux

Discussing Linux commands and apps that aren't directly related to self hosting but are generally useful.

# Linux Troubleshooting

How to deal with specific problems I encountered in Linux.

# How to fix Read-Only EXT4 drive

<div class="n6owBd awi2gc" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCAkQAA" data-sfc-cp="" data-sfc-root="ep" id="bkmrk-an-external-ext4-dri" jsaction="" jscontroller="TDBkbc#Ml18Xb" jsuid="NIX2Ld_i" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-subtree="aimfl,mfl" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">An external ext4 drive mounts as read-only in Linux usually because the kernel detected file system corruption or an improper unmount and switched it to read-only mode to prevent data loss. It can also be caused by hardware failure or root-only root directory permissions. \[[1](https://superuser.com/questions/1711832/linux-mounts-ext4-external-drive-read-only), [2](https://www.tecmint.com/fix-usb-read-only-linux/), [3](https://askubuntu.com/questions/356101/ext4-constantly-mounts-as-read-only), [4](https://bbs.archlinux.org/viewtopic.php?id=307311)\]</span></div><div class="Fsg96" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-inited="2" data-sfc-root="ep" id="bkmrk-" jsaction="rcuQ6b:&NIX2Ld_v|npT2md" jscontroller="KHhJQ#U8DOt" jsuid="NIX2Ld_v" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"></div><div aria-level="3" class="otQkpb" data-animation-nesting="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);" data-sfc-cp="" data-sfc-root="ep" id="bkmrk-how-to-fix-and-troub" jsaction="" jscontroller="a7qCn#ZxCkTb" jsuid="NIX2Ld_w" role="heading" style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);">How to Fix and Troubleshoot</div><div class="Fsg96" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-inited="2" data-sfc-root="ep" id="bkmrk--1" jsaction="rcuQ6b:&NIX2Ld_x|npT2md" jscontroller="KHhJQ#U8DOt" jsuid="NIX2Ld_x" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCAoQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIChAA" id="bkmrk-1.-identify-the-driv" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div aria-level="3" class="otQkpb" data-animation-nesting="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="a7qCn#ZxCkTb" jsuid="NIX2Ld_y" role="heading" style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);">1. Identify the Drive Partition</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCAsQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEICxAA" id="bkmrk-find-your-external-d" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div class="n6owBd awi2gc" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCAsQAQ" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="TDBkbc#Ml18Xb" jsuid="NIX2Ld_z" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Find your external drive's device name (e.g., `/dev/sdb1` or `/dev/sdc1`):</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCAwQAQ" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIDBAB" id="bkmrk-run%3A-lsblk-or-df--h" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Run: `lsblk` or `df -h`</span></div>
<div class="Fsg96" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-inited="2" data-sfc-root="ep" id="bkmrk--3" jsaction="rcuQ6b:&NIX2Ld_1h|npT2md" jscontroller="KHhJQ#U8DOt" jsuid="NIX2Ld_1h" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCA8QAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIDxAA" id="bkmrk-2.-unmount-and-repai" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div aria-level="3" class="otQkpb" data-animation-nesting="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="a7qCn#ZxCkTb" jsuid="NIX2Ld_1i" role="heading" style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);">2. Unmount and Repair the File System</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBAQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIEBAA" id="bkmrk-you-must-unmount-the" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div class="n6owBd awi2gc" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBAQAQ" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="TDBkbc#Ml18Xb" jsuid="NIX2Ld_1j" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">You must unmount the drive before running a file system check (`fsck`):</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBEQAQ" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIERAB" id="bkmrk-unmount-the-drive%3A-s" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Unmount the drive: `sudo umount /dev/sdX1` *(replace `sdX1` with your actual partition)*</span></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBEQAw" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIERAD" id="bkmrk-repair-errors%3A-sudo-" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Repair errors: `sudo e2fsck -f /dev/sdX1`</span></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBEQBQ" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIERAF" id="bkmrk-follow-any-prompts-t" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Follow any prompts to fix or clear blocks.</span> [[1](https://superuser.com/questions/1829511/how-to-investigate-ext4-filesystem-going-read-only-no-hardware-errors-reported), [2](https://forums.raspberrypi.com/viewtopic.php?t=210903), [3](https://ostechnix.com/check-disk-health-linux/), [4](https://www.vcom.com.hk/shows/61/479.html)]</div>
<div class="Fsg96" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-inited="2" data-sfc-root="ep" id="bkmrk--5" jsaction="rcuQ6b:&NIX2Ld_29|npT2md" jscontroller="KHhJQ#U8DOt" jsuid="NIX2Ld_29" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBQQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIFBAA" id="bkmrk-3.-remount-as-read-w" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div aria-level="3" class="otQkpb" data-animation-nesting="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="a7qCn#ZxCkTb" jsuid="NIX2Ld_2a" role="heading" style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);">3. Remount as Read-Write</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBUQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIFRAA" id="bkmrk-once-the-repair-fini" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div class="n6owBd awi2gc" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBUQAQ" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="TDBkbc#Ml18Xb" jsuid="NIX2Ld_2b" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Once the repair finishes cleanly, mount it back normally: [[1](https://www.reddit.com/r/linux_gaming/comments/12t9z5l/external_hdd_says_read_only_file_system_when/)]</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBYQAQ" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIFhAB" id="bkmrk-mount-command%3A-sudo-" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Mount command: `sudo mount -o remount,rw /dev/sdX1` or unplug and plug it back in.</span> [[1](https://www.reddit.com/r/Ubuntu/comments/1b4agov/external_disk_has_a_name_but_in_properties_it_has/), [2](https://askubuntu.com/questions/175739/how-do-i-remount-a-filesystem-as-read-write)]</div>
<div class="Fsg96" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-inited="2" data-sfc-root="ep" id="bkmrk--7" jsaction="rcuQ6b:&NIX2Ld_2r|npT2md" jscontroller="KHhJQ#U8DOt" jsuid="NIX2Ld_2r" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBcQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIFxAA" id="bkmrk-4.-fix-ownership-iss" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div aria-level="3" class="otQkpb" data-animation-nesting="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="a7qCn#ZxCkTb" jsuid="NIX2Ld_2s" role="heading" style="font-family: Google Sans, sans-serif; font-size: 20px; font-weight: 600; margin: 24px 0px 12px; text-decoration: none; border-bottom: 0px rgb(238, 240, 255);">4. Fix Ownership Issues (If Not Corrupted)</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBgQAA" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIGBAA" id="bkmrk-if-fsck-finds-no-err" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><div class="n6owBd awi2gc" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBgQAQ" data-sfc-cp="" data-sfc-root="ep" jsaction="" jscontroller="TDBkbc#Ml18Xb" jsuid="NIX2Ld_2t" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 12px 0px 16px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">If `fsck` finds no errors but you still cannot write, the root folder of the drive likely belongs to the `root` user: [[1](https://bbs.archlinux.org/viewtopic.php?id=307311)]</div></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBoQAQ" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIGhAB" id="bkmrk-mount-the-drive-manu" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Mount the drive manually to a folder or navigate to its mount point.</span></div><div class="" data-bfc="" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-hveid="CAIIAAgBCBoQAw" data-ved="2ahUKEwi1zbaR8pSWAxVXhIkEHRLSG0EQi4wTegoIAggACAEIGhAD" id="bkmrk-change-ownership-to-" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);"><span class="iNqyIf" data-copy-service-computed-style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);" data-sfc-cp="" data-sfc-root="ep" style="font-family: Google Sans, sans-serif; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(230, 232, 240);">Change ownership to your current user: `sudo chown -R $USER:$USER /path/to/mount/point`</span></div>

# Useful Commands

"sudo pacman -Sy"  
"sudo pacman -S git fakeroot binutils"  
"cd ~/Downloads"  
"git clone https://aur.archlinux.org/realvnc-vnc-viewer.git"  
"cd realvnc-vnc-viewer"  
"sudo pacman -U realvnc-vnc-viewer-\*-x86\_64.pkg.tar.zst"

"su" - elevate prompt so you don't need sudo  
"pwd" - show current directory  
"sudo fdisk -l" - ?  
"mhwd -li" - show ??  
"pamac install gvfs-smb" - install samba

"find . -type d -empty -delete" - delete empty subfolders

"rsync -rvh /path/to/dir1 /path/to/destination" - basic copy command with rsync that copies one folder and all sub-folders into a destination

"rsync -avh /path/to/dir1/ /path/to/dir2/ /path/to/destination/" - copy the contents of two folders into one destination with rsync  
Example: "rsync -avh /a/Media/ /b/Media/ /c/Media/" - results in /c/Media containing the **contents** of the two source Media folders  
"rsync -avh /a/Media /b/Media /c/" - another way to get the same results as the previous one  
"rsync -avh /a/Media /b/Media /c/Media" - Results in /a/Media and /b/Media being merged into /c/Media/Media

-a (archive): Preserves symbolic links, permissions, ownership, and timestamps. Identical to -dR --preserve=all, preserving recursive structure, symlinks, and attributes.  
\--archive archive mode; equals -rlptgoD (no -H,-A,-X)  
\--no-OPTION turn off an implied OPTION (e.g. --no-D)  
-H (Hard Links): Preserves hard links in the transfer (not included in -a).  
-A and -X: Preserve ACLs (Access Control Lists) and Extended Attributes, respectively.  
-v (Verbose): Increases the information provided during the transfer, listing each file as it is processed.  
-q, --quiet suppress non-error messages  
\--no-motd suppress daemon-mode MOTD (see caveat)  
-c (Checksum): Forces rsync to compare files based on checksums rather than the default "quick check" of file size and modification time.  
-r, --recursive recurse into directories  
-R, --relative use relative path names  
\--no-implied-dirs don't send implied dirs with --relative  
-P: Combines --partial (keeps partially transferred files if the sync is interrupted) and --progress (shows a progress bar during the transfer).  
-u, --update skip files that are newer (modified time) on the receiver  
\--inplace update destination files in-place  
\--append append data onto shorter files  
\--append-verify --append w/old data in file checksum  
-z (Compress): Compresses data during the transfer to reduce network usage, which is ideal for slow connections.  
-h (Human-Readable): Displays file sizes and transfer speeds in a more readable format (e.g., KB, MB, GB) instead of raw bytes.  
-n or --dry-run: Performs a trial run without making any actual changes. This is critical for testing your command before execution

If you're moving large files and you want the option to resume a cancelled or failed rsync operation from the exact point that rsync stopped, you need to use the --append or --append-verify switch on the next attempt.

Another example: rsync -achvuXPn --remove-source-files Media/ /mnt/omv/media/

In this example, it does it's best to preserve the original files, uses a checksum to verify integrity of existing files, human readable verbose logs, skips newer (modified time) files, preserves extended attributes, allows resuming, deletes source after copy and is a test run.

\--delete: Deletes files at the destination that no longer exist at the source. Use this to create an exact mirror, but always use --dry-run first to avoid accidental data loss.  
-e &lt;command&gt;: Specifies the remote shell to use, most commonly ssh. For example: rsync -avz -e ssh source/ user@remote:/dest/.  
\--exclude='PATTERN': Excludes files or directories matching a specific pattern from the transfer.  
\--ignore-existing (Optional but Recommended): Only copies files that do not exist on the destination, ignoring existing files, which saves time.  
Trailing / (Crucial): Ensure you include a trailing slash on the source path (e.g., /source/) to copy the contents of the folder, not the folder itself.

References:   
[https://linuxize.com/post/how-to-use-rsync-for-local-and-remote-data-transfer-and-synchronization/](https://linuxize.com/post/how-to-use-rsync-for-local-and-remote-data-transfer-and-synchronization/)  
[https://linux.die.net/man/1/rsync](https://linux.die.net/man/1/rsync)

"cp" - alternate copy command

Never use "cp -r" if you need to maintain soft links (symlinks) as links; -r copies the actual file the link points to. Use -a instead.

# The importance of sudo (rsync)

<div class="n6owBd awi2gc" id="bkmrk-adding-sudo-prevents" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px 0px 16px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><span style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);">Adding </span>`sudo` prevents "permission denied" errors if the blockage is caused by a lack of read or write privileges on files and folders. However, how you apply `sudo` depends on whether you are running `rsync` locally or over a remote SSH connection. [[1](https://askubuntu.com/questions/719439/using-rsync-with-sudo-on-the-destination-machine), [2](https://unix.stackexchange.com/questions/541200/rsync-permission-denied-13-what-am-i-doing-wrong), [3](https://www.dzombak.com/blog/2025/06/how-to-rsync-with-sudo-on-both-sides/)]</div><div class="Fsg96" id="bkmrk-" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"></div><div class="otQkpb" id="bkmrk-local-transfers" style="font-family:'Google Sans', sans-serif;font-size:20px;font-weight:600;margin:24px 0px 12px;text-decoration:none;border-bottom:0px rgb(238,240,255);">Local Transfers</div><div id="bkmrk-put-sudo-at-the-very" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><span class="iNqyIf" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);">Put `sudo` at the very front of your command: `sudo rsync -av /source/ /destination/`.</span></div><div id="bkmrk-this-runs-the-entire" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><span class="iNqyIf" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);">This runs the entire process with root permissions, bypassing local file restrictions.</span> [[1](https://superuser.com/questions/398146/rsync-permission-denied-backing-up-a-remote-directory-to-my-local-machine), [2](https://serverfault.com/questions/255120/run-rsync-as-root-but-keep-user-ownership), [3](https://www.dzombak.com/blog/2025/06/how-to-rsync-with-sudo-on-both-sides/)]</div>
<div class="Fsg96" id="bkmrk--2" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"></div><div id="bkmrk-remote-transfers-%28vi" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><div class="otQkpb" style="font-family:'Google Sans', sans-serif;font-size:20px;font-weight:600;margin:24px 0px 12px;text-decoration:none;border-bottom:0px rgb(238,240,255);">Remote Transfers (via SSH)</div></div><div id="bkmrk-typing-sudo-rsync-lo" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><div class="n6owBd awi2gc" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:12px 0px 16px;text-decoration:none;border-bottom:0px rgb(230,232,240);">Typing `sudo rsync` locally only elevates privileges on your local machine. If the permission error happens on the remote server, you must tell `rsync` to invoke `sudo` on the remote side using the `--rsync-path` flag: [[1](https://alexwlchan.net/notes/2024/use-rsync-and-passwordless-sudo/), [2](https://superuser.com/questions/965461/rsync-directories-that-need-sudo-permissions-on-the-remote-server), [3](https://askubuntu.com/questions/719439/using-rsync-with-sudo-on-the-destination-machine), [4](https://www.dzombak.com/blog/2025/06/how-to-rsync-with-sudo-on-both-sides/)]</div></div><div id="bkmrk-command%3A-rsync--av--" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><span class="iNqyIf" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);">Command: `rsync -av -e ssh --rsync-path="sudo rsync" /local/path/ user@remote:/remote/path/`</span></div><div id="bkmrk-important%3A-the-remot" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);"><span class="iNqyIf" style="font-family:'Google Sans', sans-serif;font-size:16px;font-weight:400;margin:0px;text-decoration:none;border-bottom:0px rgb(230,232,240);">**Important:** The remote user account must be configured for passwordless `sudo` (`NOPASSWD`) for `rsync` in the remote `/etc/sudoers` file. Otherwise, `rsync` will hang or fail when it tries to prompt you interactively for a password.</span></div>

# Docker Commands

docker stats --format "table {{.ID}}\\t{{.Name}}\\t{{.CPUPerc}}\\t{{.MemUsage}}\\t{{.MemPerc}}\\t{{.NetIO}}\\t{{.BlockIO}}\\t{{.PIDs}}" --no-stream

docker stats --format "table {{.ID}}\\t{{.Name}}\\t{{.CPUPerc}}\\t{{.MemPerc}}\\t{{.NetIO}}\\t{{.BlockIO}}" --no-stream