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)