Linux Pi
Updated: January 14, 2024
converting this document to nixos, then will be deleted :/
Table of Contents
NEW UBUNTU PI4 SETUP
- Flash with BalenaEtcher
- Default user & password: ubuntu
FIRST LOGIN
- If IP/MAC are in known_hosts => remove old key
- Set new password when prompted
- Set new name of machine
sudo vim /etc/hostname
- Set /etc/hosts to include 127.0.1.1 for hostname so it can respond by hostname (restart)
- Login with new creds & perform
sudo apt update && sudo apt upgrade -y
- Remove news (ad) set to 0 in /etc/default/motd-news
- More motd adjustment
sudo chmod -x 10-help-text
- All motd can be disabled per user
touch $HOME/.hushlogin
CREATE STATIC IP
For Ubuntu Servers (best option)
# first disable cloud
sudo vim /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
network: {config: disabled}
# edit netplan file
sudo vim /etc/netplan/50-cloud-init.yaml
network:
ethernets:
eth0:
dhcp4: no
addresses:
- 10.0.18.10/24
gateway4: 10.0.18.1
nameservers:
addresses: [9.9.9.9, 8.8.8.8]
match:
driver: bcmgenet smsc95xx lan78xx
optional: true
set-name: eth0
version: 2
# make it so
sudo netplan apply
# check that it worked
ip addr show dev eth0
NOT the best option
sudo vim /etc/dhcpcd.conf
and add:
interface eth0
static ip_address=10.0.18.20/24
static routers=10.0.18.1
static domain_name_servers=9.9.9.9 8.8.8.8
CREATE USERS
- Add user
sudo adduser username
=> prompt password creation. - Add to admin privileges
sudo usermod -aG sudo username
- Logout and back in with new username (works proceed to next)
- Remove default user
sudo deluser --remove-home ubuntu
SET TIMEZONE
- Check current systems timezone
timedatectl
- Find you zone in the list
timedatectl list-timezones
=>q
to exit - Then set ex.
sudo timedatectl set-timezone America/New_York
- Run
timedateclt
to verify
ENABLE CONTAINERS
sudo vim /boot/cmdline.txt
cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
INSTALL CLI TOOLS
sudo apt install zsh git cowsay fortune inxi apt-transport-https ca-certificates curl software-properties-common
MAKE IT FANCY
- Go to https://ohmyz.sh/#install & run either curl or wget
- Say
y
to switch to this shell - Run
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- Run
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- Copy this .zshrc to ~ or just run:
curl -o ~/.zshrc "https://gitlab.com/api/v4/projects/12002459/repository/files/zsh%2F.zshrc/raw?ref=linux"
- Vim Settings
curl -o ~/.vimrc "https://gitlab.com/api/v4/projects/12002459/repository/files/vim%2F.vimrc/raw?ref=master"
SETUP SSH
Ideally for server machines we will only need to put pub keys on for access. Also need to set privleges for local access only.
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@host
SETUP GIT
# set username
git config --global user.name "user"
# set email
git config --global user.email "email"