DEV Community

Shreyas Vithalkar
Shreyas Vithalkar

Posted on

๐Ÿš€ Day 3 of My 90-Day DevOps Journey: Vim Editor and Linux File Types

Welcome back to Day 3 of my DevOps journey! Today, I explored the Vim editor and learned about the types of files in Linux. Letโ€™s dive in!


๐Ÿ–‹๏ธ Vim Editor Basics

Vim is a highly efficient text editor thatโ€™s perfect for editing files in Linux. It operates in two primary modes:

  • Command Mode: For executing commands.

  • Insert Mode: For writing and editing text.

Image description

๐Ÿ› ๏ธ Essential Vim Commands

  • Switching Modes:

    • Press i โ†’ Enter Insert mode.

    • Press Esc โ†’ Return to Command mode.

  • File Operations:

    :w     # Save the file  
    :q     # Quit Vim  
    :wq    # Save and quit  
    :q!    # Quit without saving
    
    • Text Navigation:

      • h โ†’ Move left

      • l โ†’ Move right

      • j โ†’ Move down

      • k โ†’ Move up

    • Editing:

      • x โ†’ Delete a character

      • dd โ†’ Delete a line

      • yy โ†’ Copy a line

      • p โ†’ Paste copied content

    • Search and Replace:

      /pattern      # Search for 'pattern'  
      :%s/old/new/g # Replace 'old' with 'new' globally 
      

๐Ÿ“‚ Types of Files in Linux

Linux files come in various types, each serving a unique purpose. Hereโ€™s what I learned:

  1. Regular File:

    • Stores data like text, scripts, or binaries.

    • Command to check:

ls -l file.txt
Look for a `-` at the start of the permissions (`-rw-r--r--`).
  1. Directory:

    • Contains other files or directories.

    • Identified with a d in permissions (drwxr-xr-x).

  2. Link File:

    • A shortcut to another file. (This you can consider as a Desktop short for any file/application in Windows) Can be:

      • Hard Link: Points directly to the file's data.

        ln file.txt hardlink.txt
        
      • Soft Link: Points to the file's location.

        ln -s file.txt softlink.txt
        
    • Use unlink filename to unlink a file.

  3. Special File:

    • Represents devices like printers or disks, typically found in /dev.
  4. Socket:

    • Enables communication between processes, often used in networking.
  5. Block File:

    • Represents devices that transfer data in blocks (e.g., hard drives).

๐Ÿ” Command to Identify File Types:

Use the file command to determine a fileโ€™s type:

file filename

Also a bonus thing, some options on our ls command

ls -l

The above command with -l option is long listing of files (Sorts Alphabetically)

ls -lt

Sort by Timestamp, (Latest first/ Last modified)

ls -ltr

The -r option is for reverse sorting. And in the above example, it will sort old modified files first.


โœจ Key Takeaway

Today, I took a big step in strengthening my Linux foundation. Mastering the Vim editor and understanding file types are crucial skills for any DevOps engineer. ๐Ÿš€

Stay tuned for more as I continue my journey to DevOps mastery!

Top comments (0)