Skip to main content

Commands

Linux is a powerful operating system with a wide range of commands for various tasks. Here is a list of some basic Linux commands along with their common use cases:

  1. ls (List):

    • Use Case: List files and directories in the current directory.
    • Example: ls -l (Long format listing), ls -a (List hidden files), ls /path/to/directory (List files in a specific directory).
  2. pwd (Print Working Directory):

    • Use Case: Display the current working directory.
    • Example: pwd.
  3. cd (Change Directory):

    • Use Case: Change the current directory.
    • Example: cd /path/to/directory.
  4. mkdir (Make Directory):

    • Use Case: Create a new directory.
    • Example: mkdir my_directory.
  5. rmdir (Remove Directory):

    • Use Case: Remove an empty directory.
    • Example: rmdir my_directory.
  6. touch:

    • Use Case: Create an empty file or update the timestamp of an existing file.
    • Example: touch myfile.txt.
  7. rm (Remove):

    • Use Case: Delete files or directories.
    • Example: rm myfile.txt (Remove a file), rm -rf my_directory (-r means Remove a directory and its contents -f means forcefully).
  8. cp (Copy):

    • Use Case: Copy files or directories.
    • Example: cp file1.txt file2.txt (Copy a file), cp -r directory1/ directory2/ (Copy a directory and its contents).
  9. mv (Move/Rename):

    • Use Case: Move or rename files or directories.
    • Example: mv file1.txt newfile.txt (Rename a file), mv file.txt /new/location/ (Move a file).
  10. cat (Concatenate):

    • Use Case: Display the content of a file.
    • Example: cat myfile.txt.
  11. less/more:

    • Use Case: View the contents of a file one screen at a time.
    • Example: less myfile.txt or more myfile.txt.
  12. head/tail:

    • Use Case: Display the beginning or end of a file.
    • Example: head -n 10 myfile.txt (Display the first 10 lines), tail -f logfile.txt (Display the last few lines of a log file in real-time).
  13. grep (Global Regular Expression Print):

    • Use Case: Search for a pattern in text.
    • Example: grep "pattern" file.txt.
  14. find:

    • Use Case: Search for files and directories in a directory hierarchy.
    • Example: find /path/to/search -name "filename".
  15. chmod (Change Mode):

    • Use Case: Change file permissions.
    • Example: chmod 755 myfile.sh (Give read, write, and execute permissions to the owner, and read and execute permissions to others).
  16. chown (Change Owner):

    • Use Case: Change the owner of a file or directory.
    • Example: chown user:group myfile.txt.
  17. ps (Process Status):

    • Use Case: List currently running processes.
    • Example: ps aux (List all processes).
  18. kill:

    • Use Case: Terminate a running process.
    • Example: kill process_id.
  19. df (Disk Free):

    • Use Case: Display disk space usage.
    • Example: df -h (Display usage in human-readable format).
  20. du (Disk Usage):

    • Use Case: Show the disk space used by files and directories.
    • Example: du -sh /path/to/directory.

These are just some of the basic Linux commands. Linux provides a wide array of commands and utilities for performing various tasks, making it a versatile and powerful operating system. You can typically find more information about these commands and their options by using the man command followed by the command name, e.g., man ls for detailed information about the ls command.