"Linux Day 3 :Managing Files, Navigation Paths, and Directories in Linux 🖥️."

Shreyash MyakalShreyash Myakal
3 min read

Linux provides a powerful command-line interface (CLI) to manage files and directories efficiently. Whether you're a beginner or an advanced user, mastering file operations and navigation commands is essential.

1. Navigating Directories

pwd - Print Working Directory

1) cd - Change Directory

cd /home/user/Documents # Go to Documents folder
cd .. # go to previous directory
cd,cd ~ # go to home directory
cd - # Switch to the previous directory

2) ls - List Directory Contents

ls # List files
ls -l # Detailed list with permissions
ls -a # Show hidden files
ls -lh # Human-readable file sizes
ls ~ # list of user home directory
ls -d # list of specific directory

2. Managing Files and Directories

1) touch - Create a New File

touch fille-name # create a empty file and modify
touch file{1..10} # create empty file from 1 to 10

2) mkdir - Create a Directory

mkdir # make a directory
mkdir -p month{jan,feb} # create dir in some directories

3) rm- Remove Files or Directories

rm file.txt # Remove a empty file
rm mkdir # Remove a empty directory
rm -r file/dir # Remove file/dir having data
rm * .txt # Remove all files ending with txt
rm my* # Remove all directories starting with my
rm -rvf # Remove file forcefully

4) cp - Copy Files and Directories

cp source destination # copy file to destination
cp source1 source2 destination # copy multiple files to destination
cp -r dir1 destination # copy directory to destination

5) mv - Move or Rename Files

mv oldname.txt newname.txt # Rename a file
mv file1 file 2 # Move file to another directory
mv dir1 dir 2 # if dir2 is present it will move to dir2 or it will create and then move

3. Viewing and Editing Files

1) cat - It is use for multiple purpose to create to modify to write read a file.

cat file-name # read a file
cat > file-name # create and write in file
cat >> file-name # to append the data in file

2) nano

nano file-name # create and write in file

3) vim

vim file-name # create and write in file

Linux provides a powerful command-line interface for managing files and directories efficiently. This article covers essential operations like navigating directories using commands such as `pwd`, `cd`, and `ls`, managing files and directories with `touch`, `mkdir`, `rm`, `cp`, and `mv`, and viewing and editing files using tools like `cat`, `nano`, and `vim`. Whether you're looking to improve your basic command-line skills or enhance advanced file manipulation techniques, mastering these commands will help you operate effectively in a Linux environment.

0
Subscribe to my newsletter

Read articles from Shreyash Myakal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shreyash Myakal
Shreyash Myakal

I’m currently learning Linux, AWS, DevOps, MySQL, and related technologies, aiming to become a Cloud Engineer. Passionate about cloud infrastructure and automation, I’m excited to apply these skills in real-world projects.