How to delete and remove files on Arch Linux

I am a new Arch Linux user. How do I delete and remove a file on Arch Linux based system?

You need to use the rm command. It tries to remove the files specified on the command line. Use the rm command to delete files and directories on Arch Linux. This page shows how to delete and remove files on Arch Linux.

ADVERTISEMENTS

Command to delete and remove files on Arch Linux

The syntax is as follows for the rm and unlink command to remove files on Arch Linux:

  1. Open the Arch terminal application (bash shell)
  2. Type any one of the following command to delete a file named joan.doc in the current directory
  3. rm joan.doc
    OR
    unlink joan.doc

Let use see all the rm command options to delete and remove files on Arch Linux.

Delete multiple files

Type the following command to delete the file named topsy.jpg, jerry.png, and dance.jpg located in the current directory:
[vivek@arch ~]$ rm topsy.jpg jerry.png dance.jpg
You can specify path too. If a file named topsy.jpg located in /tmp/ directory, you can run:
[vivek@arch ~]$ rm /tmp/topsy.jpg
[vivek@arch ~]$ rm /tmp/topsy.jpg /home/vivek/dance.jpg /home/vivek/data/jerry.png

Arch Linux delete a file and prompt before every removal

To get confirmation before attempting to remove each file pass the -i option to the rm command on Arch Linux:
[vivek@arch ~]$ rm -i Your-File-Name
[vivek@arch ~]$ rm -i topsy.jpg

Force rm command on Arch Linux to explain what is being done with file

Pass the -v option as follows to get verbose output on Arch Linux box:
[vivek@arch ~]$ rm -v Your-File-Name
[vivek@arch ~]$ rm -v cake-day.jpg

Arch Linux delete all files in folder or directory

You need to pass the following options:
[vivek@arch ~]$ rm -rf dir1
[vivek@arch ~]$ rm -rf /path/to/dir/
[vivek@arch ~]$ rm -rf /home/vivek/oldschoolpics/

It will remove all files and subdirectories from a directory. So be careful. Always keep backups of all important data on Arch Linux.
Delete and remove files on Arch Linux

Arch Linux delete file begins with a dash or hyphen

If the name of a file or directory or folder starts with a dash (- or hyphen --), use the following syntax:
[vivek@arch ~]$ rm -- -Your-File-Name
[vivek@arch ~]$ rm -- --Your-File-Name
[vivek@arch ~]$ rm -rf --Your-Folder-Name
[vivek@arch ~]$ rm ./-file
[vivek@arch ~]$ rm -rf ./--Your-Folder-Name

Do not run ‘rm -rf /‘ command as an administrator/root or normal Arch Linux user

rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Arch Linux disasters. The rm -rf / variant of the command, if run by an administrator, would cause the contents of every writable mounted filesystem on the computer to be deleted. Do not try these commands on Arch Linux:
[vivek@arch ~]$ rm -rf /
[vivek@arch ~]$ rm -rf *

Conclusion

And there you have it, the rm command which is used to delete files and directories on Arch Linux operating systems. For more info see the rm command man page on Arch by typing the following man command:
$ man rm
OR
$ info rm
OR
$ rm --help

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.