- Безопасное удаление файлов и каталогов из Mac OS X с помощью командной строки 2021
- The Impossible Cat — How to install the OS X 10.6 Snow Leopard PowerPC Beta on G4 Macs
- Только для опытных пользователей
- Безопасное удаление файла с помощью srm
- Безопасное удаление всего каталога
- Принудительное безопасное удаление чего-либо
- Принудительно и безопасно удалить заблокированный или принадлежащий файл с суперпользователем
- Как насчет безопасного удаления всего?
- Secure Remove Files & Directories from Mac OS X with the Command Line
- For Advanced Users Only
- Secure Remove a File with srm
- Secure Delete an Entire Directory
- Force Secure Delete Anything
- Forcibly & Securely Remove a Locked or Owned File with Super User
- What About Securely Deleting Everything?
- How to Delete a File in Terminal on Your Mac
- Use the command line to permanently delete files from a Mac
- What to Know
- What Is Terminal?
- How to Delete a File in Terminal on Your Mac
- Master the macOS command line: How to delete files and folders using Terminal
- Why bother deleting files with the command line?
- How to delete files
- How to delete empty directories (a.k.a folders)
- How to delete everything in a directory
- Can’t empty Trash in the Finder? Use the Terminal
Безопасное удаление файлов и каталогов из Mac OS X с помощью командной строки 2021
The Impossible Cat — How to install the OS X 10.6 Snow Leopard PowerPC Beta on G4 Macs
Насколько безопасен srm? Что ж, по умолчанию для безопасного удаления используется невероятно безопасный 35-проходный метод, который использует «35-проходный алгоритм Гутмана», что в основном означает, что сначала данные удаляются, а затем записываются более 35 раз с использованием случайно сгенерированных шаблонов, что делает восстановление буквально буквально. невозможно. Для некоторого сравнения того, насколько это безопасно, srm также имеет параметр «среднего» параметра, который использует 7-проходную защиту, а 7-проходной соответствует стандарту Министерства обороны США для безопасного стирания данных… таким образом, теоретически, по крайней мере, 35 проходных Этот метод в 7 раз более безопасен, чем то, что Министерство обороны США принимает в качестве стандарта для безопасного удаления данных. Мы не собираемся сосредотачиваться на среднем варианте, мы будем использовать srm, как и предполагалось, с полным 35-проходным удалением данных.
Только для опытных пользователей
Это не называется «безопасное удаление» без причины, это называется потому, что если файл был удален с помощью безопасного удаления, вы в буквальном смысле никогда не сможете восстановить этот файл с диска. Период. Это выходит далеко за рамки основных приемов очистки корзины или даже принудительного удаления и удаления файлов. Пользователям, которым неудобно пользоваться командной строкой, но которые хотят сохранить параметры безопасного удаления файлов, следует рассмотреть возможность использования простого метода безопасного удаления или использования параметра «Всегда защищенный пустой мусор», который вместо этого доступен для Mac OS X Finder. Вы были предупреждены, действуйте с осторожностью!
Безопасное удаление файла с помощью srm
В самом простом, команда srm используется просто, указывая ее на файл или путь к файлу:
Поскольку в параметре по умолчанию используется 35 проходов, удаление файла может занять одну или две минуты, а удаление больших файлов займет больше времени, поскольку для перезаписи файла и предотвращения восстановления используются проходы одинакового размера.
Безопасное удаление всего каталога
Флаг -r может быть применен к srm, чтобы рекурсивно удалять его, тем самым применяя к каталогам и их содержимому:
srm -r /path/to/directory/
Опять же, удаление может занять одну или две минуты, потому что после удаления все перезаписывается 35 раз.
Принудительное безопасное удаление чего-либо
Флаг -f добавляет принудительное удаление в srm. Это одна из наиболее «опасных» команд, потому что она похожа на «rm -rf» на стероидах, что означает, что она принудительно удалит все, на что она указывает, без какого-либо запроса, за исключением того, что добавление безопасного удаления гарантирует, что удаленный файл никогда не будет абсолютно возмещена. Используйте с особой осторожностью .
srm -rf /file/to/destroy/from/everything
Из-за огромного преимущества комбинации флагов -rf она должна использоваться только опытными пользователями и с абсолютной точностью.
Принудительно и безопасно удалить заблокированный или принадлежащий файл с суперпользователем
Приставляя sudo к приведенному выше варианту -rf-флага srm, вы можете применять привилегии суперпользователя (root) к процессу принудительного удаления файлов и каталогов, тем самым перезаписывая любые проблемы с владением или блокировку файлов. Это так же безопасно и так же опасно, как и из-за доступа суперпользователя. Используйте с особой осторожностью и не используйте это, если вы не знаете, что вы делаете и почему вы делаете это:
sudo srm -rf /path/to/something/to/obliterate/from/existence/
Опять же, это только для опытных пользователей и должно быть ограничено точными путями к файлам и каталогам.
Как насчет безопасного удаления всего?
Хотя srm принимает подстановочные знаки, при таком подходе, очевидно, существует огромный потенциал для ошибок, и он не форматирует диск. Таким образом, если вы хотите надежно удалить все данные на компьютере, с внутреннего загрузочного диска на внешний диск любого типа, вам будет гораздо удобнее использовать инструменты безопасного форматирования для всего диска, связанного с диском. Утилита, которая предоставляет возможность 35-проходного безопасного форматирования.
Источник
Secure Remove Files & Directories from Mac OS X with the Command Line
Need to securely delete a file, group of files, or an entire directory, insuring that it’s quite literally never recoverable by any known possible means? You can do this easily from the command line with the help of an incredibly powerful tool called srm. srm, as you may have guessed, stands for ‘secure removal’, and is a secure version of the commonly used ‘rm’ command that exists in virtually every flavor of unix, Mac OS X included. Be advised this utility is not for everyone and certainly not for novice users, srm should be considered an advanced tool, and it’s best used by those who are comfortable with the command line and understand the data repercussions of secure delete functions.
How secure is srm? Well, the default for secure remove is the incredibly secure 35-pass method which uses the “35-pass Gutmann algorithm”, that basically means that first the data is removed, then written over 35 times using randomly generated patterns, making recovery quite literally impossible. For some comparison on how secure that is, srm also has a “medium” option setting which uses 7-pass security, and 7-pass meets the US Department of Defense standard for securely erasing data… thus, theoretically at least, the 35 pass method is 7 times more secure than what the US DoD accepts as their standard for secure data removal. We’re not going to focus on the medium option though, we’re going to use srm as it was intended to be used, with full 35-pass data removal.
For Advanced Users Only
This isn’t called “secure remove” for no reason, it’s called that because if a file has been deleted with secure remove, you will quite literally never be able to recover that file from the drive. Period. This is going far beyond the basic tricks of emptying the Trash or even forcibly trashing and removing files that way. Users who are not comfortable with the command line but who want to retain secure file removal options should consider using a simple method of secure deletion, or by using the “Always Secure Empty Trash” option that is available to the Mac OS X Finder instead. You have been warned, proceed with caution!
Secure Remove a File with srm
At it’s most simple, the srm command is used just by pointing it at a file or file path:
Because the default option uses 35-pass, file removal can take a moment or two, and larger files will take longer to delete because passes of equal size are being used to overwrite the file and prevent recovery.
Secure Delete an Entire Directory
The -r flag can be applied to srm to make it delete recursively, thereby applying to directories and their contents:
srm -r /path/to/directory/
Again, deleting may take a moment or two because everything is being overwritten 35 times after it’s been deleted.
Force Secure Delete Anything
The -f flag adds force removal to srm. This is one of the more ‘dangerous’ commands because it’s like ‘rm -rf’ on steroids, meaning it will forcibly delete everything it’s pointed out, without any prompt, except that the addition of secure deletion insures that the removed file is absolutely never recoverable. Use with extreme caution.
srm -rf /file/to/destroy/from/everything
Because of the immense strength behind the -rf flag combination, it should only be used by advanced users and with absolute precision.
Forcibly & Securely Remove a Locked or Owned File with Super User
By prefixing sudo to the above -rf flag variation of srm you can apply super user (root) privileges to the forced file and directory removal process, thereby overwriting any ownership issues or file locking. This is as secure and as ‘dangerous’ as it gets because of the superuser access. Use with extreme caution and do not use this is unless you know what you’re doing and why you’re doing it:
sudo srm -rf /path/to/something/to/obliterate/from/existence/
Again, this is for advanced users only and should be limited with precise file and directory paths.
What About Securely Deleting Everything?
Though srm accepts wildcards, there is obviously giant potential for mistakes with such an approach, and it doesn’t format the drive. Thus, if you’re looking to securely delete every single thing on a computer, from an internal boot disk to an external drive of any type, you would be much better served using the secure format tools for an entire drive that are bundled within Disk Utility, which provide the option of 35-pass secure formatting.
Источник
How to Delete a File in Terminal on Your Mac
Use the command line to permanently delete files from a Mac
What to Know
- In a Finder window, go to Applications >Utilities, type rm, space, drag the file to the Terminal window, and press Enter.
- You can also press Command+Space to open Spotlight, type terminal, and press Enter to access the Terminal window.
In this guide, we show you how to delete a file in Terminal on Mac computers with macOS and OS X Lion (10.7) and later.
What Is Terminal?
Terminal is an app that comes with every Mac. It’s a way to use the command line on the Mac. It allows you to modify settings, files, and other features beyond what is available in the graphical user interface (GUI). The command line offers you total command of your Mac, from the inside out.
Why should you use Terminal? Here are a few of the key benefits of using Terminal for Mac:
- It rings true to Unix: Mac users coming over from Unix will find Terminal easier to use due to its similarity.
- It allows you to unlock all preference settings: Everything you can customize can be unlocked using Terminal, even things you can’t access through the GUI.
- It cuts down on clicks: Want to move all your files from one folder to another? A few seconds of typing in Terminal is all you need, versus the time and clicks it takes to transfer files manually.
- It helps you remove files with ease: If you want to remove a file from your Mac forever, you can skip the Trash and use Terminal. It’s quick, only taking a few seconds.
The Terminal is a dangerous place if you’re inexperienced in the command line. Before you enter Terminal, familiarize yourself with the basic commands. One wrong command can damage your system.
How to Delete a File in Terminal on Your Mac
Whether you’re dealing with a problem file that refuses to leave your Mac or you want to delete multiple files quickly, Terminal makes it quick and easy. Here’s how:
Navigate to Terminal on your Mac by opening a Finder window and selecting Applications > Utilities.
You can also press Command+Space to open Spotlight. Then, type terminal and press the Enter key.
In the Terminal window, type rm and a space. Next, drag the file you want to delete into the Terminal window.
Press Enter, and the file is gone forever.
Want to go faster? Remove the file by entering the path to the file into Terminal, without the drag and drop.
There you have it. Harness your new power to delete files easily, but remember to use it with care.
Источник
Master the macOS command line: How to delete files and folders using Terminal
When it comes to quickly taking care of daily tasks, the command line can be both powerful and dangerous. Take the commands in this article as an example: the rm command allows you to remove (or delete) files. The rmdir command does the same to directories (also know as folders). But be careful: Unlike when you move files to the Trash from the Finder, there’s no way to get them back if you use these commands.
Still, if you want to tap into Terminal’s powers, this is a command you can’t overlook. I’ll show you how to add a safeguard to ensure that you only delete files you really want to delete.
Why bother deleting files with the command line?
Deleting files with the Finder isn’t too difficult, plus you can always fish files out of the Trash if you change your mind. So why bother using the command line? Here are some reasons:
- You can use wildcards to delete multiple files quickly and efficiently.
- You can remove files from the Trash when you encounter stubborn errors.
- You can delete files that are hidden in the Finder. These files, which can contain settings for certain apps or parts of macOS, contain a dot (.) before their names and the Finder doesn’t show them.
- If you’ve lost access to the Finder because your Mac is on the blink, you might be able to use the command line to troubleshoot the problem.
How to delete files
It’s dangerously easy to delete files with the rm command. Here’s an example. After you launch Terminal (in your /Applications/Utilities folder) type cd
/Desktop to navigate to the Desktop directory. To delete a file, type rm filename , replacing filename with the actual name of the file you want to delete. (If you have a file name with spaces, you need to put the name in quotes: «For Example.txt» .) If you had a file here named MyFile.rtf that you never, ever wanted to see again, you could run this command:
rm MyFile.rtf
When you press Return, the file will go poof! The Mac doesn’t confirm if you want to delete the file. It will be gone, toast, history. You can’t get it back.
You can even delete multiple files in a single command. If you have three files on your Desktop that you want to delete, and you want to delete them all at once, you can do so like this (if you have a file name with spaces, you need to put the name in quotes: «For Example.txt» .):
rm MyFile.rtf MyCV.rtf MyGreatAmericanNovel.rtf
Again, pressing the Return key does the dirty work.
It’s worth repeating: this command deletes files. It nukes them. You can’t get them back. You can’t click on the Trash icon and retrieve files you’ve accidentally deleted.
But there is a safety net: it’s the -i (interactive) flag. So if you’re feeling cautious, you could run the above commands with this flag as follows:
Or, in the case of deleting multiple files:
rm -i MyFile.rtf MyCV.rtf MyGreatAmericanNovel.rtf
In each case, pressing Return won’t actually activate the rm command, because the -i flag acts as a pause button. You’ll see the following in Terminal when running these commands:
In order to proceed, you need to type yes , or simply y . In the case of multiple files, you’ll see one query for each file. Granted, it’s easy to get into the habit of quickly typing y , but the question is intended to make you stop and think very carefully about whether you really want to delete that file.
How to delete empty directories (a.k.a folders)
Deleting directories, or folders, is a bit different. If you try to run the rm command on a directory, you’ll see the following message:
You can’t delete a directory using the rm command.
There’s a special command for deleting directories: rmdir . So to delete a directory named Archives, run this command (If you have a directory name with spaces, you need to put the name in quotes: «For Example» .):
rmdir Archives
You can’t use the -i flag with the rmdir command, so the command is a bit riskier.
Note that this command only deletes empty directories. If you want to delete a directory and the files it contains, read on.
How to delete everything in a directory
The rm command has a powerful option, -R (or -r ), otherwise known as the recursive option. When you run the rm -R command on a folder, you’re telling Terminal to delete that folder, any files it contains, any sub-folders it contains, and any files or folders in those sub-folders, all the way down. You enter the command as m -R directoryname , where you substitute directoryname for the name of the directory you want to delete. (If you have a directory name with spaces, you need to put the name in quotes: «For Example» .)
For example, let’s say you have a directory full of archives, containing sub-directories and files. Deleting each item individually from the Finder or the command line can take a long time. So just run the command like this:
rm -R Archives
Remember, this deletion is final. But you can use the -i flag for protection:
rm -iR Archives
This will ask you to confirm the deletion of each item. This can be annoying, but unless you’re really sure you want to delete all those files, it’s probably best to be safe.
Can’t empty Trash in the Finder? Use the Terminal
When can the rm -R command come in handy? Say you can’t empty the Trash on your Mac. A file might be locked or you may not have permission to delete one or more files. This sort of glitch is annoying, but you can use the command line to provide an easy solution.
In Terminal, type the following:
rm -R
Then type a space.
In the Finder, open the Trash, and then drag the items it contains to the Terminal window. You’ll see one or more files with paths such as /Users/.Trash/file.txt.
If there are lots of files, you may find that the resulting list—all on one long line, wrapping in the Terminal window—may be very long. If you’re absolutely sure that you want to delete all these items, press Return. Terminal will empty the Trash. Command line win!
Источник