i KILLED my Linux computer!! (to teach you something)

i KILLED my Linux computer!! (to teach you something)

How to Create Over 1 Million Directories in Linux?

Introduction to the Challenge

  • The speaker introduces a challenge of creating over 1 million directories in Linux, motivated by curiosity rather than necessity.
  • Clarifies that the experiment was conducted on a computer owned by Hack The Box Academy, not their personal device.

Hack The Box Academy Overview

  • Encourages viewers to sign up for Hack The Box Academy, which offers free access to a lab environment for practicing Linux skills.
  • Highlights various learning paths available at Hack The Box Academy, including skill and job role paths aimed at aspiring cybersecurity professionals.

Getting Started with Linux Commands

  • Advises viewers to set up their own lab environment after signing up for Hack The Box Academy.
  • Emphasizes the importance of launching the terminal as a primary tool for executing commands in Linux.

Creating Files in Linux

  • Introduces the touch command for creating files, demonstrating its use with an example file named "can't touch this.txt".
  • Shows how multiple files can be created simultaneously using touch, enhancing efficiency in file management.

Advanced File Creation Techniques

  • Explains how to create files containing text using the cat command, illustrating it with practical examples.
  • Demonstrates multiline input into a file using cat and custom end-of-file markers (EOF), showcasing flexibility in file creation.

Quick File Creation Method

  • Presents an efficient one-liner method using echo to create files with content directly from the command line.

Creating and Managing Directories in Linux

Introduction to Directory Management

  • The speaker introduces various methods for creating files, emphasizing their relevance in scripting and practical use.
  • A directory is explained as a folder, with a humorous note on the terminology differences between Windows and Linux.

Creating Directories

  • The command mkdir (make directory) is introduced, demonstrating how to create a new directory named "cool stuff."
  • The speaker discusses color coding in terminal outputs, noting that directories are visually distinct from files but shares personal challenges due to color blindness.

Understanding File Types

  • The first letter of file information indicates whether an item is a directory ('D') or a file (dash), providing clarity beyond color distinctions.

Moving Files into Directories

  • The mv command (move) is presented as a simple way to relocate files. An example shows moving "file.txt" into the "cool stuff" directory using relative paths.
  • Emphasis on the importance of specifying the current working directory with ./ when moving files to avoid permission errors.

Renaming Files During Movement

  • Demonstrates how to move and rename "stuff.txt" simultaneously by specifying a new name while moving it into the "cool stuff" directory.

Bulk Moving Files

  • The ability to move multiple files at once is highlighted, showcasing efficiency in managing file organization within directories.

How to Copy and Move Files in Linux

Copying Files

  • The process of copying files is introduced, emphasizing the importance of backing up files before making changes.
  • The command cp is used for copying files. An example shows how to copy "can't touch this.txt" into a directory called "cool stuff."
  • Users can also rename a copied file by specifying a new name during the copy process, demonstrated with "you can touch this.txt."
  • A backup file can be created in the same directory using a different name, such as changing ".txt" to ".bk" for backup purposes.
  • Participants are encouraged to move any extra files into the "cool stuff" directory for organization.

Creating Directories

  • The mkdir command is introduced for creating directories, with an explanation of the -p switch that allows creating parent and child directories simultaneously.
  • A demonstration shows how multiple nested directories can be created using the mkdir -p command.
  • The tree command provides a visual representation of the current working directory structure, showcasing all created directories.

Moving and Copying Directories

  • Moving directories follows similar syntax as moving files; an example demonstrates moving "cool stuff" into another directory.
  • To copy directories containing files, users must use the recursive option (cp -R) to ensure all contents are included in the copy operation.
  • A successful execution of copying a directory confirms that all sub-files are replicated correctly within the new location.

Deleting Files

  • The session transitions towards deleting files, indicating that participants will learn how to remove unwanted items from their system.

How to Remove Files and Directories in Linux

Basic File Deletion Commands

  • The command to delete a file in Linux is rm, followed by the filename. For example, rm please_don't_delete_me will remove the specified file.
  • Multiple files can be deleted at once using the same command format. For instance, creating several files named "please don't delete me" and then removing them with rm is straightforward.

Removing Directories

  • To remove a directory, use the command rmdir or rm -d. However, if the directory contains files, it cannot be removed without additional options.
  • Attempting to remove a non-empty directory with rmdir will result in an error message indicating that the directory is not empty. This feature protects users from accidental data loss.

