Day1
pwd
cd /home/path
cd ..
ls
ls -l
ls -lt
ls -ltr
mkdir directory_name
mkdir dir1 dir2 dir3
rm -r d1 d2
touch file_name
touch f1 f2 f3
vi filename i --> insert :wq --> write and quit :q --> quit :set nu or :set number
cat filename
Here is the explanation of the commands you listed. These are the "daily driver" commands for any Linux user or DevOps engineer.
1. Navigation Commands (Moving around)
pwdMeaning: Print Working Directory.
What it does: Shows you exactly where you are in the system right now.
Example Output:
/home/user/projects
cd /home/pathMeaning: Change Directory.
What it does: Teleports you straight to the specific folder you typed.
cd ..Meaning: Go Up one level.
What it does: Moves you out of the current folder into the one before it (the parent folder).
Example: If you are in
/home/user/downloads, typingcd ..takes you to/home/user.
2. Listing Commands (Seeing what you have)
lsMeaning: List.
What it does: Shows the names of files and folders in your current directory.
ls -lMeaning: List Long.
What it does: Shows details: File permissions, Owner, Size, and Date Modified.
ls -ltMeaning: List Long + Time.
What it does: Sorts the list by time, with the newest files at the top.
ls -ltrMeaning: List Long + Time + Reverse.
What it does: Sorts by time but reverses the order (Oldest at top, Newest at bottom).
Why use this? This is the "Log Reader's Best Friend." When you run it, the most recently changed file appears right above your cursor so you don't have to scroll up to find it.
3. Creation & Deletion (Making and removing)
mkdir directory_nameMeaning: Make Directory.
What it does: Creates a new folder.
mkdir dir1 dir2 dir3What it does: Creates multiple folders at the same time.
rm -r d1 d2Meaning: Remove Recursive.
What it does: Deletes the folders
d1andd2and everything inside them.Warning: Be careful! There is no "Recycle Bin" in the Linux command line. Once you
rm, it is gone forever.
touch file_nameWhat it does: Creates an empty file.
Note: If the file already exists, it updates the timestamp (makes it look like it was just modified) but doesn't change the content.
touch f1 f2 f3What it does: Creates multiple empty files at once.
4. Editing & Viewing Files
cat filenameMeaning: Catch (Concatenate).
What it does: Dumps the content of a file onto the screen. Great for reading short files quickly.
vi filenameWhat it does: Opens the Vi Editor. This is the standard text editor in Linux.
How to use it (The Workflow):
Open file:
vi filename(You start in Command Mode—you cannot type text yet).i: Pressito enter Insert Mode. (Now you can type like a normal notepad).Esc: Press theEsckey to exit Insert Mode and go back to Command Mode.:set nu: Turns on line numbers (helps you find errors).:wq: Write (Save) and Quit.:q: Quit (Use this if you haven't made any changes).
Last updated
