Ubuntu Command Line Guide: Essential Commands You Should Know

Piedalies.lv - 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

  1. pwd (Print Working Directory)

    • Usage: pwd
    • Description: Displays the path of the current working directory.
  2. 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).
  3. 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.
  4. mkdir (Make Directory)

    • Usage: mkdir [directory]
    • Description: Creates a new directory.
  5. rmdir (Remove Directory)

    • Usage: rmdir [directory]
    • Description: Removes an empty directory.
  6. touch (Create Empty File)

    • Usage: touch [filename]
    • Description: Creates a new, empty file or updates the timestamp of an existing file.
  7. rm (Remove)

    • Usage: rm [options] [file]
    • Description: Deletes files. Adding -r deletes directories and their contents recursively.
  8. cp (Copy)

    • Usage: cp [options] [source] [destination]
    • Description: Copies files and directories. Use -r for recursive copy.
  9. mv (Move)

    • Usage: mv [source] [destination]
    • Description: Moves or renames files and directories.
  10. cat (Concatenate)

    • Usage: cat [file]
    • Description: Displays the content of a file on the screen.

Intermediate Commands

  1. 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).
  2. 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).
  3. chown (Change Owner)

    • Usage: chown [owner][:[group]] [file]
    • Description: Changes the owner and/or group of a file or directory.
  4. find

    • Usage: find [directory] [options]
    • Description: Finds files and directories based on criteria like name, size, and modification time.
  5. wget (Web Get)

    • Usage: wget [options] [URL]
    • Description: Downloads files from the internet.
  6. curl (Client URL)

    • Usage: curl [options] [URL]
    • Description: Transfers data from or to a server, supporting various protocols.
  7. sudo (SuperUser DO)

    • Usage: sudo [command]
    • Description: Executes a command with superuser privileges, essential for commands that require administrative access.
  8. 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.
  9. nano/vim

    • Usage: nano [file], vim [file]
    • Description: Opens a text editor in the terminal to edit files.
  10. 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.