Image to PDF with OCR on Fedora Linux

sudo dnf install ocrmypdf tesseract tesseract-langpack-eng tesseract-langpack-fas ImageMagick

Convert to PDF, enhance clarity (e.g., for OCR), add filters:

magick 01.jpeg \
  -resize 200% \
  -colorspace Gray \
  -sharpen 0x1 \
  -contrast-stretch 0 \
  -threshold 50% \
  cleaned.pdf

Or for OCR preprocessing (especially with Tesseract):

magick 01.jpeg \
  -resize 300% \
  -colorspace Gray \
  -normalize \
  -sharpen 0x1 \
  cleaned.pdf

Then apply OCR:

ocrmypdf -l eng+fas cleaned.pdf output.pdf

 

Optimize Kernel Configuration for Fedora

sudo nano /etc/sysctl.d/99-custom.conf
vm.swappiness=10
vm.dirty_ratio=15
vm.dirty_background_ratio=5
kernel.sched_migration_cost_ns=5000000
sudo sysctl --system
sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off noibrs noibpb nospec_store_bypass_disable nopti zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=25"
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo systemctl enable --now fstrim.timer
sudo journalctl --vacuum-size=100M

 

Set Permanently ulimit -n open files in Fedora

sudo nano /etc/security/limits.d/99-openfiles.conf
* soft    nofile  65536
* hard    nofile  1048576
sudo nano /etc/systemd/system.conf
[Manager]
# Set soft:hard limits
DefaultLimitNOFILE=65536:1048576
# Or set both soft and hard to the same value
# DefaultLimitNOFILE=65536
sudo nano /etc/systemd/user.conf
[Manager]
# Set soft:hard limits
DefaultLimitNOFILE=65536:1048576
# Or set both soft and hard to the same value
# DefaultLimitNOFILE=65536
sudo systemctl daemon-reexec
sysctl fs.file-max
sudo nano /etc/sysctl.d/99-filemax.conf
fs.file-max = <larger_value>
sudo sysctl -p /etc/sysctl.d/99-filemax.conf
# Or apply all sysctl settings: sudo sysctl -p

 

Increase max_user_watches on Fedora Linux

Check current value:

cat /proc/sys/fs/inotify/max_user_watches

Temporarily change the value:
This change will reset after reboot.

sudo sysctl fs.inotify.max_user_watches=524288

Permanently change the value:
Edit or create the config file:

sudo nano /etc/sysctl.d/99-inotify.conf

Add the following line (or update if it already exists):

fs.inotify.max_user_watches=524288

Apply changes:

sudo sysctl -p /etc/sysctl.d/99-inotify.conf

Verify:

cat /proc/sys/fs/inotify/max_user_watches

 

 

Dual Boot Clock Issues

If you’re using dual-boot Windows alongside a Linux distribution (like Fedora, Ubuntu, etc.), you’ve probably encountered that frustrating issue where the clock shows the wrong time after switching from one OS to the other. It drove me crazy! This post is a quick reminder for my future self (and maybe you!) on why this happens and the best way I found to fix it permanently.

The Root Cause: A Tale of Two Time Standards

The heart of the problem lies in how Windows and Linux, by default, interpret the time stored in your computer’s Hardware Clock (also known as the RTC or CMOS clock). This is the clock that keeps running even when your PC is off, thanks to that little battery on the motherboard.

  • Windows: Assumes the time stored in the Hardware Clock is Local Time – the actual time on the clock in your specific time zone (e.g., Eastern Daylight Time, Pacific Standard Time), including adjustments for Daylight Saving Time (DST).
  • Linux (most distros): Assumes the time stored in the Hardware Clock is Coordinated Universal Time (UTC) – the global time standard that doesn’t change with time zones or DST. Linux then calculates your correct local time based on UTC plus your selected time zone settings.

When you switch operating systems, they read the Hardware Clock based on their own assumption. One OS might then “correct” the Hardware Clock according to its standard, making it wrong for the other OS when you boot into it next. This back-and-forth causes the time drift.

The Fix: Tell Windows the Hardware Clock is UTC

The most robust solution is to make Windows adopt the same standard as Linux: interpreting the Hardware Clock as UTC. This requires a simple change in the Windows Registry.

Why this method is generally preferred:

  • It aligns both operating systems with a universal standard (UTC).
  • UTC doesn’t have ambiguities related to Daylight Saving Time transitions, making it more reliable for the base hardware clock time.

Here are the steps:

  1. Boot into Windows.
  2. Open Registry Editor: Press Win + R, type regedit, and hit Enter. You’ll likely need to approve the User Account Control (UAC) prompt by clicking “Yes”.
    • Standard Warning: Be careful when editing the registry. Incorrect changes can cause system instability. Stick precisely to these instructions.
  3. Navigate to the Key: In the left-hand pane of the Registry Editor, navigate to this specific location:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
    

    (Expand HKEY_LOCAL_MACHINE, then SYSTEM, CurrentControlSet, Control, and finally click on TimeZoneInformation).

  4. Create the DWORD Value:
    • In the right-hand pane (showing the values within TimeZoneInformation), right-click on an empty space.
    • Select New -> DWORD (32-bit) Value.
    • Crucial: Even if you are using 64-bit Windows, you must select DWORD (32-bit) Value.
    • Name this new value exactly:
      RealTimeIsUniversal
      
  5. Set the Value Data:
    • Double-click the RealTimeIsUniversal value you just created.
    • In the “Value data” box, type 1.
    • Ensure the “Base” is set to Hexadecimal (though it makes no difference for the value 1).
    • Click OK.
  6. Close Registry Editor.
  7. Reboot Your Computer: The change takes effect after a restart.

Use a Self-Signed SSL Certificate for Nginx Server

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Modify Your Nginx Server Block:

server {
    listen 443 ssl;
    server_name your_domain.com;

    ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

    location / {
        # Your proxy or root configurations
    }
}
sudo nginx -t
sudo systemctl reload nginx

 

Set Battery Charge Limit in Fedora

sudo nano /etc/systemd/system/battery-charge-threshold.service
[Unit]
Description=Set battery charge threshold to 60%
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now battery-charge-threshold.service