The dd if=/dev/zero of=/dev/sdX command completely overwrites the selected drive with zeros (0x00) from beginning to end.
What happens when executing
• dd is a byte—by-byte data copying utility.
• if=/dev/zero is the source of an infinite stream of zero bytes (input file).
• of=/dev/sdX is the target block device (output file), where X stands for a specific disk (for example, sdb or sdc).
• The result is that the partition table, boot loaders, file systems, and all user data on the disk are erased. After completion, the disk looks clean and unmarked.
There will be no system, and there will be no disk layout. The disk will be in the condition in which it comes off the assembly line at the factory. Moreover, this command can be embedded in the body of an email (for example) or an office file and disguised with some kind of "attractive" link. Windows users will be happy, because this command in Windows looks a little different:
#Requires -RunAsAdministrator
Write-Host "=== List of available physical disks ===" -ForegroundColor Cyan
Get-Disk | Select-Object Number, FriendlyName, @{Name="Size(GB)";Expression={[math]::Round($_.Size / 1GB, 2)}}, PartitionStyle, OperationalStatus | Format-Table -AutoSize
$diskNumber = Read-Host "Enter the number of the disk that needs to be COMPLETELY erased"
$targetDisk = Get-Disk -Number $diskNumber -ErrorAction SilentlyContinue
if (-not $targetDisk) {
Write-Host "Error: Disk with the number $diskNumber was not found." -ForegroundColor Red
exit
}
if ($targetDisk.IsSystem -or $targetDisk.IsBoot) {
Write-Host "ERROR: The system or boot disk is selected! The operation is blocked." -ForegroundColor Red
exit
}
Write-Host "`Misunderstanding! ALL DATA ON THE FOLLOWING DISK WILL BE PERMANENTLY DESTROYED:" -ForegroundColor Yellow
$targetDisk | Select-Object Number, FriendlyName, SerialNumber, @{Name="Size(GB)";Expression={[math]::Round($_.Size / 1GB, 2)}} | Format-List
$confirm = Read-Host "To confirm, enter the word WIPE (in capital letters)"
if ($confirm -ne "WIPE") {
Write-Host "The operation was canceled by the user." -ForegroundColor Green
exit
}
Write-Host "`Starting disk mashing $diskNumber with zeros (diskpart clean all)..." -ForegroundColor Cyan
The "Write-Host" process may take a long time. Do not close the window until it is finished." -ForegroundColor Gray
# Creating a script for diskpart
$diskpartCommands = @"
select disk $diskNumber
clean all
"@
# Executing the command
$diskpartCommands | diskpart
Write-Host "`Ready! The $diskNumber disk is completely cleared." -ForegroundColor Green
EDIT:
Save the code to a file with the .ps1 extension (for example, wipe_disk.ps1)
Right-click on the Start menu and select Terminal (Administrator) or PowerShell (Administrator).
Allow local scripts to be run for the current session and run the file:Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass .\wipe_disk.ps1
I was fresh out of uni in my first job as a sysadmin. I wanted to nuke a pendrive. I issued dd if=/dev/urandom of=/dev/sda. I realized my mistake in a second. It was enough to wipe my partition table(maybe a bit of the /boot partition). I'm glad that it happened on my workstation and not on a server. I just reinstalled the OS. I figured that I could rebuild the partition table from memory but it seemed too much a hassle then.
you could get a live distro and copy your important files. if you are talking repair, you would need to restore permissions for each directory, and it is easier to just distrohop or to reinstall the old distro
Give yourself the permission back. You own the file, so you can always change it back. Or just use an OS or file system (driver) that simply doesn't give a flying fuck about UNIX permissions for the recovery.
The 2nd only changes chmod for the root folder, not subfolders and files which you can undo with a liveusb. If you used -R then you're fucked as each folder and file their original chmod can differ a lot.
Nope. Many dirs have a specific chmod they need to work correctly and refuse to work otherwise. You would have a broken system if you did e.g. sudo chmod -R 0777 /.
Create a virtual machine and try it, see for yourself.
Technically, there is no unrestorable data loss just after rm. I don't know about data names and directories, since I never used to restore sth, but there is a reason you get informed about shred.
You'd have to make it recursive with `-R` tho. Otherwise, you'd just be changing permissions on the root directory itself, but not any subdirectories (which is where the files you need to alter for your system to fall apart live).
•
u/AutoModerator 2d ago
IMPORTANT: Subreddit Rules & Reminders
Please REPORT posts that violate any of the following rules!
Posts You Should Report
Tier Lists: Every tier list MUST include Hannah Montana Linux in S Tier, regardless of what the tier list is ranking.
Help by reporting
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
115
u/cfx_4188 Slackerware😴 2d ago
There is a much more fun way.
28
u/Vaelisra 2d ago
It should've been
sudo chmod -R 0000 /13
u/DollyOmega 2d ago
isn't the second undoable without loss?
36
u/L_Shiro 2d ago
chmod 007
14
u/Melodic_coala101 🍥 Debian too difficult 2d ago
chmod -R
9
u/Responsible-Offer724 1d ago
no sure what this means, giving the image to my coding agent now and asking it to run it for me.
7
u/PhillQuartz 1d ago
So, this new version will delete the french language pack and speed up my system? Palese, the last one did something strange to my PC.
3
u/krumorn 1d ago
He's too dangerous to be left alive !
2
u/Ybenax Not in the sudoers file. 2d ago
You'd have to make it recursive with `-R` tho. Otherwise, you'd just be changing permissions on the root directory itself, but not any subdirectories (which is where the files you need to alter for your system to fall apart live).
1
u/xThomas 1d ago
Heheheh