Command Line Basics

The command line, or terminal, is a text-based interface in which users interact with a computer by typing commands. It’s a powerful tool for performing various tasks, file management, and system administration. Here are some basic command line operations:


  1. pwd (Print Working Directory):
  • Displays the current working directory (the directory you are currently in).
  1. ls (List):
  • Lists the contents of the current directory.
  1. cd (Change Directory):
  • Changes the current working directory.
   cd path/to/directory
  1. mkdir (Make Directory):
  • Creates a new directory.
   mkdir new_directory
  1. cp (Copy):
  • Copies files or directories.
   cp source_file destination
  1. mv (Move):
  • Moves files or directories. It can also be used for renaming.
   mv old_name new_name
  1. rm (Remove):
  • Deletes files or directories. Use with caution.
   rm file_name

File and Text Manipulation:

  1. touch (Create Empty File):
  • Creates an empty file or updates the access and modification time of a file.
   touch filename
  1. nano or vim (Text Editors):
  • Opens a text editor for creating or editing files.
   nano filename
  • To exit nano, press Ctrl + X, then follow the prompts to save changes.
  1. cat (Concatenate and Display):
    • Displays the content of a file.
    cat filename
  2. echo (Print to the Screen):
    • Prints text to the terminal.
    echo "Hello, World!"

System Information:

  1. whoami (Show Current User):
    • Displays the username of the currently logged-in user.
  2. date (Display Date and Time):
    • Shows the current date and time.
  3. cal (Display Calendar):
    • Displays a calendar for the current month.

Redirection and Pipes:

  1. > (Output Redirection):
    • Redirects the output of a command to a file, overwriting the file’s contents.
    command > file
  2. >> (Append Output):
    • Redirects the output of a command to a file, appending to the file.
    command >> file
  3. | (Pipe):
    • Takes the output of one command and uses it as input for another.
    command1 | command2

Help and Manual:

  1. man (Manual):
    • Displays the manual (help) for a command.
    man command
  2. --help (Command Help):
    • Displays help information for a command.
    command --help


  1. history (Command History):
    • Displays a list of previously executed commands.
  2. clear (Clear Screen):
    • Clears the terminal screen.
  3. chmod (Change Permissions):
    • Changes the permissions of a file or directory.
    chmod permissions file

These are just a few basic command line operations. The command line provides a powerful and efficient way to interact with a computer, especially for tasks related to file management, system administration, and development. As you become more familiar with the command line, you’ll discover additional commands and options to enhance your productivity.