The command line interface (CLI) is a vital tool for system administrators and developers working with Ubuntu servers. To help you navigate the myriad of tasks efficiently, the Ubuntu Server CLI Cheat Sheet 2024 provides a comprehensive list of commands, organized by functionality. Here’s a detailed breakdown of the cheat sheet’s contents, highlighting key commands and their use cases.
System Information and Management
System Information
uname -a: Displays detailed system information, including kernel version and architecture.hostnamectl: Retrieves the current hostname and associated metadata.lscpu: Lists CPU details such as cores, threads, and architecture.timedatectl status: Provides the system’s current time and timezone settings.
System Monitoring
topandhtop: Monitor active processes and system resource usage. Whiletopis pre-installed,htopoffers an interactive alternative.df -h: Check disk space usage in a human-readable format.free -m: View memory usage statistics in MB.
File Management
Basic Commands
ls: List directory contents.cp <source> <destination>: Copy files or directories.mv <source> <destination>: Move or rename files.rm <filename>: Delete a file.
Navigating Directories
pwd: Show the current directory.cd <directory>: Change to the specified directory.mkdir <dirname>: Create a new directory.
Permissions
chmod u+x <file>: Make a file executable by the owner.chown [user]:[group] <file>: Change file ownership.
Networking and Remote Access
Networking Basics
ip addr show: Display network interfaces and their IPs.ping <host>: Test connectivity to a host.
SSH and File Transfers
ssh <user@host>: Securely connect to a remote host.scp <source> <user@host>:<destination>: Securely copy files between machines.
Process and Job Management
Running Commands
[command] &: Run a command in the background.jobs: List background jobs.fg <job number>: Bring a job to the foreground.
Service Management
sudo systemctl start <service>: Start a service.sudo systemctl stop <service>: Stop a service.sudo systemctl status <service>: View the status of a service.
Package Management
APT Package Manager
sudo apt install <package>: Install software packages.sudo apt update && sudo apt upgrade: Update package lists and upgrade installed packages.
Snap Package Manager
snap find <package>: Search for Snap packages.sudo snap install <snap_name>: Install Snap packages.
Advanced Topics: LXD and Ubuntu Pro
LXD (Linux Containers)
LXD enables streamlined container and virtual machine management:
lxc init ubuntu:22.04 <container>: Create a new container.lxc start <instance>: Start an instance.
Ubuntu Pro
With Ubuntu Pro, extend security updates and compliance tooling:
sudo pro enable esm-infra: Enable Extended Security Maintenance for infrastructure.sudo pro enable livepatch: Apply kernel patches without rebooting.
Conclusion
This cheat sheet equips you with the essential commands for managing Ubuntu servers, from monitoring system resources to managing software packages and ensuring robust networking. Bookmark these commands or print the cheat sheet for quick reference—it’s a must-have for anyone looking to optimize their workflow in the Linux environment.