Monday, September 14, 2026

Linux File Management & Text Processing — Beginner Guide

File management and text processing are core Linux skills for a System Administrator, Cloud Engineer, DevOps Engineer, and Linux Administrator.

You will mainly learn how to:

  • Create files and directories
  • Copy, move, rename, and delete files
  • Find files
  • Read file contents
  • Edit files
  • Search text
  • Process and filter text
  • Count lines/words
  • Combine commands using pipes
  • Redirect command output

1. Linux File Management

Think of Linux files and folders like Windows:

Windows

Linux

Folder

Directory

C:\Users

/home

File Explorer

Terminal commands

Copy

cp

Move

mv

Delete

rm

Rename

mv

Search

find

View file

cat

2. Check Your Current Location — pwd

pwd means Print Working Directory.

pwd

Example:

/home/sandeep

This tells you where you currently are.

Easy example

Imagine you are standing inside:

/home/sandeep/Documents

pwd tells you:

"You are currently inside /home/sandeep/Documents."

3. List Files — ls

ls

Example:

Documents
Downloads
file.txt
notes.txt

Useful ls options

Command

Purpose

ls

List files

ls -l

Detailed information (Long List)

ls -a

Show hidden files (All List)

ls -lh

Detailed + human-readable sizes

ls -la

Detailed + hidden files

ls -lt

Sort by modification time

Try:

ls -lah

You may see:

drwxr-xr-x  2 user user 4.0K Documents
-rw-r--r--  1 user user  250 notes.txt

4. Create a Directory/Folder — mkdir

mkdir = Make Directory

mkdir project

Now check:

ls

You should see:

project

Create multiple directories

mkdir dev test backup

Create nested directories

mkdir -p project/src/html

The -p option creates the parent directories if they don't already exist.

5. Change Directory — cd

Move into a directory:

cd project

Go back one level:

cd ..

Go to your home directory:

cd ~

Go to the root directory:

cd /

Example

pwd
cd project
pwd
cd ..
pwd

6. Create an Empty File — touch

touch file.txt

Check:

ls

You should see:

file.txt

Create several files:

touch file1.txt file2.txt file3.txt

7. Copy Files data — cp

Copy a file:

cp file.txt backup.txt

Now:

ls

You have:

file.txt
backup.txt

Copy file to another directory

cp file.txt backup/

Copy a directory

Use -r:

cp -r project project_backup

-r means recursive — copy the directory and everything inside it.

8. Move Files — mv

Move:

mv file.txt Documents/

Rename:

mv old.txt new.txt

This is important:

Linux uses mv for both moving and renaming.

Example

mv report.txt final-report.txt

The file has been renamed.

9. Delete Files — rm

Delete a file:

rm file.txt

⚠️ Linux rm normally does not move files to the Recycle Bin.

Delete multiple files

rm file1.txt file2.txt

Delete a directory

rm -r project

Force delete

rm -rf project

⚠️ Be extremely careful with rm -rf.

Never blindly run commands such as:

rm -rf /

10. Reading File Contents

There are several important commands.

cat

Display the complete file:

cat notes.txt

Example:

Linux is an operating system.
Linux is widely used in servers.
Linux is important for DevOps.

less

Useful for large files:

less /var/log/syslog

Navigate with:

  • / — move
  • Space — next page
  • b — previous page
  • /word — search
  • q — quit

head

Show the first lines:

head notes.txt

First 5 lines:

head -n 5 notes.txt

tail

Show the last lines:

tail notes.txt

Last 20 lines:

tail -n 20 notes.txt

Very important for server administration:

tail -f application.log

This continuously displays new log entries as they are added.

11. Write Text into a File

You can use echo.

echo "Hello Linux" > hello.txt

Check:

cat hello.txt

Output:

Hello Linux

Important: >

> overwrites the existing content.

Example:

echo "Line 1" > test.txt
echo "Line 2" > test.txt

Now the file contains only:

Line 2

12. Append Text — >>

>> adds content to the end.

echo "Line 1" > test.txt
echo "Line 2" >> test.txt
echo "Line 3" >> test.txt

Check:

cat test.txt

Output:

Line 1
Line 2
Line 3

Remember

>   = overwrite
>>  = append

