LINUX BASIC COMMANDS        


                                 

1. whoami - Display the current logged-in user.

                   whoami - Shows username.

                   Example: whoami

 2. pwd - Print the current directory path.

               pwd - Outputs the current directory.

 Example: pwd

 3. . ls - Lists directory contents.

            ls - Basic list.

            ls -l - List with details.

            Example: ls -la Directory

 4. . cd - Change the current directory. 

             cd Directory - Changes to "Directory".

             Example: cd /home 

 5. . mkdir - Create a new directory.

                   mkdir Directory - Creates "Directory".

                   Example: mkdir /home/Directory

 6. . rmdir - Remove an empty directory.

                   rmdir Directory - Deletes "Directory".

                   Example: rmdir /home/Directory

 7. touch - Create an empty file.

                 touch file - Creates "file".

                Example: touch /home/Directory/newfile

 8. rm - Delete files and directories

          . rm file - Deletes "file".

            rm -r Directory - Deletes "Directory" recursively.

 Example: rm -rf /home/Directory

 9. . cp - Copy files or directories.

              cp file new_file - Copies "file" to "new_file".

              cp -r Directory new_directory - Copies "Directory" recursively

            . Example: cp -r Directory /backup/

 10. mv - Move or rename files and directories

             . mv file new_file - Renames "file" to "new_file". 

              Example: mv file /home/Directory/

 11. cat - Concatenate and display file contents. 

              cat file - Shows contents of "file". 

              Example: cat file 

 12. less - View file content interac vely.

                less file - Opens "file" in viewer.

                Example: less file

 13. more - View file content page-by-page.

                  more file - Views file with paging.

                  Example: more file 

 14. head - Show the first few lines of a file.

                  head -n 5 file - Shows first 5 lines

               . Example: head file

 15. tail - Show the last few lines of a file.

               tail -n 5 file - Shows last 5 lines.

               tail -f file - Shows last lines with live updates.

               Example: tail -f /var/log/syslog 

 16. grep - Search within files. 

                  grep "pa ern" file - Searches for "pa ern". 

                  Example: grep -i error file 

 17. sed - Stream editor for modifying files.

               sed 's/old/new/' file - Replace text.

               Example: sed -i 's/foo/bar/g' file 

 18. wc - Count lines, words, and characters in a file.

                Usage: wc file - Displays line, word, and character counts for "file". 

                Example: wc -l file - Counts lines in "file".

 19. echo - Display a line of text. Usage:

                 echo "Hello World" - Outputs text to the screen.

                 Example: echo $PATH

 20. free - Show memory usage.

                 Usage: free -h - Memory stats in human-readable format. 

                 Example: free 

 21. tree - Show directory structure in tree format. 

                  tree Directory - Displays "Directory" structure.

                   Example: tree /home






Comments

Popular posts from this blog

User Management in Linux – Complete Notes for Beginners

DevOps Roadmap 2026 – Your Complete Beginner-to-Expert Guide

What is Public Subnet in AWS? Step-by-Step Explanation with Example