Linux Guides & Tips

This is a collection of guides and tips I've used/currently use.

Most of this was written with Manjaro Linux (KDE) in mind (Arch based distro) so keep that in mind when following the code (substitute pacman/yaourt for your package manager and change packages to the equivalent ones provided by your distro). Otherwise, this is pretty universal stuff.

Manjaro Build Script

This is my personal build script for Manjaro I run post-install

sudo sed -i 's/#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/' /etc/makepkg.conf
echo "Installing programs from main repos"
sudo pacman -S git python python-pip go audacity atom onlyoffice-desktopeditors vlc gimp gimp-help-en picard firejail bleachbit telegram-desktop pulseeffects calf zam-plugins rubberband mda.lv2 lsp-plugins playonlinux wine-mono wine_gecko devtools virt-manager qemu qemu-arch-extra ovmf vde2 ebtables dnsmasq bridge-utils openbsd-netcat spice-vdagent manjaro-settings-samba
sudo pip install click request
[ "$(echo $DESKTOP_SESSION)" == "kde" ] && sudo pacman -S elisa kdiff3 libappindicator-gtk3
echo "Installing programs from aur"
# Disable pgp checking when installing stuff from AUR
# export MAKEPKG="makepkg --skippgpcheck"
pamac build gitkraken gimp-plugin-registry slack-desktop epson-inkjet-printer-201308w pxz teamviewer
echo "Setting up teamviewer and WOL"
sudo systemctl enable teamviewerd
echo "Make sure screen lock is NOT set and bios setting is enabled"
nmcli c modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
sudo sed -i "s/WOL_DISABLE=.*/WOL_DISABLE=N/" /etc/default/tlp
echo "Setting up virt-manager stuff"
# Workaround needed for ovmf detection for now, see https://bugs.archlinux.org/task/64175
# Replace YOURUSERNAME with your own below
sudo sed -i -e "/^#nvram = \[/invram = \[\n   \"/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd\"\n\]" -e "s/#user =.*/user = \"YOURUSERNAME\"/" -e "s/#group =.*/group = \"users\"/" -e "s/^#nographics_allow_host_audio = 1/nographics_allow_host_audio = 1/" -e "s/^#vnc_allow_host_audio = 0/vnc_allow_host_audio = 0/" /etc/libvirt/qemu.conf
sudo sed 's#qemu/edk2-x86_64-code.fd#ovmf/x64/OVMF_CODE.fd#;s#qemu/edk2-i386-vars.fd#ovmf/x64/OVMF_VARS.fd#' < /usr/share/qemu/firmware/60-edk2-x86_64.json > /usr/share/qemu/firmware/10-ovmf-workaround.json
sudo usermod -G libvirt -a $(whoami)
sudo usermod -G kvm -a $(whoami)
sudo systemctl enable libvirtd.service
sudo systemctl start libvirtd.service
echo "Setting up PCI passthrough for PCI devices"
sudo sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"/GRUB_CMDLINE_LINUX_DEFAULT=\"intel_iommu=on iommu=pt /" /etc/default/grub
sudo update-grub
# Replace device ids with ones you want to pass through
sudo bash -c 'echo "options vfio-pci ids=1002:67df,1002:aaf0,1002:6811,1002:aab0,1b4b:9235" >> /etc/modprobe.d/vfio.conf'
sudo sed -i 's/^MODULES=(/MODULES=(vfio_pci vfio vfio_iommu_type1 vfio_virqfd /' /etc/mkinitcpio.conf
sudo mkinitcpio -P
echo "Installing android build tools"
git clone https://github.com/akhilnarang/scripts
cd scripts
bash setup/arch-manjaro.sh
# Replace git info below
git config --global user.name "YOURUSERNAME"
git config --global user.email "YOUREMAIL"
echo "Applying misc fixes"
sudo bash -c 'echo "vm.swappniess=1" >> /etc/sysctl.d/99-sysctl.conf'
sudo firecfg
#Firefox touchscreen scrolling fix
#[ -f /etc/security/pam_env.conf ] && sudo bash -c 'echo "MOZ_USE_XINPUT2 DEFAULT=1" >> /etc/security/pam_env.conf' || sudo bash -c 'echo "MOZ_USE_XINPUT2 DEFAULT=1" >> /usr/share/security/pam_env.conf'
#Btrfs Grub
sudo sed -i 's/GRUB_SAVEDEFAULT=true/GRUB_SAVEDEFAULT=false/' /etc/default/grub
sudo update-grub
#KDE Icon Scaling Fix & GTK App Scaling Fix
[ "$(echo $DESKTOP_SESSION)" == "kde" ] && { sudo sed -i 's/plasmashell/PLASMA_USE_QT_SCALING=1 plasmashell/g' /etc/xdg/autostart/org.kde.plasmashell.desktop; echo -e "GDK_SCALE=2\nGDK_DPI_SCALE=-1" >> ~/.pam_environment; }
#Pulseeffects profiles install
bash -c "$(curl -fsSL https://raw.githubusercontent.com/JackHack96/PulseEffects-Presets/master/install.sh)"
									

Tweaks

