Debian Linux Tutorial
Collection of snippets to help you getting started with Debian Linux
```md
# Disable root user
create admin user
```sh
/sbin/useradd -m -s /usr/bin/bash admin
/sbin/usermod -aG sudo admin
passwd admin
```
disable root login
```sh /etc/passwd
root:x:0:0:root:/root:/sbin/nologin
```
# Setup apt
remove cdrom line from /etc/apt/sources.list
```sh
apt update
apt upgrade
```
# apt
## Setup all debian apt repos
### preferences
to downgrade to a specific release use 1001 as the Pin-Priority.
```/etc/apt/preferences.d/testing.pref
Package: *
Pin: release a=testing
Pin-Priority: 900
```
```/etc/apt/preferences.d/stable.pref
Package: *
Pin: release a=stable
Pin-Priority: -10
```
```/etc/apt/preferences.d/unstable.pref
Package: *
Pin: release a=unstable
Pin-Priority: -20
```
### list
Setup debian stable, change bullseye for current stable version, or use stable for rolling release
```/etc/apt/sources.list.d/stable.list
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb-src http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
```
Setup debian testing, change bookworm for current next-stable version, or use testing for rolling release
```/etc/apt/sources.list.d/testing.list
deb http://deb.debian.org/debian/ bookworm main contrib non-free
deb-src http://deb.debian.org/debian/ bookworm main contrib non-free
```
Setup debian unstable
```/etc/apt/sources.list.d/unstable.list
deb http://deb.debian.org/debian/ unstable main contrib non-free
deb-src http://deb.debian.org/debian/ unstable main contrib non-free
```
comment everything out in /etc/apt/sources.list
### Refresh repos
```sh
sudo apt update
sudo apt full-upgrade
/sbin/reboot
```
# Install software
install latest firmware, drivers and kernel
```sh
#apt install intel-microcode # optional intel microcode
#apt install amd64-microcode # optional amd microcode
apt install firmware-linux-nonfree
apt install linux-image-generic
#apt install nvidia-driver # optional nvidia driver
#apt install libnvoptix1 # optional nvidia optix
#apt install nvidia-cuda-dev nvidia-cuda-toolkit # optional nvidia cuda
#apt install firmware-iwlwifi # optional intel wifi
#apt install firmware-realtek # optional realtek wifi
/sbin/reboot
```
install gnome
```sh
apt install task-gnome-desktop
/sbin/reboot
```
install openbox
```
apt install openbox
```
install XFCE
```sh
apt install task-xfce-desktop
/sbin/reboot
#xfconf-query -c xfwm4 -p /general/use_compositing -s false # disable compositor
#xfconf-query -c xfwm4 -p /general/use_compositing -s true # enable compositor
```
install cursor theme, apply in Tweaks > Apperance > Cursor > Breeze_cursors
```sh
apt install breeze-cursor-theme
```
install system utils
```sh
apt install htop curl wget lshw git nmap python3-full neofetch virt-manager build-essential cmake dnsutils
```
install applications
```sh
apt install chromium firefox-esr keepassxc
```
install regular firefox
```sh
apt install -t unstable firefox
```
fix firefox high refreshrate
- about:config:
- layers.acceleration.force = True
# install vs code
```sh
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/microsoft-archive-keyring.gpg
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
apt install apt-transport-https
apt update
apt install code
```
## Setup vs code
- Extensions
- hediet.vscode-drawio
- streetsidesoftware.code-spell-checker
- rust-lang.rust-analyzer
- vadimcn.vscode-lldb
- dbaeumer.vscode-eslint
- ms-python.python
- vscodevim.vim
- ms-dotnettools.csharp
# Install Rust
install rust with rustup
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
configure cargo path in fish
```~/.config/fish/config.fish
export PATH="$HOME/.cargo/bin:$PATH"
```
install rust-analyzer
```sh
rustup component add rust-analyzer
```
symlink rust-analyzer
```sh
sudo ln -s $(rustup which rust-analyzer ) /usr/local/bin/rust-analyzer
```
update rust toolchain
```sh
rustup update
```
# cargo clippy
## Default
```sh
cargo clippy --all-targets --all-features
```
## CI
```sh
cargo clippy --all-targets --all-features -- -Dwarnings
```
## Through
```sh
cargo +nightly clippy --all-targets --all-features -- -Wclippy::pedantic -Aclippy::too-many-lines -Aclippy::default_trait_access -Aclippy::must-use-candidate -Aclippy::doc_markdown -Aclippy::manual_assert -Aclippy::redundant-closure-for-method-calls
```
# cargo fmt
## Default
```sh
cargo +nightly fmt --all
```
# Setup git
```sh
git config --global user.email "${YOUR_EMAIL}"
git config --global user.name "${YOUR_NAME}"
git config --global credential.helper 'cache --timeout=86400'
```
# Install fish
```sh
sudo apt install fish
chsh -s $(which fish)
```
relog to change default shell, and open new terminal and run the command, which should print /usr/bin/fish
```sh
echo $SHELL
```
## Install fisher, fish package / plugin manager
```sh
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
```
## Install z, fuzzy directory navigation
```sh
fisher install jethrokuan/z
```
## Configure fish
```~/.config/fish/config.fish
if status is-interactive
# Commands to run in interactive sessions can go here
end
set fish_greeting
fish_add_path ~/.local/bin
fish_add_path ~/.cargo/bin
export HELIX_RUNTIME="/home/user/pro/github/helix/runtime"
if type -q exa
alias ll "exa -l -g --icons"
end
starship init fish | source
fnm env --use-on-cd | source
```
## Cheatsheet
Navigate to previous and next directories
```fish
ALT+LeftArrow
ALT+RightArrow
```
or use command
```fish
prevd
nextd
```
Prepend / rerun last command with sudo
```fish
ALT+S
```
Execute inline sh / shell scripts
```fish
sh -c 'ps aux | awk \'{sum+=$6} END {print sum / 1024}\''
```
# Install zsh
install and change default shell to zsh
```sh
sudo apt install zsh
chsh -s $(which zsh)
```
relog to change default shell, and open new terminal and run the command, which should print /usr/bin/zsh
```sh
echo $SHELL
```
install ohmyzsh
```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```
install fish style plugins
```sh
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-history-substring-search $ZSH_CUSTOM/plugins/zsh-history-substring-search
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
```
add plugins
```~/.zshrc
plugins = (git zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting)
```
# install starship
```sh
cargo install starship --locked
```
## configure
```~/.config/starship.toml
format = """
\\[$time\\] - \
$username@\
$hostname:\
$directory\n\
\\$
"""
add_newline = false
[username]
show_always = true
format = '$user'
[hostname]
ssh_only = false
format = "$hostname"
[directory]
format = "$path"
truncation_length = 8
truncate_to_repo = false
truncation_symbol = "…/"
[time]
disabled = false
format = '$time'
time_format = "%H:%M:%S"
```
## enable in fish
```~/.config/fish/config.fish
starship init fish | source
```
## enable in bash
```~/.bashrc
eval "$(starship init bash)"
```
## enable in zsh
```~/.zshrc
eval "$(starship init zsh)"
```
# Install fnm
https://github.com/Schniz/fnm
```sh
cargo install fnm --locked
```
## enable in fish
```~/.config/fish/config.fish
fnm env --use-on-cd | source
```
## enable in bash
```~/.bashrc
eval "$(fnm env --use-on-cd)"
```
## enable in zsh
```~/.zshrc
eval "$(fnm env --use-on-cd)"
```
## install node version 14 and 16
```sh
fnm install 16.14
fnm install 14.20
```
# Next.js disable telemetry
```sh
npx next telemetry disable
```
# Install CascadiaCode
# Install Alacritty
install alacritty
```sh
sudo apt install alacritty
```
alacritty config
```~/.config/alacritty/alacritty.yml
window:
dimensions:
columns: 104
lines: 28
font:
normal:
family: CaskaydiaCove Nerd Font
size: 12.0
cursor:
style:
shape: Beam
blinking: On
colors:
primary:
background: '#1e1e1e'
foreground: '#ffffff'
normal:
black: '#232627'
red: '#ed1515'
green: '#11d116'
yellow: '#f67400'
blue: '#1d99f3'
magenta: '#9b59b6'
cyan: '#1abc9c'
white: '#fcfcfc'
bright:
black: '#7f8c8d'
red: '#c0392b'
green: '#1cdc9a'
yellow: '#fdbc4b'
blue: '#3daee9'
magenta: '#8e44ad'
cyan: '#16a085'
white: '#ffffff'
dim:
black: '#31363b'
red: '#783228'
green: '#17a262'
yellow: '#b65619'
blue: '#1b668f'
magenta: '#614a73'
cyan: '#186c60'
white: '#63686d'
```
Set Alacritty as default terminal emulator
```sh
sudo update-alternatives --config x-terminal-emulator
```
# Install exa, ls alternative
```sh
sudo apt install exa
```
## setup fish alias
```~/.config/fish/config.fish
if type -q exa
alias ll "exa -l -g --icons"
end
```
# Install dotnet, .NET, csharp, C#, mono and OmniSharp
https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian
```sh
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-7.0
sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt -t stable-buster install mono-devel
```
install vscode exteinsion ms-dotnettools.csharp
# Install Unity
https://gigi.nullneuron.net/gigilabs/using-visual-studio-code-with-unity3d-on-linux/
```sh
sudo sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
wget -qO - https://hub.unity3d.com/linux/keys/public | sudo apt-key add -
apt update
apt -t stable install unityhub
```
# Install KXStudio Zyn-Fusion zynsubaddfx sfizz
```sh
# Update software sources
sudo apt-get update
# Install required dependencies if needed
sudo apt-get install apt-transport-https gpgv wget
# Download package file
wget https://launchpad.net/~kxstudio-debian/+archive/kxstudio/+files/kxstudio-repos_11.1.0_all.deb
# Install it
sudo dpkg -i kxstudio-repos_11.1.0_all.deb
sudo apt -t bionic install zynaddsubfx fabla calf-plugins
echo 'deb http://download.opensuse.org/repositories/home:/sfztools:/sfizz/Debian_Testing/ /' | sudo tee /etc/apt/sources.list.d/home:sfztools:sfizz.list
curl -fsSL https://download.opensuse.org/repositories/home:sfztools:sfizz/Debian_Testing/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_sfztools_sfizz.gpg > /dev/null
sudo apt update
sudo apt install sfizz
```
# Utility
clear apt cache
```sh
apt clean && apt autoclean
```
clear logs
```sh
sudo truncate -s 0 /var/log/*log
```
```