✅ Linux Basics (Beginner Guide) – Till File & Directory Management Part 1
🔰 Step 0: Connect to EC2 Instance
✅ Command:
ssh -i "your-key.pem" ec2-user@your-public-ip
This connects you to your Amazon Linux EC2 machine.
📁 Step 1: Linux Directory Structure
Folder Meaning (Simple Words)
/ Root directory (like C:\ in Windows)
/root Home folder for root user (admin)
/home Contains home folders for users (like ec2-user)
/bin System commands like ls, cp, pwd live here
/sbin Advanced system tools used by root only
/usr Installed programs and commands live here
/etc Configuration files of the system
/var Log files and variable data
/tmp Temporary files folder
✅ Commands to explore:
cd / # Go to root folder
ls # List files/folders
cd etc # Go inside etc folder
cd .. # Go one step back
pwd # Show current path
🧾 Step 2: Basic Linux Commands
Command What It Does
date Shows current date and time
cal Shows calendar of current month
uptime Shows how long the system is running
Command What It Does
whoami Shows which user is logged in
who / w Shows who is online
users Shows all logged-in users
finger Shows user info (needs install)
man <cmd> Shows manual/help for any command
✅ To install finger:
sudo yum install finger -y
📄 Step 3: Create Files
✅ Commands:
Command What It Does
touch file.txt Creates an empty file
cat > file.txt Opens file to type content (Ctrl+D to save)
nano file.txt Opens file in nano editor
vi file.txt Opens file in vi editor
💡 nano Editor:
Type: nano file.txt
To Save: Ctrl + O, then Enter
To Exit: Ctrl + X
💡 vi Editor:
Type: vi file.txt
Press i to start typing
Press Esc to exit insert mode
Type :wq → Save & Quit
Step 4: Delete Files and Folders
Command What It Does
rm file.txt Deletes a file
mkdir myfolder Makes a new folder
rmdir myfolder Deletes empty folder only
rm -rf myfolder Deletes folder and everything inside (use carefully)
📁 Step 5: Create & Explore Folders
Command What It Does
mkdir foldername Creates a new folder
cd foldername Goes inside the folder
cd .. Goes back one step
cd ~ Goes back to your home folder
ls Shows files/folders in current directory
ls -l Shows detailed list with permissions
pwd Shows full path (where you are)
📝 Practice Task
Try this step-by-step:
1. mkdir project
2. cd project
3. nano plan.txt → add some text
4. cd ..
5. rm -rf project
✅ This helps you practice: create, edit, delete.
🧾 Final Summary Table
Task Command
Go to root folder cd /
Show current folder pwd
List files/folders ls
Task Command
Create empty file touch file.txt
Create & write to file cat > file.txt (then Ctrl+D to save)
Edit file (easy) nano file.txt
Edit file (advanced) vi file.txt
Delete file rm file.txt
Create folder mkdir myfolder
Delete empty folder rmdir myfolder
Delete folder with files rm -rf myfolder
Check who you are whoami
Check system uptime uptime
Check date and time date
Show manual/help man <command>