How to Delete File and Directory in Termux?

Termux is a widely used terminal emulator for Android. With the help of Termux, we can run Linux commands on our mobile devices. If you are a beginner, you must be confused about how to delete files and directories in Termux. In this article, we will learn how to delete files and directories in Termux.

Deleting Files

To delete a file in Termux, just follow the following steps:

Step 1 - Open Termux App and type "ls" to list the files and directories and move to the file that you want to delete.

How to delete files and directories in termux?

Step 2 - We will use rm command. So just type the command "r"m followed by the name of the file you want to delete. For example, I want to delete instander.txt file, I have to type

rm instanderfile.txt

Step 3 - Press Enter to execute the command. The file will be permanently deleted.

Deleting Directories

If you want to delete the whole directory the process is simple, follow these steps:

Step 1 - Open Termux and type "ls" to see the all directories.

Step 2 - Now just type the command rm -r followed by the name of the directory you want to delete. For example, I want to delete a directory named "instanderdirectory", then

rm -r instanderdirectory

Step 3 - Just Press enter to execute the command. The directory and all its contents will be permanently deleted.

Tips for Deleting Files and Directories

Keep these points in your mind when deleting files and directories in Termux:

1. Be careful when using the rm command, as it permanently deletes files without confirmation.

2. Always double-check the file or directory name before deleting the same.

3. Always use the ls command to list the contents of a directory to ensure that you are deleting the right directory or file.

Final Notes

So always be cautious while performing deleting tasks. If you have any questions, comment down. I will reply to you ASAP.

Post a Comment