This is extremely important in Linux.

13. Text Editor — nano

For beginners, nano is easy.

nano notes.txt

Type:

Linux File Management
Linux Text Processing
Linux Administration

Save:

Ctrl + O
Enter

Exit:

Ctrl + X

14. Search for Files — find

find is one of the most important Linux commands.

Find a file:

find /home -name "notes.txt"

Find all .txt files:

find . -name "*.txt"

Here:

.       = current directory
*.txt   = all text files

Find directories

find . -type d

Find files

find . -type f

Find files larger than 100 MB

find /home -type f -size +100M

15. locate

Another file-search command:

locate notes.txt

It can be faster than find, but it relies on an indexed database, so very recently created files may not appear until the database is updated.

16. File Information — file

Check what type of file something actually is:

file notes.txt

Example:

notes.txt: ASCII text

Another example:

file image.jpg

Output might be:

image.jpg: JPEG image data

17. File Size — du

Check directory size:

du -sh project/

Example:

250M    project/

Check disk usage:

df -h

Difference

CommandPurpose
duSpace used by files/directories
dfFree/used space on filesystems

18. Text Processing in Linux

Now we move to one of the most important Linux administration skills:

Searching, filtering, counting, sorting and transforming text from files and command output.

Important commands:

cat
grep
sort
uniq
wc
cut
tr
awk
sed
head
tail

19. grep — Search Text

grep is one of the most important commands for Linux administrators.

Suppose:

cat users.txt

Output:

Sandeep
Rahul
Amit
Sandeep
Priya

Search for Sandeep:

grep "Sandeep" users.txt

Output:

Sandeep
Sandeep

Case-insensitive search

grep -i "sandeep" users.txt

Show line numbers

grep -n "Sandeep" users.txt

Search recursively

grep -r "error" /var/log/

This is very useful when troubleshooting applications.

20. wc — Count

wc = Word Count

wc notes.txt

It can show:

lines words bytes filename

Count lines:

wc -l notes.txt

Count words:

wc -w notes.txt

Count characters/bytes:

wc -c notes.txt

21. sort

Suppose:

Zebra
Apple
Mango
Banana

Run:

sort fruits.txt

Output:

Apple
Banana
Mango
Zebra

Reverse order:

sort -r fruits.txt

22. uniq

uniq removes adjacent duplicate lines.

Example:

Linux
Linux
Windows
Windows
Docker

Run:

uniq file.txt

Output:

Linux
Windows
Docker

For duplicate counting:

sort file.txt | uniq -c

Example:

2 Linux
2 Windows
1 Docker

23. cut

cut extracts selected parts of each line.

Suppose:

101,Sandeep,DevOps
102,Rahul,Linux
103,Amit,AWS

Extract the first column:

cut -d "," -f 1 users.csv

Output:

101
102
103

Extract the second column:

cut -d "," -f 2 users.csv

Output:

Sandeep
Rahul
Amit

Here:

-d "," = delimiter is comma
-f 2   = field/column 2

24. tr

tr is used to translate or replace characters.

Convert lowercase to uppercase:

echo "hello linux" | tr 'a-z' 'A-Z'

Output:

HELLO LINUX

Replace spaces with underscores:

echo "Linux System Admin" | tr ' ' '_'

Output:

Linux_System_Admin

25. sed

sed is commonly used for searching and replacing text.

Example:

echo "I use Windows" | sed 's/Windows/Linux/'

Output:

I use Linux

Replace text in a file:

sed 's/Windows/Linux/g' file.txt

Here:

s = substitute
g = all occurrences on each line

26. awk

awk is extremely useful for processing columns and structured text.

Example:

echo "Sandeep 30 DevOps" | awk '{print $1}'

Output:

Sandeep

Second column:

echo "Sandeep 30 DevOps" | awk '{print $2}'

Output:

30

Third:

echo "Sandeep 30 DevOps" | awk '{print $3}'

Output:

DevOps

Think of awk as:

A powerful tool for working with rows and columns.

27. Pipe | — Connect Commands

The pipe is extremely important.

command1 | command2

It means:

Send the output of command 1 to command 2.

Example:

ls | grep ".txt"

Flow:

ls
 ↓
