Update Kernel arguments for better performance in Ubuntu 24.04

Here’s how you can apply these kernel parameters in Ubuntu 24.04:

  1. Edit GRUB Configuration File:

    Open the GRUB configuration file in a text editor. For example, you can use nano:

    sudo nano /etc/default/grub
    
  2. Add Kernel Parameters:

    Find the line that starts with GRUB_CMDLINE_LINUX_DEFAULT and add your parameters to the list. It should look something like this:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off mem_sleep_default=s2idle nvidia-drm.modeset=1"
    

    Ensure that all parameters are enclosed within the same set of quotes.

  3. Update GRUB:

    After saving the changes, you need to update the GRUB configuration:

    sudo update-grub
    
  4. Reboot:

    Finally, reboot your system to apply the changes:

    sudo reboot
    

This will apply the desired kernel parameters on all boot entries.

Install Android ADB on Ubuntu Linux

To install Android ADB (Android Debug Bridge) on Ubuntu, you can follow these steps:

Identify the Vendor ID:

Connect your Android device to your computer and run the following command to identify the vendor ID:

lsusb

Look for the line that corresponds to your Android device. The vendor ID is the first part of the ID after ID, for example, 18d1 for Google.

Update Your Package List: Open your terminal and update the package list to ensure you have the latest information on the newest versions of packages and their dependencies.

sudo apt update

Install ADB: You can install the ADB package using the following command:

sudo apt install android-tools-adb

Verify Installation: After installation, you can verify that ADB is installed correctly by checking its version:

adb version

Add Your User to the Plugdev Group (Optional): This step ensures that you can use ADB without root permissions. It’s especially useful when working with devices.

sudo usermod -aG plugdev $USER

Then, log out and log back in to apply the changes.

Set Up Udev Rules (Optional): To communicate with your Android device over USB, you might need to set up udev rules. Create a new udev rules file:

sudo nano /etc/udev/rules.d/51-android.rules

Add the following line to the file, replacing xxxx with your device’s USB vendor ID (you can find a list of these IDs online or in the documentation for your device):

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

Save and close the file, then reload the udev rules:

sudo udevadm control --reload-rules

Now, you should have ADB installed and configured on your Ubuntu system. You can connect your Android device and start using ADB commands.

Install Android ADB on Fedora Linux

sudo dnf install android-tools

Create a plugdev group (if it doesn’t already exist) and add the user to it:

sudo groupadd plugdev
sudo usermod -aG plugdev $LOGNAME

Log out and log back in for the group change to take effect. Use the id command to verify that you are in the plugdev group:

id

Identify the Vendor ID:

Connect your Android device to your computer and run the following command to identify the vendor ID:

lsusb

Look for the line that corresponds to your Android device. The vendor ID is the first part of the ID after ID, for example, 18d1 for Google.

Create a udev Rule:

Create a file for the udev rule:

sudo nano /etc/udev/rules.d/51-android.rules

Add the Following Content:

In the file, add a rule to grant the necessary permissions. Replace YOUR-VENDOR-ID with your device’s vendor ID. Here’s an example rule:

SUBSYSTEM=="usb", ATTR{idVendor}=="YOUR-VENDOR-ID", MODE="0666", GROUP="plugdev"

For example, if the vendor ID is 18d1 (Google):

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

Change File Permissions:

Change the permissions of the file to make it readable:

sudo chmod a+r /etc/udev/rules.d/51-android.rules

Reload udev rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

Restart your machine.

Check ADB Devices:

Verify that your device is recognized correctly:

adb devices

References
https://developer.android.com/studio/run/device

Using Data Recovery Tools in Linux

Stop Using the Drive

Immediately stop using the drive to prevent further data overwriting.

Identify the Overwritten Part

Determine how much data the ISO has overwritten. Typically, writing an ISO will overwrite the beginning of the drive, including the partition table and some initial sectors.

Use Data Recovery Tools

You can try using data recovery tools that work well on Linux:

  1. TestDisk: This tool can help recover lost partitions and make non-booting disks bootable again. It can also recover deleted files from FAT, NTFS, and ext2 filesystems.
  2. PhotoRec: This companion tool to TestDisk specializes in recovering lost files, including videos, documents, and archives from hard disks, CD-ROMs, and lost pictures from memory cards.
  3. ddrescue: A data recovery tool specifically designed to recover data from damaged disks. It can create a disk image and then work on the image to recover data.

Steps to Recover Data

  1. Install Recovery Tools:
    sudo apt-get install testdisk photorec gddrescue
    
  2. Create a Disk Image: It’s safer to work on a disk image rather than directly on the hard drive.
    sudo ddrescue /dev/sdX /path/to/image.img /path/to/logfile.log
    

    Replace /dev/sdX with your external hard drive’s identifier.

  3. Run TestDisk:
    sudo testdisk /path/to/image.img
    

    Follow the on-screen instructions to analyze and recover lost partitions.

  4. Run PhotoRec:
    sudo photorec /path/to/image.img
    

    This will guide you through recovering individual files.

Change Display gamma on Linux Mint

To change the display gamma on Linux Mint, you can use the xgamma utility. Follow these steps:

Step 1: Install xgamma (if not already installed)

Open a terminal and install xgamma if it is not already installed:

sudo apt update
sudo apt install x11-xserver-utils

Step 2: Adjust the Gamma Value

You can adjust the gamma value using the xgamma command. The gamma value can be set for red, green, and blue channels individually or together. The default gamma value is usually 1.0. Adjusting this value will change the brightness of the display.

To set gamma for all channels equally:

xgamma -gamma 2.2

Step 3: Make the Changes Permanent

The changes made with xgamma will be reset after a reboot. To make them permanent, you can add the xgamma command to your startup applications or add it to your ~/.xprofile file.

Adding to Startup Applications:

  1. Open the Menu and search for “Startup Applications”.
  2. Click “Add” to create a new startup program.
  3. Enter a name (e.g., “Set Gamma”), and in the command field, enter the xgamma command you used (e.g., xgamma -gamma 1.2).
  4. Click “Add” to save the entry.

Adding to ~/.xprofile:

  1. Open a terminal.
  2. Edit the ~/.xprofile file (create it if it does not exist):
    nano ~/.xprofile
    
  3. Add the xgamma command you used (e.g., xgamma -gamma 1.2).
  4. Save the file and exit the editor (in nano, you can do this by pressing Ctrl+X, then Y, and Enter).

Now, the gamma settings should be applied every time you log in.

Step 4: Verify the Changes

To verify the current gamma settings, simply run xgamma without any arguments:

xgamma

This will display the current gamma settings for red, green, and blue channels.

By following these steps, you should be able to adjust and maintain your desired display gamma settings on Linux Mint.

Disable CPU mitigations on Linux Mint

To disable mitigations on Linux Mint, you need to edit the GRUB configuration file and add a kernel parameter. Here are the steps to do that:

  1. Open Terminal: You can open the terminal by searching for it in the application menu or by pressing Ctrl + Alt + T.
  2. Edit GRUB Configuration:
    sudo nano /etc/default/grub
    
  3. Modify the GRUB_CMDLINE_LINUX_DEFAULT Line: Find the line that starts with GRUB_CMDLINE_LINUX_DEFAULT. It usually looks something like this:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    

    Add mitigations=off to this line. After editing, it should look like this:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off"
    
  4. Update GRUB: Save the file and exit the editor (in nano, you can do this by pressing Ctrl + X, then Y, and Enter). Then update GRUB with the following command:
    sudo update-grub
    
  5. Reboot: Reboot your system for the changes to take effect:
    sudo reboot
    

After rebooting, the mitigations should be disabled. You can verify this by checking the kernel command line:

cat /proc/cmdline

You should see mitigations=off in the output.

Optimize Intel WiFi Driver Settings in Linux

# Disable 802.11n to potentially improve stability
options iwlwifi 11n_disable=1

# Disable hardware encryption to offload encryption to the CPU
options iwlwifi swcrypto=0

# Disable Bluetooth coexistence to potentially improve WiFi performance
options iwlwifi bt_coex_active=0

# Disable power saving features to improve performance at the cost of higher power consumption
options iwlwifi power_save=0

# Disable Unscheduled Automatic Power Save Delivery (U-APSD)
options iwlwifi uapsd_disable=1

# Set power scheme to maximum performance
options iwlmvm power_scheme=1

# Enable antenna aggregation to potentially improve WiFi performance
options iwlwifi 11n_disable=8

To apply these settings, you would typically place them in a configuration file under /etc/modprobe.d/. For example, you could create a file called iwlwifi.conf:

sudo nano /etc/modprobe.d/iwlwifi.conf

Then, paste the configuration options into this file and save it.

Finally, to apply these changes, you will need to reload the iwlwifi module:

sudo modprobe -r iwlwifi
sudo modprobe iwlwifi

Or, you can simply reboot your system for the changes to take effect.

Set Battery Charge Limit in Ubuntu

ls /sys/class/power_supply/
ls /sys/class/power_supply/BAT0
sudo sh -c "echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold"
cat /sys/class/power_supply/BAT0/status

Create Battery Charge Threshold Service

sudo nano /etc/systemd/system/battery-charge-end-threshold.service
[Unit]
Description=Set Battery Charge Maximum Limit
After=multi-user.target
StartLimitBurst=0

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

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

References
https://ubuntuhandbook.org/index.php/2024/02/limit-battery-charge-ubuntu/

Fedora 40 Post Install

Making dnf a little faster

sudo nano /etc/dnf/dnf.conf
max_parallel_downloads=8

Firmware

sudo fwupdmgr get-devices 
sudo fwupdmgr refresh --force 
sudo fwupdmgr get-updates 
sudo fwupdmgr update

Media Codecs

sudo dnf groupupdate 'core' 'multimedia' 'sound-and-video' --setopt='install_weak_deps=False' --exclude='PackageKit-gstreamer-plugin' --allowerasing && sync
sudo dnf swap 'ffmpeg-free' 'ffmpeg' --allowerasing
sudo dnf install gstreamer1-plugins-{bad-\*,good-\*,base} gstreamer1-plugin-openh264 gstreamer1-libav --exclude=gstreamer1-plugins-bad-free-devel ffmpeg gstreamer-ffmpeg
sudo dnf install lame\* --exclude=lame-devel
sudo dnf group upgrade --with-optional Multimedia

H/W Video Acceleration

sudo dnf install ffmpeg ffmpeg-libs libva libva-utils
sudo dnf swap libva-intel-media-driver intel-media-driver --allowerasing

Set Hostname

hostnamectl set-hostname YOUR_HOSTNAME

Disable Mitigations

sudo grubby --update-kernel=ALL --args="mitigations=off"

Modern Standby

sudo grubby --update-kernel=ALL --args="mem_sleep_default=s2idle"

Enable nvidia-modeset

sudo grubby --update-kernel=ALL --args="nvidia-drm.modeset=1"

Disable NetworkManager-wait-online.service

sudo systemctl disable NetworkManager-wait-online.service

Disable SELinux

sudo grubby --update-kernel ALL --args selinux=0
sudo nano /etc/selinux/config
SELINUX=disabled

References
https://github.com/devangshekhawat/Fedora-40-Post-Install-Guide