Basic Linux Commands

Basic Linux Commands

  1. cat <file_name>: This command is used to view what's written in a file

    cat -n <file_name>: This adds line numbers to all lines

  2. To change the access permissions of files.

    chmod: This command is used to change the permission of files

    Ex. chmod 770 <file_name> , Here chmod is the command and 770(user+group+other) is the permission.

    Introduction to Linux file permissions & attributes: chmod - Globo.Tech

  3. To change the owner of the files

    chown <username> <filename>: This command is used to change the owner of files.

  4. sudo: This is used to run the command with superuser privilege.

  5. history: This command is used to check which commands you have run till now.

  6. rmdir <directory_name>: This command is used to remove a directory.

    or

    rm -r <directory_name>: We used this command when a directory is not empty

  7. vim <filename> : Vim is the text editor in Linux.

  8. Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

  9. head -n <filename>: To show only top three fruits from the file.

  10. tail -n <filename>: To Show only bottom three fruits from the file.

  11. To create another file colors.txt and to view the content and add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

  12. To find the difference between the fruits.txt and Colors.txt files.

    Here we can use diff commands.

  13. grep: This command is used to find a particular pattern or word.

    Ex. grep -i pratik test.txt

  14. find: This command is used to find the files and directories

    find ./ -name test.txt

  15. apt-get install <package>: To install package

  16. ifconfig: Is used to get IP address

Suggestions are always welcome. Thank you !!