GO KALI FREE
IntermediateLinux

Linux Terminal Guide: Advanced Shell Skills for Professionals

Advanced Linux terminal techniques including shell customization, multiplexing, productivity tools, and scripting best practices.

#Linux#Terminal#Bash#Zsh#tmux#Shell Scripting

Choosing Your Shell

Bash is the default on most Linux distributions — reliable, widely available, and well-documented. Configuration file: ~/.bashrc.

Zsh offers significant improvements including better autocompletion, theme support, and plugin management. It is the default shell in Kali Linux and macOS. Configuration file: ~/.zshrc.

Fish provides user-friendly features out of the box including syntax highlighting and autosuggestions.

Shell Customization with Oh My Zsh

Oh My Zsh is a framework for managing Zsh configuration:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Popular themes: agnoster (clean informative prompt), powerlevel10k (highly customizable, fast), robbyrussell (simple default).

Essential plugins: git (aliases and completions), docker, sudo (double-tap Esc to add sudo), web-search, colorize.

Powerlevel10k

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

Run p10k configure for interactive setup.

Terminal Multiplexing with tmux

tmux allows running multiple terminal sessions in one window:

tmux new -s mysession    # Create new session
tmux attach -t mysession # Attach to session
tmux ls                  # List sessions

Pane management: Ctrl+B % (vertical split), Ctrl+B " (horizontal split), Ctrl+B arrow (navigate), Ctrl+B x (close pane).

Window management: Ctrl+B c (create), Ctrl+B n/p (next/previous), Ctrl+B w (list).

Advanced Text Processing

jq processes JSON data: curl api.example.com/data | jq '.[].name'

yq is the YAML equivalent for parsing YAML configuration files.

ripgrep (rg) is a faster alternative to grep: rg pattern /path/to/search

bat displays files with syntax highlighting and line numbers: bat filename.py

Network Tools Deep Dive

Netcat (nc)

nc -zv 192.168.1.1 1-1000    # Port scanning
nc -v 192.168.1.1 80          # Banner grabbing
nc -l -p 4444 > received_file # File receiver

Socat

More powerful than netcat:

socat TCP-LISTEN:8080,fork TCP:192.168.1.1:80  # Port forwarding

Productivity Enhancements

fzf provides interactive fuzzy search: vim **<TAB>

htop is an enhanced process viewer with tree view and mouse support.

bat replaces cat with syntax highlighting.

Shell Scripting Best Practices

#!/bin/bash
set -euo pipefail
IFS=
#039;\n\t'
  • `set -e`: Exit on error
  • `set -u`: Error on undefined variables
  • `set -o pipefail`: Pipe failures propagate
  • Debug with bash -x script.sh or set -x within scripts.

    Mastering the terminal is an ongoing journey. Start by customizing your shell environment, then gradually incorporate advanced tools and automation into your workflow.

    Frequently Asked Questions

    What is the difference between Bash and Zsh?

    Bash is the default shell on most Linux distributions, while Zsh offers better autocompletion, themes, and plugin support. Zsh is the default in Kali Linux and macOS. Oh My Zsh makes Zsh configuration easy with hundreds of community plugins.

    What is tmux and why should I use it?

    tmux is a terminal multiplexer that lets you run multiple terminal sessions in one window. You can split panes, detach sessions, and keep processes running after disconnecting from SSH. It is essential for managing long-running scans and remote work.

    How do I customize my terminal prompt?

    Use Oh My Zsh with themes like Powerlevel10k for a highly customizable prompt. Edit your ~/.zshrc or ~/.bashrc file to set the ZSH_THEME variable. Powerlevel10k offers an interactive configuration wizard with `p10k configure`.

    What is fzf and how does it improve productivity?

    fzf is a fuzzy finder that provides interactive search for files, commands, and history. Use it with `vim **<TAB>` to fuzzy-search files, or press Ctrl+R to fuzzy-search command history. It integrates with [command-line tools](/learn/command-line-essentials) for faster navigation.

    What is the difference between netcat and socat?

    Netcat (nc) handles basic TCP/UDP connections for port scanning and file transfer. Socat is more powerful, supporting port forwarding, SSL/TLS connections, and bidirectional data streams. Use socat when you need advanced networking beyond what netcat provides.

    What does set -euo pipefail do in Bash scripts?

    set -e exits on any command failure, set -u errors on undefined variables, and set -o pipefail propagates failures through pipelines. Together they prevent silent errors in scripts. Always include this at the top of your [Bash scripts](/learn/command-line-essentials) for safer automation.

    How do I install Oh My Zsh?

    Run the install command from ohmyz.sh: `sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)". It automatically detects your shell, backs up existing configuration, and sets up Zsh with sensible defaults. Then customize via ~/.zshrc.

    What is ripgrep and why is it better than grep?

    ripgrep (rg) is a faster alternative to grep that recursively searches files while respecting .gitignore rules by default. It is optimized for speed with parallel searching and requires no flags for common operations. Use it as your default text search tool for [security analysis](/learn/linux-terminal-guide).

    How do I split panes in tmux?

    Press Ctrl+B then % for vertical split or Ctrl+B then " for horizontal split. Navigate between panes with Ctrl+B and arrow keys. Resize panes by holding Ctrl+B while pressing arrow keys. These shortcuts are essential for multitasking during [penetration testing](/learn/ethical-hacking-fundamentals).

    What is bat and why should I use it instead of cat?

    bat is a cat replacement with syntax highlighting, line numbers, and Git integration. It automatically detects file types and applies appropriate highlighting. Install it with `sudo apt install bat` and use `bat file.py` for a much more readable file view.