Ubuntu Command Line Guide: Essential Commands You Should Know
Navigating the Ubuntu Command Line Interface (CLI) is a foundational skill for anyone using this operating system, especially for system administration, programming, and software management. This comprehensive guide will introduce you to essential basic and intermediate commands that will help you effectively control and manage your Ubuntu system through the terminal.
Introduction to the Terminal
The terminal in Ubuntu, also known as the command line or shell, is a powerful tool that allows users to interact with the system by entering commands. You can open the terminal by pressing Ctrl+Alt+T or by searching for 'Terminal' in your dashboard.
Basic Commands
pwd (Print Working Directory)
- Usage: pwd
- Description: Displays the path of the current working directory.
ls (List)
- Usage: ls [options] [directory]
- Description: Lists all files and directories in the current directory. Common options include -l (long listing format), -a (all files, including hidden files), and -h (human-readable sizes).
cd (Change Directory)
- Usage: cd [directory]
- Description: Changes the current directory. cd .. moves one directory up, while cd or cd ~ returns to the home directory.
mkdir (Make Directory)
- Usage: mkdir [directory]
- Description: Creates a new directory.
rmdir (Remove Directory)
- Usage: rmdir [directory]
- Description: Removes an empty directory.
touch (Create Empty File)
- Usage: touch [filename]
- Description: Creates a new, empty file or updates the timestamp of an existing file.
rm (Remove)
- Usage: rm [options] [file]
- Description: Deletes files. Adding -r deletes directories and their contents recursively.
cp (Copy)
- Usage: cp [options] [source] [destination]
- Description: Copies files and directories. Use -r for recursive copy.
mv (Move)
- Usage: mv [source] [destination]
- Description: Moves or renames files and directories.
cat (Concatenate)
- Usage: cat [file]
- Description: Displays the content of a file on the screen.
Intermediate Commands
grep (Global Regular Expression Print)
- Usage: grep [options] [pattern] [file]
- Description: Searches for patterns within files. Useful options include -i (ignore case) and -r (recursive search).
chmod (Change Mode)
- Usage: chmod [permissions] [file]
- Description: Changes the file permissions. Permissions can be numeric (e.g., 755) or symbolic (e.g., u+x).
chown (Change Owner)
- Usage: chown [owner][:[group]] [file]
- Description: Changes the owner and/or group of a file or directory.
find
- Usage: find [directory] [options]
- Description: Finds files and directories based on criteria like name, size, and modification time.
wget (Web Get)
- Usage: wget [options] [URL]
- Description: Downloads files from the internet.
curl (Client URL)
- Usage: curl [options] [URL]
- Description: Transfers data from or to a server, supporting various protocols.
sudo (SuperUser DO)
- Usage: sudo [command]
- Description: Executes a command with superuser privileges, essential for commands that require administrative access.
apt-get/apt (Advanced Package Tool)
- Usage: sudo apt-get update; sudo apt-get install [package]
- Description: Used for managing packages on Ubuntu. apt is a newer, more user-friendly version.
nano/vim
- Usage: nano [file], vim [file]
- Description: Opens a text editor in the terminal to edit files.
man (Manual)
- Usage: man [command]
- Description: Displays the manual page for commands, providing detailed information about its usage.
Conclusion
Mastering these commands will greatly enhance your ability to work efficiently with Ubuntu. Regular practice and usage of these commands can help you become proficient in managing your system entirely via the CLI. Remember, the man command is your friend for detailed documentation of any command you wish to learn more about.