Some useful tweaks I use or have used at some point

  • SSD Tweaks:
    # Move trim from a weekly task to a daily one
    sudo mv -v /etc/cron.weekly/fstrim /etc/cron.daily
    
    # Decrease swappiness (so system favors using ram over swap more (0=keep in ram as much as possilble, 100=use swap as much as possible)
    sudo nano /etc/sysctl.conf
    # Add: 'vm.swappniess=1' at end of file
  • Disable IPv6 (Useful for OpenVPN):
    sudo nano /etc/sysctl.d/99-sysctl.conf
    # Copy/paste these to bottom of file:
    
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
    
    # Close file
    sudo sysctl -p
  • Sandbox Web Browser:
    # Install firejail package
    # Change web browser command so it has 'firejail ' in front of it
    # If having issues with sound:
    mkdir -p ~/.config/pulse
    cd ~/.config/pulse
    cp -v /etc/pulse/client.conf ~/.config/pulse
    echo "enable-shm = no" >> client.conf
    
    # Close any programs that have been firejailed
    # To confirm it's working, open firejailed program and type in terminal:
    firejail --tree
    
    # Note: Firejail blocks acccess to all folders/files in user directory except Downloads
    # This can be changed by modifiying corresponding file in /etc/firejail

Troubleshooting

These are applicable to all Arch based distros only (except the first one which is obviously for arch based distros using KDE desktop environment only)

  • If KDE System Monitor (KSysGuard) isn't working right (like graphs not showing up):
    # Replace 'username' with your username
    rm /home/username/.local/share/ksysguard/ProcessTable.sgrd
    rm /home/username/.local/share/ksysguard/SystemLoad2.sgrd
    rm /home/username/.config/ksysguardrc
  • If having issues with dolphin-root not installing due to packages being dependent on dolphin:
    sudo nano /var/lib/pacman/local/packagename/desc # Where packagename is the problem package
    # Change the 'DEPENDS' section from 'dolphin' to 'dolphin-root'
  • If having issues with updating due to dependencies (such as dolphin-plugins in this example), just ignore them:
    sudo pacman -Sdd dolphin-plugins

Microsoft Office 365 Wine Install Instructions

Wine version used for this was 3.7-1

This was pretty huge for me. WineHQ is the place to find this stuff by the way, I modified it slightly so it'd work for me (and added/changed regedits based on what Crossover did)

# Install needed components:
sudo pacman -Sy wine wine-mono wine_gecko winetricks samba smbclient libwbclient alsa-lib alsa-plugins gnutls libpng libpulse libglvnd libxcomposite libxinerama libxml2 lib32-alsa-lib lib32-alsa-plugins lib32-gnutls lib32-libpng lib32-libpulse lib32-libglvnd lib32-libxcomposite lib32-libxinerama lib32-libxml2 gconf gst-plugins-base gst-plugins-base-libs gst-plugins-good gstreamer lcms2 libcanberra libcanberra-pulse libva libva-intel-driver libva-vdpau-driver libvdpau libx11 libxmu libxrandr libxslt libxss libxt libxtst libxv mesa mesa-vdpau mpg123 p11-kit vulkan-intel lib32-gconf lib32-gst-plugins-base lib32-gst-plugins-base-libs lib32-gst-plugins-good lib32-gstreamer lib32-lcms2 lib32-libcanberra lib32-libcanberra-pulse lib32-libva lib32-libva-intel-driver lib32-libva-vdpau-driver lib32-libvdpau lib32-libx11 lib32-libxmu lib32-libxrandr lib32-libxslt lib32-libxss lib32-libxt lib32-libxtst lib32-libxv lib32-mesa lib32-mesa-vdpau lib32-mpg123 lib32-p11-kit lib32-vulkan-intel
yaourt -S lib32-nss-mdns

# Get installer from office365 in school email or whatever (will need to spoof browser user agent as windows)
# Note that only 32bit office is working with wine at the moment. Don't even bother with 64bit.
export WINEARCH=win32
export WINEPREFIX=~/.msoffice
wineboot -i
winetricks winecfg
# Change to Windows
winetricks corefonts
winetricks winecfg # Check for windows 7 again
winetricks dotnet20 gdiplus msxml6 riched20
winetricks regedit
# In [HKEY_CURRENT_USER\Software\Wine]:
# Make a Direct2D, Direct3D, and X11 Driver keys
# Make a new DWORD in Direct2D: max_version_factory=0
# Make a new DWORD in Direct3D: MaxVersionGL=30002
# Make a new String value in X11 Driver: ScreenDepth=32
winetricks winecfg
# Make sure these overrides are present: gdiplus (native), msxml6 (native,builtin), riched20 (native,builtin)
# Make sure it's still Windows 7
wine ~/Desktop/SetupFile.exe # Replace this with the full path to your setup exe file
# Installer won't exit automatically, will need to close manually in system monitor or whatever
cp ~/.msoffice/drive_c/Program\ Files/Common\ Files/Microsoft\ Shared/ClickToRun/{AppvIsvSubsystems32.dll,C2R32.dll} ~/.msoffice/drive_c/Program\ Files/Microsoft\ Office/root/Office16/
# In KDE, go to System Settings -> Window Management -> Window Rules, then import this kwinrule file to fix windows resizing issues
# To fix powerpoint hanging on open: force quit it in whatever task manager you have, then reopen it. It'll prompt for safe mode, say "Yes". Then go to File -> Options -> Addins -> Manage (at bottom), delete the onenote addin
                  

Misc Programs

These are install instructions and helpful tips for various programs

  • Thunderbird not showing all of your subfolders?
    Go to Preferences -> Account settings -> Server settings (for target email accounnt) -> Advanced - uncheck 'show only subscribed folders'
  • Wireguard: The future of VPNs:
    # Make an account with AzireVPN here
    # Install Wireguard - replace headers number with kernel number
    sudo pacman -S linux414-headers wireguard-dkms wireguard-tools # Replace the headers version with your kernel version
    curl -LO https://www.azirevpn.com/dl/azirevpn-wg.sh && chmod +x azirevpn-wg.sh && ./azirevpn-wg.sh
    
    # To start it:
    wq-quick up azirevpn-us1
    # To stop it:
    wq-quick down azirevpn-us1