Installing .NET 6 on Ubuntu 22.04

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt update && sudo apt install -y wget
sudo apt update && sudo apt install -y wget
sudo apt update && sudo apt install -y wget
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo dpkg -i packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
rm packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo touch /etc/apt/preferences
sudo touch /etc/apt/preferences
sudo touch /etc/apt/preferences
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo nano /etc/apt/preferences
sudo nano /etc/apt/preferences
sudo nano /etc/apt/preferences

Paste :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
Package: * Pin: origin "packages.microsoft.com" Pin-Priority: 1001
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-6.0
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-6.0
sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dotnet --info
dotnet --info
dotnet --info

References
https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2204
https://github.com/dotnet/core/issues/7699

Install Latest Kernel in Ubuntu using Mainline

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo add-apt-repository ppa:cappelikan/ppa
sudo add-apt-repository ppa:cappelikan/ppa
sudo add-apt-repository ppa:cappelikan/ppa
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt install mainline
sudo apt install mainline
sudo apt install mainline

References
https://ubuntuhandbook.org/index.php/2020/08/mainline-install-latest-kernel-ubuntu-linux-mint/
https://github.com/pimlie/ubuntu-mainline-kernel.sh

Turn off Wireless power management permanently in Ubuntu 22.04

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

And change wifi.powersave to 2

or

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*
sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*
sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*

Possible values for the wifi.powersave field are:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
NM_SETTING_WIRELESS_POWERSAVE_ENABLE (3): enable powersave
NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave NM_SETTING_WIRELESS_POWERSAVE_ENABLE (3): enable powersave
NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
NM_SETTING_WIRELESS_POWERSAVE_IGNORE  (1): don't touch existing setting
NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
NM_SETTING_WIRELESS_POWERSAVE_ENABLE  (3): enable powersave

References
https://askubuntu.com/questions/1403773/22-04-wifi-keeps-disconnecting-for-a-few-seconds-frequently
https://unix.stackexchange.com/questions/269661/how-to-turn-off-wireless-power-management-permanently

Increase or Resize Swap Space on Ubuntu 22.04

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ls -lh /swapfile
ls -lh /swapfile
ls -lh /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo swapoff -a
sudo swapoff -a
sudo swapoff -a
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo fallocate -l 8G /swapfile
sudo fallocate -l 8G /swapfile
sudo fallocate -l 8G /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ls -lh /swapfile
ls -lh /swapfile
ls -lh /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo chmod 600 /swapfile
sudo chmod 600 /swapfile
sudo chmod 600 /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo mkswap /swapfile
sudo mkswap /swapfile
sudo mkswap /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo swapon /swapfile
sudo swapon /swapfile
sudo swapon /swapfile
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo swapon --show
sudo swapon --show
sudo swapon --show
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
free -h
free -h
free -h

References
https://devanswers.co/creating-swap-space-ubuntu-18-04/

Install Windows Subsystem for Linux (WSL) on Windows 11

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wsl --install
wsl --install
wsl --install
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wsl --list --online
wsl --list --online
wsl --list --online
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wsl --install -d Ubuntu
wsl --install -d Ubuntu
wsl --install -d Ubuntu
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wsl --update
wsl --update
wsl --update

References
https://pureinfotech.com/install-wsl-windows-11/

Compile Bash Script into Binary in Linux

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt install shc
sudo apt install shc
sudo apt install shc

Compile script file using shc

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
shc -f hello.sh
shc -f hello.sh
shc -f hello.sh

Check generated files

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ls -l hello*
-rw-rw-r-- 1 user user 29 Mar 14 07:37 hello.sh
-rwxrwxr-x 1 user user 14960 Mar 14 07:39 hello.sh.x
-rw-rw-r-- 1 user user 10047 Mar 14 07:39 hello.sh.x.c
ls -l hello* -rw-rw-r-- 1 user user 29 Mar 14 07:37 hello.sh -rwxrwxr-x 1 user user 14960 Mar 14 07:39 hello.sh.x -rw-rw-r-- 1 user user 10047 Mar 14 07:39 hello.sh.x.c
ls -l hello*
-rw-rw-r-- 1 user user    29 Mar 14 07:37 hello.sh
-rwxrwxr-x 1 user user 14960 Mar 14 07:39 hello.sh.x
-rw-rw-r-- 1 user user 10047 Mar 14 07:39 hello.sh.x.c

