Git, SSH & Terminal Basics
This article covers how to set up a Git version control environment, configure SSH keys, and use the terminal on Ubuntu 26.04.
Install Git
Ubuntu 26.04’s default repository includes Git. Install it directly with apt:
sudo apt update
sudo apt install git -yVerify the installation:
git --versionConfigure Git User Information
Before using Git for the first time, set your username and email. This information is recorded in every commit:
git config --global user.name "Your Username"
git config --global user.email "your@email.com"Recommended global settings:
# Set default branch name to main
git config --global init.defaultBranch main
# Set default editor
git config --global core.editor "vim"
# Enable colored output
git config --global color.ui auto
# View all settings
git config --global --listGenerate SSH Keys
SSH keys are used to securely connect to GitHub, GitLab, and other remote repositories without entering a password each time.
Generate an Ed25519 Key (Recommended)
ssh-keygen -t ed25519 -C "your@email.com"Follow the prompts. The default save path is ~/.ssh/id_ed25519. Setting a passphrase is recommended for enhanced security.
Start the SSH Agent and Add Your Key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy the Public Key
cat ~/.ssh/id_ed25519.pubCopy the output and add it to GitHub (Settings > SSH and GPG keys) or your preferred platform.
Test the Connection
ssh -T git@github.comIf configured correctly, you’ll see a welcome message.
Managing Multiple SSH Keys
If you have multiple Git accounts (e.g., work and personal), manage them through the SSH config file:
vim ~/.ssh/configAdd the following:
# Personal GitHub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
# Work GitLab
Host gitlab.company.com
HostName gitlab.company.com
User git
IdentityFile ~/.ssh/id_ed25519_workTerminal Basics: Bash
Ubuntu 26.04 uses Bash as the default shell. Here are common operations:
Common Keyboard Shortcuts
| Shortcut | Function |
|---|---|
Ctrl + A | Move to beginning of line |
Ctrl + E | Move to end of line |
Ctrl + R | Reverse search command history |
Ctrl + L | Clear screen |
Ctrl + C | Terminate current command |
Tab | Auto-complete |
Customize Bash Configuration
Edit ~/.bashrc to add aliases and custom settings:
# Common aliases
alias ll='ls -alF'
alias la='ls -A'
alias gs='git status'
alias gp='git push'
# Apply changes
source ~/.bashrcSwitch to Zsh
Zsh provides more powerful auto-completion and a plugin system:
Install Zsh
sudo apt install zsh -ySet as Default Shell
chsh -s $(which zsh)Log out and back in for the change to take effect.
Install Oh My Zsh
Oh My Zsh is a popular Zsh configuration framework:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Recommended Plugins
Edit ~/.zshrc and modify the plugins list:
plugins=(git z sudo extract zsh-autosuggestions zsh-syntax-highlighting)Install third-party plugins:
# Auto-suggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightingOther Terminal Emulator Recommendations
Ubuntu 26.04’s default terminal works well, but you can also try:
# Install Alacritty (GPU-accelerated terminal)
sudo snap install alacritty --classic
# Install Kitty
sudo apt install kitty -y
# Install Wezterm
flatpak install flathub org.wezfurlong.weztermCommon Git Workflows
# Clone a repository
git clone git@github.com:username/repo.git
# Create and switch to a branch
git checkout -b feature/new-feature
# Add, commit, push
git add .
git commit -m "feat: add new feature"
git push origin feature/new-feature
# Merge a branch
git checkout main
git merge feature/new-featureOnce you’ve mastered Git, SSH, and terminal basics, you’ll be well-prepared for your development work.