Skip to content

Instantly share code, notes, and snippets.

@tur1ngb0x
Last active February 15, 2023 09:01
Show Gist options
  • Save tur1ngb0x/c010a7d60643a3ee7e0ea0f5f4c4e8b4 to your computer and use it in GitHub Desktop.
Save tur1ngb0x/c010a7d60643a3ee7e0ea0f5f4c4e8b4 to your computer and use it in GitHub Desktop.
third-party-tools
#!/usr/bin/env bash
RPL='key <CAPS> \{ repeat=no, type\[group1\]=\"ALPHABETIC\", symbols\[group1\]=\[ Caps_Lock, Caps_Lock \],actions\[group1\]=\[LockMods\(modifiers=Lock\),Private\(type=3,data\[0\]=1,data\[1\]=3,data\[2\]=3\) \] \}'
rm -fv /tmp/keyboardmap
xkbcomp -xkb "${DISPLAY}" /tmp/keyboardmap
sed -i "s/key <CAPS>[^;]*/${RPL}/" /tmp/keyboardmap
xkbcomp /tmp/keyboardmap "${DISPLAY}"
rm -fv /tmp/keyboardmap
#!/usr/bin/env bash
cat << EOF
RAM:
EOF
ram_used=$(free -mltw | awk 'FNR == 2 {print $3}')
ram_avail=$(free -mltw | awk 'FNR == 2 {print $8}')
ram_total=$(free -mltw | awk 'FNR == 2 {print $2}')
echo -e "used\t${ram_used}MB"
echo -e "avail\t${ram_avail}MB"
echo -e "total\t${ram_total}MB"
cat << EOF
SWAP:
EOF
swp_total=$(free -mltw | awk 'FNR == 5 {print $2}')
swp_used=$(free -mltw | awk 'FNR == 5 {print $3}')
swp_free=$(free -mltw | awk 'FNR == 5 {print $4}')
echo -e "used\t${swp_used}MB"
echo -e "free\t${swp_free}MB"
echo -e "total\t${swp_total}MB"
cat << EOF
PACKAGES:
EOF
[[ -f /usr/bin/dpkg ]] && pkgs_dpkg="$(dpkg --get-selections | wc -l)" && printf "dpkg\t${pkgs_dpkg}\n"
[[ -f /usr/bin/dnf ]] && pkgs_dnf="$(dpkg --get-selections | wc -l)" && printf "dnf\t${pkgs_dpkg}\n"
[[ -f /usr/bin/snap ]] && pkgs_snap="$(snap list --all | wc -l)" && printf "snap\t${pkgs_snap}\n"
[[ -f /usr/bin/flatpak ]] && pkgs_flatpak="$(flatpak list | wc -l)" && printf "flatpak\t${pkgs_flatpak}\n"
#!/usr/bin/env bash
fc-list --format="%{family[0]}\n" | grep -i 'nerd' | sort
fc-list : family | grep -i 'nerd' | cut -f1 -d"," | sort
#!/usr/bin/env bash
sudo apt-get install libsdl-pango-dev
python3 -m venv ~/git-sim
source ~/git-sim/bin/activate
pip install manim
pip install git-sim
#!/usr/bin/env bash
wget -4O /tmp/input-mono.zip 'https://input.djr.com/build/?fontSelection=whole&accept=I+do'
unzip -jo /tmp/input-mono.zip -d /tmp/input-mono
rm -frv ~/.local/share/fonts/input-mono
mkdir -pv ~/.local/share/fonts/input-mono
find /tmp/input-mono -iname "InputMono-*" -exec cp -fv -t ~/.local/share/fonts/input-mono {} \;
fc-cache -rv
#!/usr/bin/env bash
# refresh sources
sudo apt-get update
# install requirements
sudo apt-get install build-essential libx11-dev libxft-dev libxinerama-dev stterm suckless-tools wget
# create build folder
mkdir -pv ~/src/dwm
# download archive
wget -O /tmp/dwm.tar.gz http://dl.suckless.org/dwm/dwm-6.4.tar.gz
# extract archive
tar -vxz --strip-components 1 -f /tmp/dwm.tar.gz -C ~/src/dwm
# fix permissions
sudo chown -Rv $USER:$USER ~/src/dwm
# compile source
sudo make clean install -C ~/src/dwm
# desktop entry
printf "[Desktop Entry]\nName=DWM\nExec=dwm\nType=XSession\n" | sudo tee /usr/share/xsessions/dwm.desktop
#!/usr/bin/env bash
# load zram module at startup
sudo mkdir -pv /etc/modules-load.d
printf 'zram\n' | sudo tee /etc/modules-load.d/zram.conf
# set zram device limit to 1
sudo mkdir -pv /etc/modprobe.d
printf 'options zram num_devices=1\n' | sudo tee /etc/modprobe.d/zram.conf
# create zram udev rule with 4096M ~ 4GB size
mkdir -pv /etc/udev/rules.d
printf 'KERNEL=="zram0", ATTR{disksize}="4096M", ATTR{comp_algorithm}="lz4", RUN="/usr/sbin/mkswap /dev/zram0", TAG+="systemd"\n' | sudo tee /etc/udev/rules.d/99-zram.rules
# add zram entry to fstab
printf '\n\n/dev/zram0 none swap defaults,pri=100 0 0\n\n' | sudo tee -a /etc/fstab
# reboot machine
# reboot
# check zram
# cat /proc/swaps

APT

$ cat << EOF | sudo tee /etc/apt/apt.conf.d/99-betterapt
// Disable translations
Acquire::IndexTargets::deb::Contents-deb::DefaultEnabled false;
Acquire::Languages none;
// Disable phased updates
APT::Get::Never-Include-Phased-Updates true;
// Disable recommended packages
APT::Install-Recommends false;
// Disable sugggested packages
APT::Install-Suggests false;
EOF

$ cat << EOF
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu $(lsb_release -cs) partner
EOF

Filesystem

$ mount | sed 's/ on / /' | sed 's/ type / /'| column -t

$ sed '/^$/d;/^#/d' /etc/fstab | column -t

$ sudo mount -o remount,uid=1000,gid=1000,rw /mnt/linuxdata

GNOME

$ gsettings set org.gnome.shell.extensions.screenshot clipboard-action 'set-image-data'

$ gsettings set org.gnome.shell.extensions.screenshot save-screenshot true

$ gsettings set org.gnome.shell.extensions.screenshot save-location '/home/tur1ngb0x/Pictures/Screenshots'

$ gsettings set org.gnome.shell.extensions.screenshot filename-template '{Y}{m}{d}_{H}{M}{S}_{w}x{h}'

$ gsettings set org.gnome.shell.extensions.screenshot shortcut-select-area ['<Shift><Super>s']

GRUB2

$ sed '/^$/d;/^#/d' /etc/default/grub | sort

$ cat << EOF
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 net.ifnames=0 nosgx nowatchdog pci=noaer"
GRUB_DISABLE_OS_PROBER="true"
GRUB_DISABLE_RECOVERY="true"
GRUB_DISABLE_SUBMENU="true"
GRUB_DISTRIBUTOR="Ubuntu"
GRUB_GFXPAYLOAD_LINUX="keep"
GRUB_TERMINAL_OUTPUT="console"
GRUB_TIMEOUT_STYLE="menu"
GRUB_TIMEOUT="10"
EOF

Hostname

$ hostnamectl set-hostname starlabs

$ sudoedit /etc/hosts

Locale

$ localectl set-locale en_IN.UTF-8

$ sudo locale-gen en_IN.UTF-8

$ sudo update-locale en_IN.UTF-8

Network

$ sudo rm -fv /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

$ printf '[connection]\nwifi.powersave = 2\n' | sudo tee /etc/NetworkManager/conf.d/99-wifi-powersave-off.conf

$ sudo systemctl restart NetworkManager.service

PopOS

$ sudo cp -fv /etc/apt/sources.list.d/pop-os-apps.sources{,.bak}

$ sudo sed -i 's/Enabled: yes/Enabled: no/' /etc/apt/sources.list.d/pop-os-apps.sources

$ sudo kernelstub -vv -o 'ipv6.disable=1 net.ifnames=0 nosgx nowatchdog pci=noaer'

$ flatpak install org.gtk.Gtk3theme.Pop{,-light,-dark}

$ gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu:minimize,maximize,close'

$ gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'LEFT'

$ gsettings set org.gnome.shell.extensions.dash-to-dock dock-alignment 'START'

$ gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size '32'

$ gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize-or-previews'

$ gsettings set org.gnome.shell.extensions.dash-to-dock background-color '#211F1F'

$ gsettings set org.gnome.shell favorite-apps '["pop-cosmic-applications.desktop", "org.gnome.Nautilus.desktop", "google-chrome.desktop", "com.alacritty.Alacritty.desktop"]'

Startup Apps

$ sudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop

Swappiness

$ printf 'vm.swappiness = 10\n' | sudo tee /etc/sysctl.d/99-swappiness.conf

Time

$ timedatectl set-timezone Asia/Kolkata

$ timedatectl set-ntp true

$ timedatectl set-local-rtc true

$ timedatectl --adjust-system-clock

$ timedatectl show

ZRAM

$ sudo mkdir -pv /etc/modules-load.d

$ printf 'zram\n' | sudo tee /etc/modules-load.d/zram.conf

$ sudo mkdir -pv /etc/modprobe.d

$ printf 'options zram num_devices=1\n' | sudo tee /etc/modprobe.d/zram.conf

$ sudo mkdir -pv /etc/udev/rules.d

$ printf 'KERNEL=="zram0", ATTR{disksize}="4096M", RUN="/usr/sbin/mkswap /dev/zram0", TAG+="systemd"\n' | sudo tee /etc/udev/rules.d/99-zram.rules

$ printf '\n\n/dev/zram0 none swap defaults 0 0\n\n' | sudo tee -a /etc/fstab

$ printf 'vm.swappiness = 200\n' | sudo tee /etc/sysctl.d/99-zram.conf

EOF
#!/usr/bin/env bash
# color
magenta="\033[1;35m"
green="\033[1;32m"
white="\033[1;37m"
blue="\033[1;34m"
red="\033[1;31m"
black="\033[1;40;30m"
yellow="\033[1;33m"
cyan="\033[1;36m"
reset="\033[0m"
bgyellow="\033[1;43;33m"
bgwhite="\033[1;47;37m"
c0=${reset}
c1=${magenta}
c2=${green}
c3=${white}
c4=${blue}
c5=${red}
c6=${yellow}
c7=${cyan}
c8=${black}
c9=${bgyellow}
c10=${bgwhite}
get_distro() { awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release; }
get_kernel() { uname -r; }
get_pkgs() { dpkg --get-selections | wc -l; }
get_shell() { echo ${SHELL}; }
get_display() { echo ${XDG_SESSION_TYPE}; }
get_uptime() { uptime -p | sed 's/up //g;s/,//g'; }
get_ram_total() { free -mt | awk 'FNR == 2 {print $2}'; }
get_ram_used() { free -mt | awk 'FNR == 2 {print $3}'; }
get_swap_total() { free -mt | awk 'FNR == 3 {print $2}'; }
get_swap_used() { free -mt | awk 'FNR == 3 {print $3}'; }
get_disk_used() { df -h --output=used / | awk 'FNR == 2 {print $1}'; }
get_disk_total() { df -h --output=size / | awk 'FNR == 2 {print $1}'; }
printf "${red}Distro\t\t${reset}: $(get_distro)\n"
printf "${yellow}Kernel\t\t${reset}: $(get_kernel)\n"
printf "${green}Packages\t${reset}: $(get_pkgs)\n"
printf "${cyan}Shell\t\t${reset}: $(get_shell)\n"
printf "${blue}Uptime\t\t${reset}: $(get_uptime)\n"
printf "${magenta}RAM\t\t${reset}: $(get_ram_used)M/$(get_ram_total)M\n"
#printf "${red}Swap\t\t${reset}: $(get_swap_used)M/$(get_swap_total)M\n"
printf "${yellow}Disk\t\t${reset}: $(get_disk_used)/$(get_disk_total)\n"
#printf "${green}Display\t\t${reset}: $(get_display)\n"
#!/usr/bin/env bash
echo() { printf '\n\n\n\n\n\n\n%s\n' "${1}"; }
echo '* Removing legacy intel driver...'
sudo apt-get purge -y xserver-xorg-video-intel
sudo pacman -Rns xf86-video-intel
sudo rm -fv /etc/X11/xorg.conf.d/20-intel.conf
sudo rm -fv /etc/X11/xorg.conf.d/20-nvidia.conf
sudo rm -fv /usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf
echo '* Removing nvidia drivers...'
sudo apt-get purge -y ~nnvidia
sudo pacman -Rns nvidia nvidia-lts
echo '* Disabling gpu manager service...'
sudo systemctl disable gpu-manager.service
echo '* Blacklisting nvidia modules via modprobe...'
sudo mkdir -p /etc/modprobe.d
cat << EOF | sudo tee /etc/modprobe.d/novideo.conf
alias nouveau off
alias nvidia off
alias nvidia_drm off
alias nvidia_modeset off
alias nvidia_uvm off
blacklist nouveau
blacklist nvidia
blacklist nvidia_drm
blacklist nvidia_modeset
blacklist nvidia_uvm
EOF
echo '* Removing nvidia devices via udev...'
sudo mkdir -p /etc/udev/rules.d
cat << EOF | sudo tee /etc/udev/rules.d/novideo.rules
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
EOF
echo '* Regenerating initramfs...'
sudo update-initramfs -u -k all || sudo dracut --force --regenerate-all || sudo mkinitcpio -P
#!/usr/bin/env bash
curl --proto '=https' --tlsv1.2 -sSf 'https://sh.rustup.rs' | sh -s -- -y --no-modify-path
#!/usr/bin/env bash
wget -4O /tmp/starship.sh https://raw.githubusercontent.com/starship/starship/master/install/install.sh
sudo sh /tmp/starship.sh -y

Terminal Emulator

  • It is called "emulator" as it emulates the legacy mechanical terminals.
  • It is a program/application window that is loaded on the screen.
  • Official apps: gnome-terminal, xfce4-terminal, konsole, xterm, uxterm, etc.
  • Third party apps: alacritty, kitty, terminator, tilix, st, etc.
  • You can install and use different terminal apps on the same OS.

Shell

  • Program which interprets commands typed by the user and shows the result.
  • Type echo $0 echo ${SHELL} in terminal to check your current shell.
  • You can install and use different shell programs on the same OS.
  • Type "builtin" and press tab in terminal to view builtin commands into the bash shell.
  • Every shell has system-wide and user-specific configuration files which can be customized.
  • Standard Shells: sh, bash.
  • Custom Shells: zsh, fish, oil.
  • A shell can be either login or non-login.
  • Login shell is started when a user logs into the system.
  • Non-login shell is started when a application/program launches a shell.
  • A shell can be either interactive or non-interacrive.
  • Interactive shell is where user interacts directly eg. typing commands in TTY or terminal.
  • Non-interactive shell is where user interacts indirectly eg. a script containing commands.

Command Line Interface (CLI)

  • Interface where you interact with computers using lines of text instead of using GUI.
  • It is generally done using a TTY interface or via terminal app.
  • Updating system using CLI: $ sudo apt-get update && sudo apt-get dist-upgrade
  • Launch nemo file manager using CLI: $ nemo

Prompt

  • The text that you see when you open terminal.
  • By default it should show [username]@[hostname][directory][:][prompt sign]
  • Username : The name of the current user logged in.
  • Hostname : The name of the computer user logged into.
  • Directory : The path the user is currently in. "~" is the home directory of the current user.
  • Prompt Sign : It shows "$" for non-root user and "#" for root user.
  • Example: galileo@physics:~$
  • User "galileo" is current logged into machine "physics" and is currently inside "home" directory
  • Example: antoine@chemistry:/home/Downloads$
  • User "antoine" is current logged into machine "chemistry" and is currently inside "/home/Downloads" directory
  • Example: root@linux:/usr/bin#
  • User "root" is current logged into machine "linux" and is currently inside "/usr/bin." directory
  • You can customize your prompt to add features such as date, time, git status, exit status, newline, custom prompt sign, etc.
