Top Unix/Linux Commands

Start your journey into Unix with our beginner's guide to basic command line operations. Learn essential Unix commands, navigation, file management, and more
E
Edtoks3:28 min read

Table of contents

Unix commands are the fundamental building blocks of interacting with the Unix-like operating system. These commands are issued through a command-line interface (CLI) or terminal, and they allow users to perform a wide range of tasks, such as managing files and directories, navigating the file system, running programs, and configuring the system. Understanding how to use Unix commands is essential for efficiently working with Unix-based systems.

Now, let's dive into more detailed explanations with examples for each of the basic Unix commands:

  1. ls (List Files and Directories):

    • The ls command is used to list files and directories in the current working directory.
    • Basic usage: ls
    • Example:
      $ ls
      file1.txt  file2.txt  directory1
      
  2. cd (Change the Current Directory):

    • The cd command is used to change the current working directory.
    • Basic usage: cd directory_name
    • Example:
      cd  /home/user/documents
      
  3. pwd (Print the Current Working Directory):

    • The pwd command displays the full path of the current working directory.
    • Basic usage: pwd
    • Example:
      pwd
      # Output will be
      # /home/user/documents
      
  4. mkdir (Create Directories):

    • The mkdir command creates new directories (folders) within the current directory.
    • Basic usage: mkdir directory_name
    • Example:
      mkdir my_folder
      
  5. touch (Create Empty Files):

    • The touch command creates empty files with the specified name.
    • Basic usage: touch file_name
    • Example:
      touch my_file.txt
  6. rm (Remove Files and Directories):

    • The rm command is used to delete files and directories.
    • To remove a file: rm file_name
    • To remove a directory and its contents: rm -r directory_name
    • Example:
      rm file.txt
      rm -r directory_name
      
  7. cp (Copy Files and Directories):

    • The cp command copies files or directories from one location to another.
    • Basic usage: cp source destination
    • Example:
      cp file.txt /home/user/desktop
  8. mv (Move/Rename Files and Directories):

    • The mv command moves files or directories from one location to another or renames them.
    • To move or rename: mv old_name new_name or mv source destination
    • Example (rename):
      mv file.txt new_file.txt
    • Example (move):
      mv file.txt /home/user/
  9. cat (Display File Content):

    • The cat command displays the contents of one or more files on the terminal.
    • Basic usage: cat file_name
    • Example:
      cat my_file.txt
  10. man (Access the Manual Pages for Commands):

    • The man command provides access to the manual pages (documentation) for Unix commands.
    • Basic usage: man command_name
    • Example:
      man ls

These basic Unix commands are essential for performing common tasks in a Unix-like operating system. Learning how to use them effectively is a foundational skill for working in Unix or Linux environments. Additionally, each command often has a variety of options and features that can be explored by consulting their respective manual pages using the man command.

 

Let's keep in touch!

Subscribe to keep up with latest updates. We promise not to spam you.