list of files
 ↓
grep ".txt"
 ↓
only .txt files

28. Real Example: Count Linux Processes

Run:

ps aux

Now:

ps aux | wc -l

This counts the lines.

You can combine commands:

ps aux | grep nginx

This searches running processes for nginx.


29. Redirection

Linux provides several important operators.

OperatorMeaning
>Write/overwrite
>>Append
<Take input from file
2>Redirect error
2>>Append errors
&>Redirect output + errors

Example:

ls > files.txt

Now the output of ls is stored in:

files.txt

30. Standard Output vs Error

Linux commands generally use:

0 = Standard Input
1 = Standard Output
2 = Standard Error

For example:

ls /abc 2> error.txt

If /abc doesn't exist, the error is saved into:

error.txt

31. Important Linux File Management Workflow

A good beginner practice is:

          Linux File Management
                  │
        ┌─────────┴─────────┐
        ↓                   ↓
     Directory             File
        │                   │
      mkdir               touch
        │                   │
       cd                  cat
        │                   │
       ls                  cp
        │                   │
      find                 mv
        │                   │
      du/df                rm
                            │
                            ↓
                     Text Processing
                            │
       ┌─────────┬─────────┼─────────┐
       ↓         ↓         ↓         ↓
     grep      sort       cut       awk
       ↓         ↓         ↓         ↓
     Search    Sort      Columns   Analyze
                            │
                            ↓
                          sed
                            │
                         Replace
                            │
                            ↓
                          pipe
                           |
                    Combine commands

32. Hands-on Practice Project

Let's create a small Linux administration project.

Step 1 — Create project directory

mkdir linux-file-practice
cd linux-file-practice

Step 2 — Create files

touch users.txt logs.txt server.txt

Step 3 — Add users

echo "Sandeep" > users.txt
echo "Rahul" >> users.txt
echo "Amit" >> users.txt
echo "Sandeep" >> users.txt
echo "Priya" >> users.txt

Check:

cat users.txt

Step 4 — Search

grep "Sandeep" users.txt

Step 5 — Count users

wc -l users.txt

Step 6 — Sort users

sort users.txt

Step 7 — Count duplicate users

sort users.txt | uniq -c

Step 8 — Create a backup

cp users.txt users_backup.txt

Step 9 — Rename the backup

mv users_backup.txt backup-users.txt

Step 10 — Check everything

ls -lah

33. Commands You Should Memorize

File & Directory Management

pwd
ls
ls -la
cd
mkdir
touch
cp
mv
rm

File Reading

cat
less
head
tail

Searching

find
locate
grep

Text Processing

sort
uniq
wc
cut
tr
sed
awk

Disk/File Information

file
du
df

Redirection & Combination

>
>>
|

34. Most Important Commands for Linux Admin / DevOps

If your goal is Linux System Administration → AWS → Docker → Jenkins → DevOps, prioritize these:

PriorityCommand/ConceptWhy
⭐⭐⭐⭐⭐lsView files
⭐⭐⭐⭐⭐cdNavigate
⭐⭐⭐⭐⭐cpBackup/copy
⭐⭐⭐⭐⭐mvMove/rename
⭐⭐⭐⭐⭐rmRemove
⭐⭐⭐⭐⭐findFind files
⭐⭐⭐⭐⭐grepSearch logs/text
⭐⭐⭐⭐⭐catRead files
⭐⭐⭐⭐⭐tailMonitor logs
⭐⭐⭐⭐⭐> / >>Output redirection
⭐⭐⭐⭐⭐``
⭐⭐⭐⭐sedReplace/edit text
⭐⭐⭐⭐awkProcess columns
⭐⭐⭐⭐sortSort data
⭐⭐⭐⭐wcCount
⭐⭐⭐⭐cutExtract columns
⭐⭐⭐trTransform text

Your next Linux topic

After File Management & Text Processing, I recommend learning:

Linux Users & Groups → File Permissions (chmod, chown) → Processes → Services/systemd → Package Management → Networking → Logs → SSH → Bash Scripting.

Linux File Management & Text Processing — Beginner Guide

File management and text processing are core Linux skills for a System Administrator, Cloud Engineer, DevOps Engineer, and Linux Administra...