Skip to Content
DocsDevelopmentGit, SSH & Terminal Basics

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 -y

Verify the installation:

git --version

Configure 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 --list

Generate SSH Keys

SSH keys are used to securely connect to GitHub, GitLab, and other remote repositories without entering a password each time.

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_ed25519

Copy the Public Key

cat ~/.ssh/id_ed25519.pub

Copy the output and add it to GitHub (Settings > SSH and GPG keys) or your preferred platform.

Test the Connection

ssh -T git@github.com

If 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/config

Add 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_work

Terminal Basics: Bash

Ubuntu 26.04 uses Bash as the default shell. Here are common operations:

Common Keyboard Shortcuts

ShortcutFunction
Ctrl + AMove to beginning of line
Ctrl + EMove to end of line
Ctrl + RReverse search command history
Ctrl + LClear screen
Ctrl + CTerminate current command
TabAuto-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 ~/.bashrc

Switch to Zsh

Zsh provides more powerful auto-completion and a plugin system:

Install Zsh

sudo apt install zsh -y

Set 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)"

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-highlighting

Other 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.wezterm

Common 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-feature

Once you’ve mastered Git, SSH, and terminal basics, you’ll be well-prepared for your development work.

Last updated on