.sh is the original script.
sh.x is the compiled binary.
.sh.x.c is the C source code generated from the .sh file prior to compiling to .sh.x.

hello.sh.x permission is automatically set as executable

Rename executable

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mv hello.sh.x hello
mv hello.sh.x hello
mv hello.sh.x hello

Check file execution

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
./hello Alice
./hello Alice
./hello Alice

References
https://www.simplified.guide/bash/compile-script

Install Firefox from Mozilla on Ubuntu 22.04

Download Firefox from Firefox Download Page

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
tar xjf firefox-*.tar.bz2
tar xjf firefox-*.tar.bz2
tar xjf firefox-*.tar.bz2
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mv firefox /opt
mv firefox /opt
mv firefox /opt

Create a symlink to the Firefox executable:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ln -s /opt/firefox/firefox /usr/local/bin/firefox
ln -s /opt/firefox/firefox /usr/local/bin/firefox
ln -s /opt/firefox/firefox /usr/local/bin/firefox

Create a .desktop file for firefox :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
touch ~/.local/share/applications/firefox.desktop
# or
touch /usr/local/share/applications/firefox.desktop
touch ~/.local/share/applications/firefox.desktop # or touch /usr/local/share/applications/firefox.desktop
touch ~/.local/share/applications/firefox.desktop
# or
touch /usr/local/share/applications/firefox.desktop

and paste these lines there:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
[Desktop Entry] Version=1.0 Name=Firefox Web Browser Comment=Browse the World Wide Web GenericName=Web Browser Keywords=Internet;WWW;Browser;Web;Explorer Exec=firefox %u Terminal=false X-MultipleArgs=false Type=Application Icon=/opt/firefox/browser/chrome/icons/default/default128.png Categories=GNOME;GTK;Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall; StartupNotify=true
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true

Logout and login again

References
https://support.mozilla.org/en-US/kb/install-firefox-linux

No Writes for Read Timestamps to optimize SSD on Ubuntu

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo nano /etc/fstab
sudo nano /etc/fstab
sudo nano /etc/fstab

Edit the mounting options for your partitions by adding the text noatime and nodiratime to the lines defining your root (/) and other partitions if you have them (/home)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# / was on /dev/sda2 during installation
UUID=587e0dc5-2db1-4cd9-9792-a5459a7bcfd2 / ext4 noatime,nodiratime,errors=remount-ro 0 1
# /home was on /dev/sda3 during installation
UUID=2c919dc4-24de-474f-8da0-14c7e1240ab8 /home ext4 noatime,nodiratime,defaults 0 2
# / was on /dev/sda2 during installation UUID=587e0dc5-2db1-4cd9-9792-a5459a7bcfd2 / ext4 noatime,nodiratime,errors=remount-ro 0 1 # /home was on /dev/sda3 during installation UUID=2c919dc4-24de-474f-8da0-14c7e1240ab8 /home ext4 noatime,nodiratime,defaults 0 2
# / was on /dev/sda2 during installation
UUID=587e0dc5-2db1-4cd9-9792-a5459a7bcfd2 /               ext4    noatime,nodiratime,errors=remount-ro 0       1

# /home was on /dev/sda3 during installation
UUID=2c919dc4-24de-474f-8da0-14c7e1240ab8 /home           ext4    noatime,nodiratime,defaults        0       2

References
https://askubuntu.com/questions/1400/how-do-i-optimize-the-os-for-ssds

Enable TRIM For SSD in Ubuntu

make sure that the SSD in your computer supports TRIM

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo hdparm -I /dev/sda # or sdb
sudo hdparm -I /dev/sda # or sdb
sudo hdparm -I /dev/sda # or sdb

Find “Data Set Management TRIM supported”.

Clean up the root partition of the SSD

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo fstrim -v /
sudo fstrim -v /
sudo fstrim -v /

References
https://www.maketecheasier.com/enable-trim-for-ssd-in-ubuntu/

Disable Error Reporting in Ubuntu 22.04

Disable Apport at Boot

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo nano /etc/default/apport
sudo nano /etc/default/apport
sudo nano /etc/default/apport

In the apport file, lookup for a line that has the enabled value ‘1’ by default. Change this value to 0 so that the system does not start the apport service at boot.

Uninstall Apport

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get purge apport
sudo apt-get purge apport
sudo apt-get purge apport

References
https://vitux.com/how-to-disable-enable-automatic-error-reporting-in-ubuntu/