How do i remove the files?
In this topic I will show you how to remove the files by using the “rm” command and also by using the options & without options..
The “rm” command removes a file with out asking confirmation from the user end(On Linux ,alias has been created with the rm command(-i option interactive) to ask the confirmation every time if you try to remove a file from a directory).
Be sure you really want to delete your files before you user “rm” command,because once the files are gone ,they are not coming back
Note:If you want to be prompted before the deletion use the -i option
There is one little safety features in “rm” command it wont delete a directory(unless you use -f option).
-f means forcefully.
Let me show you how to delete the files with option and without option.
Ex:1 To remove a file from a directory
#rm <option> <filename>
Task: Remove a file form the /var directory
First let me create a file inside the / directory
#ls -l /testfile
Note: Once you hit the enter button it will ask for the confirmation from the user end ,Once you give the permission “yes” to delete The file will get removed from the directory.
I will show you with one example here:
Ex :2 Now i am going to apply the option -f with the “rm” command .
#rm -f /anotherfile
Note: Here it will not ask the confirmation from the user as you have applied the force option -f which eliminates the interactive option.
Here you go….
Ex:3 Now applying the verbose option(-v) with the “rm” command
Verbose is nothing but the program provides the comments on the operation as they occur,so you will see the real time status of what the utility or program is doing to run the tasks or commands.
#rm -v /myfile
I will show you this with an simple example…
Note: From the above output if you see it is asking for the confirmation from the user before it gets delete from the directory,Because i haven’t applied the -f options ,if i would have applied then it will not ask the confirmation.
The order of options doesn’t a matter you can use it as you wish.
Ex:4 Applying -f and -v option with the “rm” command
#rm -vf /datafile
Here as i said above it will not ask the confirmation from the user end before it gets delete(coz of -f option) and also it will print a message on your screen regarding this task(coz of -v option).
If you found this article useful, Kindly Subscribe here Click this link to Subscribe