<!--UEFI Boot-->
<os>
<type arch="x86_64" machine="q35">hvm</type>
<loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE_4M.fd</loader>
<boot dev="hd"/>
</os>
<!--Video Settings-->
<video>
<model type="virtio" heads="1" primary="yes">
<acceleration accel3d="no"/>
<resolution x="1920" y="1080"/>
</model>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
</video>
#!/usr/bin/env bash
rm -frv ~/VSCode-linux-x64
wget -4O /tmp/vscode.tar.gz 'https://code.visualstudio.com/sha/download?build=stable&os=linux-x64'
mkdir -pv ~/vscode
tar -f /tmp/vscode.tar.gz -xvz --strip-components=1 -C ~/vscode
cat << EOF | tee ~/.local/share/applications/code.desktop
[Desktop Entry]
Type=Application
Name=Visual Studio Code
Exec=/home/${USER}/vscode/bin/code --disable-gpu %F
Icon=/home/${USER}/vscode/resources/app/resources/linux/code.png
Comment=Code Editing. Redefined.
Categories=Development;
Keywords=code;vscode;
MimeType=text/plain;inode/directory;
EOF
mkdir -pv ~/.local/bin
ln -fsv ~/vscode/bin/code ~/.local/bin/code
mkdir -pv ~/.local/share/bash-completion/completions
ln -fsv ~/vscode/resources/completions/bash/code ~/.local/share/bash-completion/completions/code
@echo off
title windows-post-install.cmd
color 07
pause
:: browsers
powershell winget install --source winget --id Google.Chrome
powershell winget install --source winget --id Mozilla.Firefox
:: files
powershell winget install --source winget --id 7zip.7zip
powershell winget install --source winget --id voidtools.Everything
:: media
powershell winget install --source winget --id VideoLAN.VLC
powershell winget install --source winget --id DuongDieuPhap.ImageGlass
:: utilities
powershell winget install --source winget --id xanderfrangos.twinkletray
powershell winget install --source winget --id File-New-Project.EarTrumpet
powershell winget install --source winget --id Twilio.Authy
powershell winget install --source winget --id ProtonTechnologies.ProtonVPN
powershell winget install --source winget --id Bitwarden.Bitwarden
:: development
powershell winget install --source winget --id Microsoft.WindowsTerminal
powershell winget install --source winget --id Microsoft.PowerShell
powershell winget install --source winget --id Microsoft.VisualStudioCode
powershell winget install --source winget --id Git.Git
:: gaming
powershell winget install --source winget --id JeffreyPfau.mGBA
powershell winget install --source winget --id Valve.Steam
powershell winget install --source winget --id EpicGames.EpicGamesLauncher
:: directx
powershell invoke-webrequest -uri "https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe" -outfile "$HOME\Desktop\directx.exe"
powershell invoke-expression -command "$HOME\Desktop\directx.exe"
:: vcredist
powershell invoke-webrequest -uri 'https://github.com/abbodi1406/vcredist/releases/download/v0.62.0/VisualCppRedist_AIO_x86_x64_62.zip' -outfile "$HOME\AppData\Local\Temp\vcredist.zip"
powershell expand-archive -path "$HOME\AppData\Local\Temp\vcredist.zip" -DestinationPath "$HOME\Desktop"
powershell invoke-expression -command "$HOME\Desktop\VisualCppRedist_AIO_x86_x64.exe"
:: hostname
powershell rename-computer a5
:: hibernation
powershell powercfg /hibernate off
:: defender
powershell add-mppreference -exclusionpath "$HOME"
:: ssd
powershell optimize-volume -retrim -verbose -driveletter C
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment