0% found this document useful (0 votes)
2 views5 pages

Lesson 4 - RM Delete Command

This document provides instructions on using the 'rm' command to delete files and directories in Linux, emphasizing the importance of caution as deletions are permanent. It also covers the 'chmod' command for changing file permissions, explaining both symbolic and numeric methods for setting permissions. Key rules and safety practices are highlighted throughout to ensure proper usage of these commands.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Lesson 4 - RM Delete Command

This document provides instructions on using the 'rm' command to delete files and directories in Linux, emphasizing the importance of caution as deletions are permanent. It also covers the 'chmod' command for changing file permissions, explaining both symbolic and numeric methods for setting permissions. Key rules and safety practices are highlighted throughout to ensure proper usage of these commands.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

✅ Lesson 4 – rm (delete command)

⚠️This is very important and dangerous if mis-used

First go to your lab folder:

cd ~/linuxlab
ls

🔹 Delete one file (safe)


Create a test file first:

touch [Link]
ls

Now delete it:

rm [Link]

Check:

ls

✔ File is gone.

⚠️Very important rule


rm

➡ deletes permanently
➡ there is NO recycle bin (in terminal)

🔹 Try deleting a directory (this will fail)


From inside ~/linuxlab run:

rm .
You will get an error.
Good — Linux is protecting you.

Now try:

rm -r temp

(Only if a folder named temp exists.)

🧠 Meaning
-r = recursive (delete folder and its contents)

⚠️Golden safety rule (remember as a teacher)


Before using:

rm -r

Always check with:

ls
pwd

Just like checking the correct router before pasting a config.

✅ Lesson 5 – chmod (permissions) – very


important
Create one file:

touch [Link]
ls -l [Link]

You will see something like:

-rw-r--r--
🧠 Understand this:
-rw-r--r--

Break it like this:

owner group others


rw- r-- r--

🔹 Make the file executable


Run:

chmod +x [Link]
ls -l [Link]

Now you will see:

-rwxr-xr-x

🔹 Numeric method (this is important)


Run:

chmod 644 [Link]


ls -l [Link]

Then:

chmod 755 [Link]


ls -l [Link]

🧠 Meaning (must remember)


r = 4
w = 2
x = 1

So:

7 = 4+2+1 = rwx
6 = 4+2 = rw-
5 = 4+1 = r-x
4 = 4 = r--
🎯 Small task for you (last step for today)
Please run:

ls -l [Link]

cd ~/linuxlab

touch [Link]

ls -l [Link]

chmod 644 [Link]

ls -l [Link]

chmod 755 [Link]

ls -l [Link]

One very small extra (symbolic way – useful in real work)


From the same folder, try:

chmod o-w [Link]


ls -l [Link]

This means:

remove write permission from others

One final small test (to really see the effect)


Please run:

chmod o+w [Link]


ls -l [Link]

Now you should see:

-rwxr-xrw-

or more clearly:
others = rw-

Then remove it again:

chmod o-w [Link]


ls -l [Link]

🧠 This is the final rule you must remember


u = user (owner)
g = group
o = others
a = all

And:

+ add
- remove
= set exactly

Examples:

chmod u+x file


chmod g-w file
chmod o+r file
chmod a+x file

You might also like