Debian Linux Initial Setup Guide
November 12, 2023
Whenever I buy a computer or have to re-install the operating system, I find myself gravitating towards Debian-based Linux distributions for the operating system. In the recent past, this has included Ubuntu, Raspberry Pi OS, and Pop!_OS. I have to run through very similar initial steps to get started with all of these, so itβs about time to document them!
Update the computer! β¬
Run the command: sudo apt-get update && sudo apt-get upgrade
This will check for updates and install them.
Add firewall and disable unnecessary services π‘οΈ
Install ufw (uncomplicated firewall): sudo apt install ufw
For Ubuntu devices, remove the Apache web server: sudo apt purge apache2
Setup remote access π
I have 2 use cases for machines - headless servers, and daily drivers PCs that I need the graphical user interface for. Setup varies slightly for the different use cases.
- Install Tailscale VPN: https://tailscale.com/download
- Install SSH (for headless systems)
sudo apt install openssh-server- installs the SSH serversudo systemctl start ssh- start the SSH serversudo systemctl enable ssh- enable SSH on computer boot
- Install fail2ban SSH intrusion software, using default settings
sudo apt install fail2ban- install the softwaresudo systemctl enable fail2ban- enable fail2ban on computer bootsudo systemctl start fail2ban- start the fail2ban service
- Setup key-based SSH login
- On any client devices, generate SSH keys using
ssh-keygenand copy the public key to the server usingssh-copy-id - Disable root login and password login in the SSH configuration file
/etc/ssh/sshd_config- Set:
PasswordAuthentication no - Set:
PermitRootLogin no - Save changes
sudo systemctl restart ssh- restart the SSH service to apply changes
- Set:
Install dev tools π οΈ
- Git: version control tool
sudo apt install git- If using GitHub repositories:
- setup fine-grained Git access tokens, for scoped access to private Git information
- setup signed commits
- net-tools: utilities for managing network, including
ifconfigto get network adapter informationsudo apt install net-tools
- Neovim: a more feature rich version of Vim, which is a terminal text editor
sudo apt-get install neovim
- Docker: containerization tool, which I use to run many services on my network
- Installation instructions: https://docs.docker.com/engine/install/
Setup user session scripts π
Add the following to the ~/.bash_profile file:
# Quickly navigate to Git repository directory
alias repo='cd ~/repos'
# Quickly clear the screen input, using the Windows command
alias cls='clear'
# Checkout the main branch and pull
alias main='git checkout main && git pull'
# Set my terminal prompt, so it has Git branch information and looks consistent across devices
export PS1='\n\[\e[1;37m\]\[\e[1;32m\]\u\[\e[0;39m\]@\[\e[1;36m\]\h\[\e[0;39m\]:\[\e[1;33m\]\w\[\e[0;39m\]\[\e[1;35m\]$(__git_ps1 " (%s)")\[\e[0;39m\]\[\e[1;37m\]\[\e[0;39m\]\n$ '
# Simplify the computer update process with an "update" command
alias update='sudo apt update && sudo apt upgrade'
Disable Ubuntu crash reporting and telemetry πΆοΈ
Run the following commands:
sudo apt purge -y apport
sudo apt remove -y popularity-contest
sudo apt autoremove -y
Setup computer backups π
The methods for backing up your machine can widely vary here. My usual go-to is running syncthing with Docker to keep important files backed up with a storage server.
Other π
For headed systems: set keyboard shortcuts! Ideas for shortcuts to add usually include:
- opening applications menu, search, workspaces
- play, pause, next song, previous song
- mute microphone