DEV Community

Cover image for TERMINAL MASTERY: Master Linux File Commands in 10 Minutes Flat!
OLUWADAMILOLA FASHINA
OLUWADAMILOLA FASHINA

Posted on

4 1 1 1

TERMINAL MASTERY: Master Linux File Commands in 10 Minutes Flat!

Give me 10 minutes, and I'll transform you from terminal newbie to command line wizard. Just pure Linux power! Skip the GUI, embrace the terminal, then watch your efficiency and productivity soar.

What to expect

Introduction

Before you launch Kubernetes clusters or build CI/CD pipelines, you NEED these fundamental skills. File operations are the building blocks of DevOps greatness. This isn't optional, it's the secret weapon that separates pros from pretenders.

Think your GUI is faster? Think again. Terminal masters accomplish in seconds what takes GUI users minutes.

Directory Domination: Create Directories like a pro

# mkdir is used to create directory (folder).

  • Single Directory Creation:
# mkdir /project_team
Enter fullscreen mode Exit fullscreen mode

file commands

Just like that, directory created.

  • Multi-Directory Magic:
# mkdir /admin /technology /operands
Enter fullscreen mode Exit fullscreen mode

multi-directory

Three directories, one command. Efficiency unleashed!

  • Pattern Creation:
 # mkdir /project{1..5}
Enter fullscreen mode Exit fullscreen mode

Imultidirectory

BOOM! You just generated project1 through project5 instantly.

  • Nested Directory Superpowers: Creating a directory inside a directory (parent/permissive)
# mkdir -p deployment/kubernetes/services/config
Enter fullscreen mode Exit fullscreen mode

Nested

The -p flag is your recursive superpower. Entire directory trees spawned with a single command.

Tip: Use meaningful directory names. Future-you will thank present-you.

File Creation Mastery

  • Create empty Files in an instant with # touch
# touch /server
Enter fullscreen mode Exit fullscreen mode

server

Empty file, ready for action.

  • Multiple File Creation
# touch /input /output /screen
Enter fullscreen mode Exit fullscreen mode

touch

Three files, one command. Well-done!

  • Sequential Pattern Creation
# touch /log{1..10}.txt
Enter fullscreen mode Exit fullscreen mode

log

Just created 10 log files in less time than it takes to click "New" in a GUI.

The Cat Command: Create, Write, Read in one tool

This command allows to create, read & add Content but not edit.

  • Create & Write Content with # cat >
# cat > deployment.txt
Enter fullscreen mode Exit fullscreen mode

create and write

(Press Ctrl+d twice to save)

  • Add More Content (Append Mode)
# cat >> /deployment.txt
Enter fullscreen mode Exit fullscreen mode

append

(Press Ctrl+d twice to save)

  • Read File Contents
# cat < /deployment.txt
Enter fullscreen mode Exit fullscreen mode

read

View your creation in all its glory.

Copy Files with Surgical Precision

Understanding the flags (options):
-r: recursive (for directories)
-v: verbose (shows what's being copied)
-f: force (overwrite without asking)

  • Basic File Copy # cp <option> <source path> <destination path>
# cp -v /log1.txt /cloud
Enter fullscreen mode Exit fullscreen mode

cp

Copy with -v (verbose) to see exactly what's happening.

  • Copy Entire Directories
# cp -rv /project /sbin
Enter fullscreen mode Exit fullscreen mode

s

The -r flag recursively copies everything within the directory.

  • Pattern-Based Copy
# cp -rvf *.txt /etc
Enter fullscreen mode Exit fullscreen mode

pattern

Copy all text files in one swift command.

  • Sequential Copy Operations
cp -rvf log{1..5}.txt /var
Enter fullscreen mode Exit fullscreen mode

sequence

Copy multiple numbered files with a single command.

Delete with Confidence (and Caution!!!)

Delete with # rm

  • Single File Removal
# rm -rvf /deployment.txt
Enter fullscreen mode Exit fullscreen mode

single

  • Multiple File Deletion in a Sequence
# rm -rvf /log{1..5}.txt
Enter fullscreen mode Exit fullscreen mode

sequence

  • Directory Deletion
# rm -rvf /project_team
Enter fullscreen mode Exit fullscreen mode

rm directory

  • Pattern-Based Cleanup
# rm -rvf /log*
Enter fullscreen mode Exit fullscreen mode

Pattern

  • DANGER ZONE: Handle with extreme care

rm -rvf /* - DELETES EVERYTHING IN CURRENT DIRECTORY

NEVER run this without absolute certainty of your current directory!

Move & Rename: The Versatile MV Command

  • Rename a File
mv /log1.txt /pro1.txt
Enter fullscreen mode Exit fullscreen mode

move

Simple. Powerful. Done.

Practical Challenge: Build a simple project from scratch

Let's put it all together with a simple real-world project structure:

  • Create the project structure

project structure

  • Create configuration file

Config

  • Add Content to Linux file (Do not forget Ctrl+d twice)

Content

  • Create deployment script

deploy

  • Make script executable

executable

  • Copy Configurations to a backup location

backup

  • List your project Structure

find

Congratulations: You're now a Terminal Master!

If you've made it this far, you're no longer a CLI novice. You've mastered the most essential Linux file operations that DevOps Engineers, System Administrators, and Cloud Architects use daily.

Connect with me

Did this save you hours of boring documentation reading? Follow me for more concise, practical Linux and DevOps guides that deliver immediate results!

Connect with me on LinkedIn

Drop a like if this helped you level up your terminal game!

#30DaysLinuxChallenge #CloudWhistler #RedHat #CloudJourney #DevOps #Linux #OpenSource #CloudComputing #WomenInTech #RedHatEnterpriseLinux #ITInfrastructure #Terminal #Filecommands #CLI #TerminalMastery #SysAdmin #Automation #CloudEngineer #CloudArchitect

Top comments (0)