How to delete and remove files on SUSE Enterprise Linux

I am a new SUSE Enterprise Linux user. How do I delete and remove a file on SUSE Enterprise 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 SUSE Enterprise Linux. This page shows how to delete and remove files on SUSE Enterprise Linux.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements SUSE Enterprise Linux
Est. reading time 3 minutes

Command to delete and remove files on SUSE Enterprise Linux

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

  1. Open the SUSE Enterprise terminal application (bash shell)
  2. Type any one of the following command to delete a file named suse.nixcraft.txt in the current directory
  3. rm suse.nixcraft.txt
    OR
    unlink suse.nixcraft.txt

Let use see all rm command options to delete and remove files on SUSE Enterprise Linux.

Please note that vivek@suse-nixcraft:~> is my shell prompt, and you need to type the command after that.

Delete multiple files

Type the following command to delete the file named delta.txt, bar.doc, and dance.jpg located in the current directory:
vivek@suse-nixcraft:~> rm delta.txt bar.doc dance.jpg
You can specify path too. If a file named delta.txt located in /tmp/ directory, you can run:
vivek@suse-nixcraft:~> rm /tmp/delta.txt
vivek@suse-nixcraft:~> rm /tmp/delta.txt /home/vivek/dance.jpg /home/vivek/data/bar.doc

SUSE Enterprise 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 SUSE Enterprise Linux:
vivek@suse-nixcraft:~> rm -i filename
vivek@suse-nixcraft:~> rm -i delta.txt

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

Pass the -v option as follows to get verbose output on SUSE Enterprise Linux box:
vivek@suse-nixcraft:~> rm -v filename
vivek@suse-nixcraft:~> rm -v cake-day.jpg

SUSE Enterprise Linux delete all files in folder or directory

You need to pass the following options:
vivek@suse-nixcraft:~> rm -rf dir1
vivek@suse-nixcraft:~> rm -rf /path/to/dir/
vivek@suse-nixcraft:~> 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 SUSE Enterprise Linux.

SUSE Enterprise 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@suse-nixcraft:~> rm -- -filename
vivek@suse-nixcraft:~> rm -- --filename
vivek@suse-nixcraft:~> rm -rf --dirname
vivek@suse-nixcraft:~> rm ./-file
vivek@suse-nixcraft:~> rm -rf ./--dirname

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

rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about SUSE Enterprise 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 SUSE Enterprise Linux:
vivek@suse-nixcraft:~> rm -rf /
vivek@suse-nixcraft:~> rm -rf *

Deleting files owned by other and root user

You can only remove files owned and created by you for security reasons. However, the root user can remove any files. Hence, care must be taken running rm as the root user. For example, remove a file named /root/data.txt as a normal user:
vivek@suse-nixcraft:~> sudo rm -vi /root/data.txt

Summing up

I explained the rm command that you can use on the SUSE Enterprise Linux server to remove and purge files as per your need. However, you must take care while deleting files as SUSE will not prompt for confirmation. Hence, keeping backups is an essential task for all developers and sysadmins. See rm command help by tying the following man command:
man rm


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig 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 glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Adelle Sauvageot Jun 6, 2021 @ 8:25

    I am SAP and SUSE user and this guide helped me a lot.

    Merci mon amour.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum