Linux Fundamentals and Scripting Mastery

The Art Of Editing & Securing Files

Learning Outcome

5

Manage local users and groups

4

Use nano editor effectively

3

Use vi editor confidently

2

Differentiate between vi and nano editors

1

Understand how to edit files in Linux

6

Understand RBAC basics

7

Understand Linux file permissions

8

Change permissions and ownership securely

Earlier, we learned that

 Analogy

Imagine a company office

Employees work on documents

Some can only read documents

Some can edit

Managers can control access

 What is File Editing in Linux?

File editing in Linux allows you to

  • Modify configuration files

  • Update scripts

  • Change application settings

  • Create new content

Common Editors:

V I

NANO

Goal :

Modify files efficiently

Avoid accidental errors

Maintain system stability

Comparison: vi vs nano

Feature

vi

nano

Difficulty

Interface

Mouse Support

Learning Curve

Used In

Advanced

Mode-based

No

High

Production Servers

Beginner Friendly

Simple

Limited

Low

Quick Editing

 How to Use vi Editor

vi is a powerful text editor available in almost all Linux systems

Open a File

vi filename.txt

Modes in vi

 Command Mode (Default)

Insert Mode (Press i)

Save & Exit Mode

Basic Commands

Press i â†’ Enter Insert Mode

Press Esc â†’ Back to Command Mode

:w â†’ Save

:q â†’ Quit

:wq â†’ Save & Quit

:q! â†’ Force Quit

Best for

Editing configuration files

 Working in production environments

How to Use nano Editor

nano is simple and beginner-friendly

Open a File

nano filename.txt

Basic Commands

  • Ctrl + O â†’ Save

  • Ctrl + X â†’ Exit

  • Ctrl + K â†’ Cut line

  • Ctrl + U â†’ Paste

Best for:

Beginners

 Quick file edits

Simple scripts

Managing Local Users and Groups

Linux is a multi-user operating system

An individual account that can log in and access resources

A collection of users

Why groups?

 Easier permission management

Department-based access

Basic Commands

Introduction to RBAC

RBAC = Role-Based Access Control

It means:

 Access is given based on role

 Not everyone gets full control

Example:

Admin → Full access

Developer → Read & Write

Viewer → Read only

Introduction to File Permissions

Linux controls access using permissions

Each file has 3 types of owners

 User (Owner)

 Group

 Others

Each has 3 types of permissions

Read (r)

Write (w)

Execute (x)

Example:

-rwxr-xr--

Introduction to File Permissions

Read (r)

  • View file content

  • List directory contents

Write (w)

  • Modify file

  • Add or delete content

Execute (x)

  • Run script or program

Symbolic vs Numerical Permissions

Uses letters

chmod u+x file.txt

u = user
g = group
o = others

Symbolic Method

Numerical Method

Uses numbers

Permission

Value

Read

4

Write

2

Execute

1

Example:

chmod 755 file.txt

755 means:

  • Owner → 7 (4+2+1 = rwx)

  • Group → 5 (4+1 = r-x)

  • Others → 5 (4+1 = r-x)

Changing Permissions (chmod)

Change permission using number

chmod 644 file.txt

OR

Change permission using symbol

chmod g+w file.txt

Use carefully in production systems

Changing Ownership

chown (Change Owner)

sudo chown user file.txt

Change owner and group

sudo chown user:group file.txt

chgrp (Change Group)

sudo chgrp groupname file.txt

Used to change only group ownership

 Architecture Flow (Security Perspective)

Summary

4

File permission types

3

Understanding RBAC

2

Managing users and groups

1

vi and nano editors

5

Symbolic and numeric methods

6

chmod, chown, chgrp

Quiz

Permission 755 gives full access to

A. Group

B. Others

C. Owner

D. Everyone

Quiz-Answer

Permission 755 gives full access to

A. Group

B. Others

C. Owner

D. Everyone

The Art Of Editing & Securing Files

By Content ITV

The Art Of Editing & Securing Files

  • 59