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.
π οΈ 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:
-
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--`).
-
Directory:
-
Contains other files or directories.
-
Identified with a
d
in permissions (drwxr-xr-x
).
-
-
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.
-
-
Special File:
- Represents devices like printers or disks, typically found in
/dev
.
- Represents devices like printers or disks, typically found in
-
Socket:
- Enables communication between processes, often used in networking.
-
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)