Post

The Linux Terminal / Command Line

The Linux Terminal / Command Line

Here’s a concise guide covering the basics of The Linux Terminal / Command Line and the topics you listed:


1. 🖥️ The Linux Terminal / Command Line

🔓 Opening the Terminal

  • GUI Desktop (e.g., GNOME, XFCE):

    • Press Ctrl + Alt + T or search “Terminal” in your applications menu.
  • TTY Console (CLI only systems):

    • Use Ctrl + Alt + F1 to F6 to switch to a terminal session.

2. ⚙️ Terminal Settings

Terminal settings depend on the emulator you’re using (e.g., GNOME Terminal, Kitty, Alacritty):

  • Font / Color scheme: Usually in Preferences → Appearance.
  • Scrollback / History Size: Preferences → Scrolling.
  • Shell configuration file: Typically ~/.bashrc or ~/.zshrc.

3. 🔁 Common Terminal Commands

CommandDescription
bashStarts a new Bash shell session.
echoPrints text or variables: echo $HOME.
envShows current environment variables.
export VAR=valueSets environment variables: export PATH=$PATH:/new/path.
pwdPrints current working directory.
setShows or sets shell options and variables.
unsetRemoves shell variables: unset VAR.
man commandShows manual for a command: man ls.
uname -aDisplays system information.
historyLists previously run commands.
cat ~/.bash_historyShows command history from file.

4. 🎨 Customizing the Shell Prompt & Environment

  • PS1 is the variable that defines your prompt:

    1
    
    export PS1="\u@\h:\w\$ "
    
    • \u – Username
    • \h – Hostname
    • \w – Working directory
    • $ – Dollar sign (or # for root)
  • Example: Colorful Prompt

    1
    
    export PS1="\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ "
    
  • To make permanent, add to ~/.bashrc.


5. ⚡ Creating Aliases

  • Temporarily create an alias:

    1
    
    alias ll='ls -alF'
    
  • Permanently add to ~/.bashrc or ~/.bash_aliases:

    1
    2
    
    echo "alias update='sudo pacman -Syu'" >> ~/.bashrc
    source ~/.bashrc
    

This post is licensed under CC BY 4.0 by the author.