What are common Bash commands?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 13 2025
0176

Here are some common Bash commands that are frequently used:

  1. ls: Lists files and directories in the current directory.

    ls -l  # Lists with detailed information
  2. cd: Changes the current directory.

    cd /path/to/directory  # Navigate to a specific directory
  3. pwd: Prints the current working directory.

    pwd
  4. mkdir: Creates a new directory.

    mkdir new_directory
  5. rmdir: Removes an empty directory.

    rmdir empty_directory
  6. rm: Removes files or directories.

    rm file.txt  # Deletes a file
    rm -r directory_name  # Deletes a directory and its contents
  7. cp: Copies files or directories.

    cp source.txt destination.txt  # Copies a file
    cp -r source_directory/ destination_directory/  # Copies a directory
  8. mv: Moves or renames files or directories.

    mv old_name.txt new_name.txt  # Renames a file
    mv file.txt /path/to/destination/  # Moves a file
  9. cat: Concatenates and displays file content.

    cat file.txt
  10. echo: Displays a line of text or variable value.

    echo "Hello, World!"
  11. grep: Searches for a specific pattern in files.

    grep "search_term" file.txt
  12. find: Searches for files and directories in a directory hierarchy.

    find /path/to/search -name "*.txt"
  13. chmod: Changes file permissions.

    chmod 755 script.sh  # Sets permissions for a script
  14. chown: Changes file owner and group.

    chown user:group file.txt
  15. man: Displays the manual for a command.

    man ls  # Shows the manual for the ls command

These commands form the foundation of file management and navigation in the Bash shell. If you need more details or examples for any specific command, let me know!

0 Comments

no data
Be the first to share your comment!