rm
rm
is the command for removing
files. Similar to rmdir
, this action cannot be undone so careful use is recommended.
Syntax: rm[option]<filename>
SNIPPET
1user@localhost:~$ rm Newfile
2user@localhost:~$ ls
3Documents Pictures Videos
A helpful option available for rm
is -r
. Adding this option allows us to remove non-empty directories with ease, as it recursively goes through all the files and sub-directories inside a directory and deletes them.
SNIPPET
1user@localhost:~$ rmdir Videos
2rmdir: failed to remove 'Videos': Directory not empty
3user@localhost:~$ rm -r Videos
4user@localhost:~$ ls
5Documents Pictures