IntroToLinux

3. Command Types and Discovery

Types of Commands:

1. Built-in Commands

2. External Commands

3. Aliases

4. Functions

Command Discovery:

# Check command type
type command_name
type cd          # cd is a shell builtin
type ls          # ls is /bin/ls
type ll          # ll is aliased to 'ls -l'

# Find command location
which command_name
which ls         # /bin/ls
which python3    # /usr/bin/python3

# Show all possible commands
type -a command_name
type -a echo     # Shows builtin and external versions

# ℹ️ Check if command exists
command -v command_name
if command -v git > /dev/null; then
    echo "Git is installed"
fi

Practical Examples:

# Explore your system
type bash
type cd
type ls
which ls
which grep
which python3

# Check for optional software
command -v docker && echo "Docker available"
command -v git && echo "Git available"
command -v python3 && echo "Python 3 available"

Next: → Aliases Creating Command Shortcuts
Previous: ← Special Characters And Echo
Lesson Home: ↑ Lesson 5: Echo, Alias & Operators Course Home: ⌂ Introduction to Linux