Recursive Deletion of Directories

  • To delete a non-empty directory along with its contents, use the command rm -r <directory_name>. This performs a recursive deletion of all files and subdirectories within it.
  • Caution is advised when using this command as it permanently deletes everything within the specified directory without recovery options.

Forceful Deletion Command

  • The command rm -rf <directory_name> combines recursive deletion with forceful execution. The -f option ignores warnings about non-existent files or directories.
  • Using this command can lead to significant data loss; hence it's crucial to ensure you are on a temporary or test machine before executing it.

Important Precautions

  • Before running destructive commands like rm -rf /, ensure you have proper permissions (using sudo if necessary), and confirm that you're operating on an ephemeral system where data loss won't affect critical operations.
  • Users should never execute such commands on personal or production machines unless they are fully aware of potential consequences.

Creating Nested Directories

  • The command for creating multiple nested directories is mkdir -p <path>, which allows for parent directories to be created alongside child directories efficiently.
  • There may be limits on how many child directories can be created at once due to system constraints; typically around 600 in one go depending on system settings.

Creating a Massive Directory Structure with Bash Scripting

Overview of the Script Creation

  • The speaker describes using bash scripting to create a script that generates multiple parent directories, specifically 600 in each iteration, repeating this process approximately 1500 times.
  • A simple for loop is utilized in the script to automate the directory creation, showcasing basic programming skills and efficiency.

Execution of the Script

  • After saving and running the script, the speaker notes it takes some time to complete. They express anticipation about seeing the results.
  • Upon completion, they use the tree command to visualize the extensive directory structure created by their script.

Visualizing Results

  • The output reveals an astonishing total of 1,116,017 directories generated, which prompts a humorous reflection on the absurdity of such an endeavor.
  • The speaker likens navigating through this vast number of directories to being lost in a forest filled with trees and branches, emphasizing both confusion and amusement at their own creation.
Video description

Access your FREE Linux lab here: https://ntck.co/htbacad (HTB Academy) Have you ever wanted to destroy Linux or even create more directories than you could imagine? Well in this video, NetworkChuck shows you how to break your linux box as well as how to create a million directories!! He also shows you some helpful commands too…. But we know why you’re here. Checkout HTB: -HTB: https://ntck.co/htb -HTB Academy: https://ntck.co/htbacad 🔥🔥Join the NetworkChuck Academy!: https://ntck.co/NCAcademy **Sponsored by Hack The Box SUPPORT NETWORKCHUCK --------------------------------------------------- ➡️NetworkChuck membership: https://ntck.co/NCAcademy ☕☕ COFFEE and MERCH: https://ntck.co/coffee Check out my new channel: https://ntck.co/ncclips 🆘🆘NEED HELP?? Join the Discord Server: https://discord.gg/networkchuck STUDY WITH ME on Twitch: https://bit.ly/nc_twitch READY TO LEARN?? --------------------------------------------------- -Learn Python: https://bit.ly/3rzZjzz -Get your CCNA: https://bit.ly/nc-ccna FOLLOW ME EVERYWHERE --------------------------------------------------- Instagram: https://www.instagram.com/networkchuck/ Twitter: https://twitter.com/networkchuck Facebook: https://www.facebook.com/NetworkChuck/ Join the Discord server: http://bit.ly/nc-discord 0:00 ⏩ Intro 0:57 ⏩ Get your free Linux lab! 2:10 ⏩ Let’s get to our happy place! 2:22 ⏩ Time to touch some files 3:30 ⏩ a new way to use cat? 4:43 ⏩ echo “How to use echo to create a file with text inside” - Thistimestamp.txt 5:49 ⏩ Now let’s make some folders… I mean directories 7:36 ⏩ Time to mv some stuff 10:53 ⏩ You can’t cp this! 12:36 ⏩ How to make a million directories! 15:38 ⏩ Ready to destroy some stuff? 20:05 ⏩ Time to really make a million directories! 21:51 ⏩ Outro AFFILIATES & REFERRALS --------------------------------------------------- (GEAR I USE...STUFF I RECOMMEND) My network gear: https://geni.us/L6wyIUj Amazon Affiliate Store: https://www.amazon.com/shop/networkchuck Buy a Raspberry Pi: https://geni.us/aBeqAL #linux #linuxforhackers #hacking