Arch Linux: Delete Files or Directories
This post will guide you how to delete or remove files on your Arch Linux. How do I remove directories under your Arch Linux. How to quickly delete a file under a directory in Arch Linux.
Delete a Files On Arch Linux
You need to user the rm command to remove files on Arch Linux . Assuming that you want to delete a file called archtmp.txt under /myfio directory, you just need to execute the rm command with the file name that you want to remove in command line interface of your Alpine Linux system.
Just do the following steps:
#1 open a terminal or command line interface on your Arch Linux
#2 type the following command to remove archtmp.txt file
$ rm archtmp.txt
Delete Multiple Files on Arch Linux
If you want to remove multiple files on a directory, you can can use the rm command to achieve it. you just need to pass the file names to rm command and separated by space character. For example, you want to delete two files under the /mylinux directory, type the following command:
$ rm myarch1.txt myarch2.txt
Note: before removing the files, you need to change the current directory to /mylinux directory. type:
$ cd /mylinux
or you can also use the absolute path while you delete file, type:
$ rm /mylinux/myarch1.txt /mylinux/myarch2.txt
Confirm each file before removal on Arch Linux
if you want to get the confirmation for each file while removing, you can use the rm command with -i option, type:
$ rm -i myarch.txt
Outputs:
[osetc@osetc_x8664 ~]$ rm -i myarch.txt rm: remove regular empty file ‘myarch.txt’? y [osetc@osetc_x8664 ~]$
Show report of each file removed
if you want to get the report of each file removed, you need to use the rm command with -v option, type:
$rm -v myarch.txt
outputs:
[osetc@osetc_x8664 ~]$ rm -v myarch.txt rm: remove regular empty file ‘myarch.txt’? y removed ‘myarch.txt’
Remove Directory on Arch Linux
if you want to use the rm command to remove a directory , you need to use the -d option, type:
$ rm -d darch
Outputs:
[osetc@osetc_x8664 ~]$ rm darch rm: cannot remove ‘darch’: Is a directory [osetc@osetc_x8664 ~]$ rm -d darch rm: remove directory ‘darch’? y
Remove all files under a directory(Recursive) on Arch Linux
if you want to remove a directory and its files or its sub-directory, and you need to use the rm command with rf option, type:
$ rm -rf myarch
if you want to get more information about rm command, you can directory run “rm –help” or “man rm” command.
type:
$ rm --help
Or
$ man rm