Basic Commands

Basic Commands

These are the most fundamental Linux commands that every user should know. They form the foundation for interacting with the Linux system.

clear

Clears the terminal screen, giving you a clean workspace.

clear

Options:

man

Displays the manual pages for commands, providing detailed documentation.

man [section] command

Options:

Examples:

# View the manual for the ls command
man ls

# Search for commands related to "password"
man -k password

echo

Displays text or variable values to the terminal.

echo [options] [string]

Options:

Examples:

# Print a simple message
echo "Hello World"

# Print without a newline at the end
echo -n "No newline"

# Print with escape sequences interpreted
echo -e "Line 1\nLine 2"

date

Displays or sets the system date and time.

date [options] [+format]

Options:

Examples:

# Display current date and time
date

# Display date in a custom format
date "+%Y-%m-%d %H:%M:%S"

# Set the system date (requires root privileges)
sudo date -s "2025-04-10 12:00:00"

whoami

Displays the username of the current user.

whoami

exit

Exits the current shell or terminal session.

exit [n]

Where n is an optional exit code (0 means success).

history

Shows the command history for the current user.

history [options]

Options:

Examples:

# Show command history
history

# Show the last 10 commands
history 10

# Clear history
history -c

uname

Prints system information.

uname [options]

Options:

Examples:

# Show all system information
uname -a

# Show only the kernel version
uname -r

alias

Creates shortcuts for commands.

alias [name[=value]]

Examples:

# Create an alias for listing files
alias ll='ls -la'

# List all defined aliases
alias

help

Displays help for shell built-in commands.

help [command]

Examples:

# Get help for the cd command
help cd