Ubuntu Command Line: Common Commands and Usage Guide

File and Directory Management

  1. ls: Show a list of files and directories in the current directory. This command allows you to view the contents of the current directory.

    Example: ls

  2. pwd: Print the absolute path of the current directory. This command helps you know where you are in the file system.

    Example: pwd

  3. cd <directory>: Change to the specified directory. By using this command, you can navigate between directories in your file system.

    Example: cd /home/user/documents

  4. touch <file>: Create a new file or update the modification time of an existing file. If the file already exists, it will update the modification time.

    Example: touch newfile.txt

  5. cp <source> <destination>: Copy a file or directory from the source location to the destination location. You can copy multiple files or directories by specifying multiple sources.


    • cp file.txt /home/user/documents/ (copy a file)
    • cp -r folder1 /home/user/documents/ (copy a directory)
  6. mv <source> <destination>: Move or rename a file or directory from the source location to the destination location. If the destination is a new name, it will rename; if it is a new path, it will move.


    • mv file.txt /home/user/documents/file_new.txt (rename a file)
    • mv folder1 /home/user/documents/ (move a directory)
  7. rm <file>: Delete a file. Note that this command will delete the file without any confirmation, so use it carefully.

    Example: rm file.txt

  8. mkdir <directory>: Create a new directory with the specified name.

    Example: mkdir new_folder

  9. rmdir <directory>: Delete an empty directory. Note that you can only delete an empty directory with this command.

    Example: rmdir empty_folder

Permission Management

  1. chmod <permission> <file/directory>: Change the access permissions of a file or directory according to the specified permission. Common permissions include "r" (read), "w" (write), and "x" (execute).

    Example: chmod u+rwx file.txt (add read, write, and execute permissions for the user)

  2. chown <user>:<group> <file/directory>: Change the owner of a file or directory to the specified user and group.

    Example: chown user1:group1 file.txt (set owner and group for file.txt)

Process and Service Management

  1. ps: List running processes. This command displays a list of processes and their corresponding Process IDs (PIDs).

    Example: ps

  2. top: Display running processes and system resources. This command provides an interactive interface to view running processes and monitor system resources such as CPU, RAM.

    Example: top

  3. kill <PID>: Terminate a process with the specified Process ID (PID). This command sends a signal to stop the process, allowing it to exit or shut down.

    Example: kill 1234 (terminate the process with PID 1234)

  4. systemctl start <service>: Start the specified service. A service is a background program of the system, and this command starts it.

    Example: systemctl start apache2 (start the Apache service)

  5. systemctl stop <service>: Stop the specified service. This command stops the running service.

    Example: systemctl stop apache2 (stop the Apache service)

  6. systemctl restart <service>: Restart the specified service. This command stops and then starts the service.

    Example: systemctl restart apache2 (restart the Apache service)

  7. systemctl status <service>: Show the status of the specified service. This command displays whether the service is running or not and its status.

    Example: systemctl status apache2 (show the status of the Apache service)

Package Management

  1. apt-get install <package>: Install a software package from the Ubuntu repository.

    Example: apt-get install nginx (install Nginx)

  2. apt-get update: Update the information of all software packages from the repository. This command will fetch information about the latest packages from the repository.

    Example: apt-get update

  3. apt-get upgrade: Upgrade all installed packages to the latest version.

    Example: apt-get upgrade

  4. apt-get remove <package>: Remove an installed package from the system.

    Example: apt-get remove nginx (remove Nginx)

Network Management

  1. ifconfig: Display information about network devices and IP addresses of the system.

    Example: ifconfig

  2. ip addr: Display information about network devices and IP addresses of the system. This command is similar to ifconfig.

    Example: ip addr

  3. ping <domain/IP>: Check network connectivity to a specified IP address or domain name by sending packets and waiting for a response.

    Example: ping google.com

  4. curl <URL>: Retrieve the content from a URL. This command is commonly used to download data from a website and display the result on the command line.

    Example: curl https://www.example.com

Command History Management

  1. history: Show the history of previously executed commands. This command lists the commands that have been executed in the current session.

    Example: history


These are some common and useful command line commands in Ubuntu. Depending on your needs and purposes, you can use these commands to manage your system and perform various basic tasks.