Zum Hauptinhalt springen
••••••••••••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Linux Essentials: How to Create, Read, and Delete Files & Directories Like a Pro

Whether you're just getting started with Linux or refreshing your command-line skills, mastering how to create directories and files, read and append to files,…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Whether you're just getting started with Linux or refreshing your command-line skills, mastering how to create directories and files, read and append to files, and delete files or directories is a fundamental step in your DevOps, Cloud, or SysAdmin journey.



In this guide, I’ll walk you through the most common and useful mkdir, touch, cat, and rm commands—complete with examples and tips.






Table of Contents




  • How to Create a Directory

  • How to Create a File

  • How to Use the cat Command

  • How to Remove/Delete Files or Directories

  • Business Use Case

  • Final Thoughts








How to Create a Directory



The 'mkdir' command is used to create new directories (folders) in Linux.




  • Create a single directory in the root (/) directory:



mkdir /Lucca

ls /



Terminal preview:



Image description




  • Create multiple directories at once:



mkdir /Lucca1 /Lucca2 /Lucca3

ls /



Terminal preview:



Image description




  • Use brace expansion to create a series of directories:



mkdir /GCP{1..10}

ls /



Terminal Preview:



Image description




  • Create nested directories using the -p option:



mkdir -p /Azure/a1/a2

ls /

cd Azure

ls

tree /Azure



Terminal Preview:



Image description








How to Create a File



The 'touch' command creates empty files in Linux.




  • Create a single file:



touch /appv.py

ls /



Terminal preview:



Image description




  • Create multiple files:



touch /appv1.py /appv2.py /appv3.py

ls /



Terminal preview:



Image description




  • Use brace expansion to create a sequence of files:



touch /appv{4..8}.py

ls /



Terminal preview:



Image description








How to Use the cat Command



The cat command is extremely versatile. It can create files, display their contents, or append data.




  • Create and write to a new file:



cat > /Linux.txt



This creates an empty file called Linux.txt;



Then type in the newly created file:

Linux is a super powerful server.

It is open source and very secure.



Press Ctrl + D D to save and exit.

Terminal preview:



Image description




  • Append content to an existing file:



cat >> /Linux.txt



This lets you type new lines into an already existing file.



Type your new lines, then press Ctrl+ D D again to save.

Terminal preview:



Image description




  • Read a file:



cat /Linux.txt or cat < /Linux.txt



This shows or previews the content of an existing file.

I am going to use this command to preview the content of my already

existing Linux.txt, which I created, wrote in it and appended.



Terminal preview:



Image description








How to Remove/Delete Files or Directories



The rm command removes files or directories. Be very cautious when using it, especially with -rf.



Options

-r: recursive (for directories)



-v: verbose (shows what’s happening)



-f: force (no confirmation)




  • Deleting a single file:



rm -rvf /appv.py



This command forcefully deletes the appv.py file and provides

confirmation of deletion.



Terminal preview:



Image description




  • Delete multiple specific files:



rm -rvf /appv1.py /appv2.py /appv3.py



Terminal preview:



Image description




  • Delete files using brace expansion:



rm -rvf /appv{4..8}.py



Terminal preview:



Image description




  • Delete all files or directories matching a pattern:



rm -rvf /Nashville*



Terminal preview:



Image description




  • Delete everything the root directory with a specific extension:



rm -rvf /*.jpg



Terminal preview:



Image description








Business Use Case



In enterprise cloud or DevOps environments, Linux commands play a crucial role in automation and system efficiency. 'mkdir' creates directories for logs and configs during CI/CD, 'touch' generates flag files in scripts, 'cat' reads log data for diagnostics, and 'rm' removes temporary files to optimize resources. Mastering these commands helps streamline operations, enhance security, and reduce cloud costs.








Final Thoughts



These basic commands are essential for day-to-day tasks in Linux, especially if you're:




  • Managing servers.


  • Learning DevOps, Cloud or system administration.


  • Working in cloud environments (like AWS, Azure, or GCP).




Getting comfortable with the command line opens the door to automation, scripting, and working efficiently with infrastructure.



If you found this guide helpful, feel free to connect, share, or drop a comment. Let's keep learning Linux together!

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

ATT&CK-Navigator · IoC-Radar · Exploit-Belege
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Linux Essentials: How to Create, Read, and Delete Files & Directories Like a Pro

Thematisch verwandte Begriffe: Linux, Essentials, Create, Read · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag