Skip to content

Instantly share code, notes, and snippets.

@ahasverus
Last active December 8, 2022 14:52
Show Gist options
  • Save ahasverus/9bde00ebdef04b63282ccf6913781702 to your computer and use it in GitHub Desktop.
Save ahasverus/9bde00ebdef04b63282ccf6913781702 to your computer and use it in GitHub Desktop.
Setup Ubuntu 20.04 on Lenovo X1 Carbon 7th Gen

Setup Ubuntu 22.04 on Lenovo X1 Carbon 7th Gen

SYSTEM SECURITY

Update System

sudo apt update && sudo apt upgrade -y
sudo apt autoremove -y && sudo apt autoclean

Enable Firewall

N.B. The package ufw is already installed under Ubuntu 22.04 but must enabled.

sudo ufw enable

Lock ROOT Account

N.B. Under Ubuntu 22.04, the root account is locked by default. But just in case...

sudo passwd -l root

Configure GRUB Menu

N.B. This configuration hides the GRUB menu during the startup. No more needed with Ubuntu 22.04.

# cd /etc/default
# sudo cp grub grub-OLD
# 
# sudo sed -re 's/^(GRUB_TIMEOUT=)10/\1"0"/' -i grub
# sudo sed -re 's/^(GRUB_TIMEOUT_STYLE=)hidden/\1"hidden"/' -i grub
# 
# sudo update-grub

MATERIAL SETUP

Create rc.local File

sudo -i

cat << EOF > /etc/rc.local
#! /bin/bash -e

EOF

exit

sudo chmod +x /etc/rc.local

Disable Bluetooth and WLAN on Startup

N.B. The package rfkill is already installed under Ubuntu 22.04.

sudo -i

cat << EOF >> /etc/rc.local
# Disable Bluetooth on Startup
rfkill block bluetooth

# Disable Wireless Network on Startup
rfkill block wlan

EOF

exit

Activate Speakers Bass

N.B. Not sure that improves the speakers.

sudo apt install alsa-tools

sudo -i

cat << EOF >> /etc/rc.local
# Activate Speakers Bass
hda-verb /dev/snd/hwC0D0 0x17 SET_CONNECT_SEL 1

exit 0
EOF

exit

Improve Battery Management

N.B. Not sure that is still necessary with Ubuntu 22.04.

sudo apt install tlp tlp-rdw acpi-call-dkms tp-smapi-dkms

UTILITARIES INSTALLATION

Installation

sudo apt install apt-transport-https build-essential curl evolution evolution-ews
sudo apt install ffmpeg git gnome-calendar htop imagemagick keepassxc 
sudo apt install pdftk qpdf rclone screen tree wget youtube-dl

Configure git

git config --global user.name "Nicolas Casajus"
git config --global user.email "nicolas.casajus@gmail.com"

git config --global init.defaultBranch "main"
git config --global pull.rebase "false"

# -> Copy Private Keys and change permissions
chmod 400 ~/.ssh/id_rsa

GNOME SHELL CUSTOMIZATION

Install Gnome Shell Extensions

sudo apt install gnome-shell-extensions
sudo apt install gnome-sushi
sudo apt install extension-manager

Gnome Addons

Install the following Gnome Shell addons:

  • ...

TERMINAL CUSTOMIZATION

Install ZSH and OhMyZsh

sudo apt install zsh
chsh -s $(which zsh)
sudo reboot

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Use Powerlevel10k ZSH Theme

mkdir ~/.fonts && cd ~/.fonts
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
fc-cache -f -v

# -> Terminal Preferences > Profiles > Text > Custom font > MesloLGS NF Regular

cd
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

sed -re 's/^(ZSH_THEME=)"robbyrussell"/\1"powerlevel10k\/powerlevel10k"/' -i ~/.zshrc
source ~/.zshrc

# -> Customize theme (Solarized Dark)

Add Alias

cat << EOF >> ~/.zshrc

# Alias
alias r='R'
alias ll='ls -alh'
alias ..='cd ..'
EOF

Add ZSH Plugins

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

sed -re 's/plugins=\(git\)/plugins=(\n  git\n  zsh-autosuggestions\n  zsh-syntax-highlighting\n)/' -i ~/.zshrc
source .zshrc

SOFTWARES INSTALLATION

Install Multimedia Apps

sudo apt update
sudo apt install calibre lollypop transmission vlc

Enable Calibre Dark Mode

sudo -i

cat << EOF > /etc/profile.d/calibre.sh
# Enable Calibre Dark Mode
export CALIBRE_USE_DARK_PALETTE=1
EOF

exit

Install R

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/'

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc

sudo apt update

sudo apt install libfreetype6-dev libpoppler-cpp-dev libmagick++-dev
sudo apt install libmagick++-dev libpoppler-cpp-dev libgmp3-dev
sudo apt install libgdal-dev libproj-dev libgeos-dev libudunits2-dev
sudo apt install libnode-dev libcairo2-dev libnetcdf-dev libssl-dev
sudo apt install libmpfrc++-dev libfftw3-bin libfftw3-dev libgsl-dev 
sudo apt install libharfbuzz-dev libfribidi-dev

sudo apt install r-base r-base-dev

Install RStudio

N.B. With Ubuntu 22.04, the official release doesn't work yet (libssl issue). Just install a Daily build from: https://dailies.rstudio.com/rstudio/spotted-wakerobin/desktop/jammy/.

Install LaTeX and Pandoc

sudo apt install pandoc
> install.packages("tinytex")
> tinytex::install_tinytex()

Install OpenVPN

sudo apt update
sudo apt install openvpn

wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
unzip ovpn.zip
rm -rf ovpn_udp
mv ovpn_tcp .ovpn
rm ovpn.zip

nano .credentials
chmod 400 .credentials

cd .ovpn
for country in *.ovpn; do
	sed -i 's:auth-user-pass:auth-user-pass /home/ahasverus/.credentials:' "$country";
done

sudo /etc/init.d/openvpn restart
sudo openvpn --config /home/ahasverus/.ovpn/fr620.nordvpn.com.tcp.ovpn --daemon --auth-nocache
killall openvpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment