Linux Basics: Essential Commands and Usage

Linux is a powerful and widely used operating system with a command-line interface that allows users to interact with the system using text commands. Here are some basic Linux commands and their usage:

Linux commands and usage:

  1. pwd – Print Working Directory: Shows the current directory you are in.

    Usage: pwd

  2. ls – List Files and Directories: Lists the files and directories in the current directory.

    Usage: ls (list current directory contents)
    Usage: ls <directory> (list contents of a specific directory)

    Additional options:
    • ls -l: List with detailed information (permissions, size, owner, etc.)
    • ls -a: List including hidden files (files starting with a dot)

  3. cd – Change Directory: Change the current directory to another directory.

    Usage: cd <directory> (move to a specific directory)
    Usage: cd .. (move to the parent directory)
    Usage: cd or cd ~ (move to the home directory)

  4. mkdir – Make Directory: Create a new directory.

    Usage: mkdir <directory_name>

  5. rmdir – Remove Directory: Remove an empty directory.

    Usage: rmdir <directory_name>

  6. rm – Remove Files or Directories: Remove files or directories.

    Usage: rm <file_name> (remove a file)
    Usage: rm -r <directory_name> (remove a directory and its contents)

    Caution: Be careful when using rm -r as it permanently deletes files and directories without confirmation.

  7. touch – Create Empty File: Create an empty file or update the access and modification times of an existing file.
    Usage: touch <file_name>

  8. cp – Copy Files and Directories: Copy files or directories.

    Usage: cp <source_file> <destination_file> (copy a file)
    Usage: cp -r <source_directory> <destination_directory> (copy a directory)

  9. mv – Move or Rename Files and Directories: Move files or directories from one location to another or rename them.

    Usage: mv <source> <destination> (move or rename a file or directory)

  10. cat – Concatenate and Display File Content: Display the content of a file.

    Usage: cat <file_name>

  11. more and less – Display File Content Page by Page: Display the content of a file one screen/page at a time.

    Usage: more <file_name> (use spacebar to go to the next page)
    Usage: less <file_name> (use arrow keys to navigate)

  12. head and tail – Display the Beginning or End of a File:
    Show the first few lines (head) or last few lines (tail) of a file.

    Usage: head <file_name> (show the first 10 lines by default)
    Usage: tail <file_name> (show the last 10 lines by default)

  13. grep – Search for Patterns in Files: Search for a specific pattern in a file.

    Usage: grep <pattern> <file_name>

  14. chmod – Change File Permissions: Change the permissions of a file or directory.

    Usage: chmod <permissions> <file_name> (e.g., chmod 755 myfile)

  15. chown – Change File Owner and Group: Change the owner and/or group of a file or directory.

    Usage: chown <new_owner>:<new_group> <file_name>

  16. ps – Process Status: Display information about running processes.

    Usage: ps (shows processes of the current user)
    Usage: ps -ef (shows all processes)

  17. kill – Terminate a Process: Terminate or send a signal to a process.

    Usage: kill <process_id> (terminate a process by its ID)

  18. man – Manual Pages: Get information about commands and their usage.

    Usage: man <command> (e.g., man ls)

These are just a few of the basic Linux commands. Linux provides a rich set of commands and utilities that can be combined to perform various tasks efficiently. To explore more commands and their options, you can use the man command to access the manual pages and learn about their usage and options.

How to install Linux on Virtual Box

Leave a Comment

Your email address will not be published. Required fields are marked *