- Video Recovery
- SD Card Recovery
- Recycle Bin Recovery
- Recover Data from USB
- Recover Deleted Emails
- Hard Drive Not Showing Up in Windows
- Recover Unsaved Word Documents
- Recover Deleted Files in Windows 10/11
- Recover Files from Virus Infected Hard Drive
- Best Free Photo Recovery Software
- Recover Files from Formatted Hard Drive
Learning how to utilize the Linux command line is a must-have skill for all Linux users and system administrators. Simple maintenance duties, such as creating a file, deleting a file, browsing a folder, and transferring a file, may be completed using the program.
Due to the popularity of Linux as an operating system for virtual server hosting, being familiar with the core Linux commands is essential for server administration. This article will teach you how to delete a file in Linux using the Terminal command line.
How to Delete a File in the Linux Terminal
Keep in mind the following tips before proceeding with the file deletion in Linux:
- The following commands should be used with care, especially those that employ regular expressions or search patterns with the "Find" command. As a consequence of an improper phrase or pattern, data/system and non-intended files are deleted.
- Having a current copy of vital data and device files is always good.
- Run these commands with extreme care, especially if you're using root (super-user privileges) and Sudo.
1. Delete a Single File Using rm Command
The rm function, which allows you to delete one or more files simultaneously, is the most often used command for eliminating files from your computer.
rm {file-name}
Step 1. Write-protected files will be asked for confirmation before being deleted; otherwise, rm will remove the file without asking for confirmation. With the "-i" flag, you may compel rm to ask you for confirmation before it removes a file from your computer.
rm -i {file-name}
Step 2. The rm command removes files from the system without displaying any notifications. In order to view what the rm command is presently doing, it is necessary to use it in conjunction with the -v flag.
rm -v {file-name}
Step 3. Using the -f flag to delete write-protected files without first requesting an explanation is not recommended.
rm -f {file-name}
2. Remove Files by Employing unlink
Here is how you can deploy the "unlink" command when deleting a file permanently using Linux.
$ unlink {file-name}
How to Remove Folders and Directories in Linux with Command Lines
The rmdir and rm commands in Linux allow you to remove or delete folders. Removing empty directories using the rmdir command-line program while removing directories with their contents with the rm command-line utility is recursive.
Step 1. Use the rm command with the -r (recursive) option to completely delete non-empty folders and all of the files contained inside them:
rm -d dirname
Step 2. If you attempt to delete a directory or a file inside a directory that is write-protected, you will be requested to confirm your decision:
rmdir dirname
Step 3. Use the rm command with the -r (recursive) and -f (forceful) arguments to delete non-empty folders and all of the files without being prompted:
rm -r dirname
Step 4. Use the rm -r command followed by a space and the directory names you want to delete to remove several directories at the same time.
rm -rf dirname
Step 5. In the same way you can use a wildcard (*) to match multiple files, you can also use normal expansions to match multiple directories.
rm -r dirname1 dirname2 dirname3
Important to Remember: When the command rmdir returns an error with the message "Directory not empty," it stops processing the directories that were supplied to it on the command line. It would not accomplish anything if you asked it to remove four directories, and the first one contained files.
rmdir would give you an error message and would not do anything else. You may compel it to ignore these problems by using the —ignore-fail-on-non-empty option, which will allow other directories to be processed while these errors are ignored.
How to Recover Deleted Files, Folders, and Directories in Linux
Deleting files is always risky. Sometimes you end up deleting important files that you never wanted to delete in the first place. The same can happen when you are employing all these commands in Linux. So, how can you recover these lost files? Regardless of the failure, we suggest that you restore the game data. You will need expert help to achieve this, and we suggest that you utilize the EaseUS Data Recovery Wizard to recover your Deleted data.
EaseUS Data Recovery Wizard makes it simple to recover deleted files or data on Linux, including MX Linux, Manjaro, Linux Mint, Ubuntu, Debian, and more. If any files, folders, or directories on Linux are accidentally destroyed, users may effortlessly recover them using the software. Using this application, users may recover lost data from a Linux computer running on a Windows PC.
Note: Linux Recovery is a new feature of EaseUS Data Recovery Wizard, included in the latest version. You can contact our online customer service to get the installation package.
Step 1. Install and Launch EaseUS Data Recovery Wizard on your Windows PC. Choose "Linux Recovery" on the left panel.
Step 2. This software will detect your IP and Port automatically. You need to input the user name and password. If the IP address or Port is not right, you can correct it manually. Then, click "Connect Now".

Step 3. After successfully connecting to your Linux device, EaseUS recovery software will start scanning the disk to find all lost and deleted files. When the scan process completes, click "Filter" > "Type" to specify lost file types.

Step 4. You can preview the scanned files first. Then, select the target data and click the "Recover" button to restore lost files in Linux.

Main Features of the EaseUS Data Recovery Wizard:
- Recover data from hard disks, SSDs, SD cards, flash drives, and USB devices
- Repair corrupted files after recovery, support documents, video, and photo repair
- Preview restored files before recovery
Conclusion
The rm, rmdir, and unlink Linux commands should be familiar to you at this point, and you should be able to properly delete files and folders from the command line using these commands after reading through this how to Delete a File in Linux guide.
The EaseUS Data Recovery Wizard may be used to recover accidentally deleted data from any Linux distribution, including Ubuntu, Fedora, Debian, and Slackware. Make sure you use the software to your advantage when in need!
Was This Page Helpful?

Cedric Grantham is one of the senior editors of EaseUS who lives and works in Chengdu, China. He mainly writes articles about data recovery tutorials on PC and Mac and how-to tips for partition management. He always keeps an eye on new releases and likes various electronic products.
-
EaseUS Data Recovery Wizard is a powerful system recovery software, designed to enable you to recover files you’ve deleted accidentally, potentially lost to malware or an entire hard drive partition.
Read More -
EaseUS Data Recovery Wizard is the best we have seen. It's far from perfect, partly because today's advanced disk technology makes data-recovery more difficult than it was with the simpler technology of the past.
Read More -
EaseUS Data Recovery Wizard Pro has a reputation as one of the best data recovery software programs on the market. It comes with a selection of advanced features, including partition recovery, formatted drive restoration, and corrupted file repair.
Read More
Related Articles
-
[Real Fix] There Is No Option to Empty Recycle Bin on Windows 10
Brithny/2022/01/18
-
[2022] USB Recovery Software to Recover Files from USB Flash Drive
Roxanne/2022/02/10
-
How to Recover Data from Corrupted Windows OS [Easy and Fast]
Roxanne/2022/04/14
-
Top 6 Ways to Fix Windows 10 WHEA Uncorrectable Error
Roxanne/2022/04/14