Linux Basics for the Aspiring Hacker: Managing Hard Drives « Null Byte :: WonderHowTo

Managing hard drives inLinuxis crucial to understanding your system and its operation as well as understanding the system you are exploiting or conducting aforensic analysison. Linux has numerous commands that can provide us with information, control, and management of hard drives, and in this tutorial, we will examine a number of the most important ones.Hard Drive Designations in LinuxUnlike the C: drive in Windows, Linux does not have a physical drive at its root. Instead, it has a/(slash) at the top (root) of its file system. It then mounts physical drives to this file system either at/mntor/media.Linux uses a logical label for the drives that are then mounted on the file system. These logical labels will vary depending upon when and where they are mounted. This means that the same hard drive might have different labels at different times.Previously:Archiving & Compressing Files in LinuxGenerally, the system for labeling drives starts with:hdahdbhdcetc.The letters "hd" stand forharddrive, and the following letter is the order with which they are mounted. With newer hard drives (SATA), Linux designates them with:sdasdbsdcetc.The "s" is a legacy from SCSI drives. Partitions within those drives are then designated with numbers after the letters such as sda1, sda2, sda3, etc.Step 1: DfAmong the most basic commands in Linux isdf. When we type it, it will provide us with basic information on any hard disks or mounted drives such as CD, DVD, or flash drives. It is usually used to quickly glance at the available space on your drives; that's why "df" stands fordiskfree.kali > dfNote that my virtual disk on this system was designated sda1.sd= SATA drivea= first hard drive1= first partition of that driveAnd my 16 GB flash drive was sdb1 and my external hard drive sdc1.Step 2: FdiskThefdsiskcommand is often used to determine the partitions on the disk. If we use the-lswitch, it will list all the partitions of all of the drives.kali > fdisk -lAs you can see in the screenshot above, it lists sda1, sda2, and sda3 in the first circled stanza. This is the virtual disk from my virtual machine that thisKali Linuxis installed on. Note that it is 25 GB with three partitions including the swap partition (sda3).If we scan a bit down the screenshot to the second stanza, we see a second device output designated sdb1. This is my 16 GB flash drive. Note that fdisk indicates that it is a FAT32 filesystem type.Lastly, we see sdc1 in the third circled stanza. This is my external 1 TB hard drive. Note that fdisk indicates that it is a NTFS file system.Step 3: LsblkIn Linux, devices are categorized as either block or character devices. Character devices are such devices as keyboards and printers. Block devices are hard drives, DVD devices, and flash drives, among others.We have a command,lsblk(list block), that will list some basic information about each of the block devices. It will also display the devices in a kind of tree, showing each device with branches of its partitions. An example would be sda with the branches of sda1, sda2, and sda3.kali > lsblkNote in the output above, it also includes fd0 (floppy drive) and sr0 (DVD drive). Additional information included here is the mount point of the drive. Note that both of my external USB devices are mounted at/media/root.Step 4: PartedThe parted command is capable of displaying your partitions and editing them. We can start by simply typing:kali > partedWhen we do so, it returns an interactive prompt beginning with (parted). From that prompt, we can provide further options and information to parted. For instance, if we wanted to see all the partitions like above, we can type:(parted) printIf we wanted to see the specific information on a single partion, we can useselectfollowed by the partition. For instance:parted select /dev/sdbAs you can see, parted then provided us with just the information on that single partition, my FAT32 16 GB flash drive.To remove a partition, simply typermpartfollowed by the number of the partition such as:(parted) rmpart 5We can use parted to create and edit partitions, but I don't recommend it for beginners—without knowledge and experience, one is likely to cause more damage than good.Finally, to leave the interactive mode of parted, type:(parted) quitStep 5: Hdparmhdparmis a powerful utility that enables us to change and edit the parameters of the hard drive. This can be useful in applications such as forensics, but can be very dangerous without sufficient knowledge. I introduce it to you here as we will be using it inmy forensics seriesin the near future.As you can see from the voluminous help page above, hdparm is capable of altering and editing just about any parameter of your hard drive.To become a professional hacker,you must be competent in Linux. I hopethis serieswill continue to develop your Linux skills, thereby assisting you in your goal of becoming a professional hacker.Keep coming back, my neophyte hackers!Next Up:Using Start-Up Scripts in LinuxFollow Null Byte onTwitter,Flipboard, andYouTubeFollow WonderHowTo onFacebook,Twitter,Pinterest, andFlipboardWant to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseCover image bykozirsky/Shutterstock; Screenshots by OTW/Null ByteRelatedHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 12 (Loadable Kernel Modules)Hack Like a Pro:Digital Forensics Using Kali, Part 2 (Acquiring a Hard Drive Image for Analysis)News:How to Study for the White Hat Hacker Associate Certification (CWA)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 20 (Devices Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 11 (Apache Web Servers)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 13 (Mounting Drives & Devices)How To:The Essential Skills to Becoming a Master HackerHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 6 (Networking Basics)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 21 (GRUB Bootloader)How To:Linux Basics for the Aspiring Hacker: Using Start-Up ScriptsHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 9 (Managing Environmental Variables)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 23 (Logging)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 2 (Creating Directories & Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 25 (Inetd, the Super Daemon)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 17 (Client DNS)How to Hack Like a Pro:Getting Started with MetasploitHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 22 (Samba)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 19 (Linking Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 10 (Manipulating Text)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 8 (Managing Processes)Mac for Hackers:How to Install Kali Linux as a Virtual MachineGoodnight Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingNews:Virtualization Using KVMGoodnight Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingHow To:Bypass Windows and Linux PasswordsCommunity Byte:HackThisSite Walkthrough, Part 5 - Legal Hacker TrainingHow To:Conceal a USB Flash Drive in Everyday ItemsGoodnight Byte:HackThisSite Walkthrough, Part 7 - Legal HackerCommunity Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingNews:The Right Linux DistroNews:Complete Arch Linux Installation, Part 1: Install & Configure ArchHow To:Run Windows from Inside LinuxCommunity Byte:HackThisSite Walkthrough, Part 1 - Legal Hacker TrainingHow To:Install Linux to a Thumb Drive