Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
Remove Files And Directories In Linux From Terminal

Remove Files And Directories In Linux From Terminal

Posted on May 3, 2020 By admin

Tutorial To Remove Files And Directories In Linux From Terminal Or From Command-Line.

In this Linux tutorial post, we will use various Linux commands to remove files and directories in Linux from the terminal.

We will go through the Linux commands to delete files and directories in Linux from terminal or CLI.

Remove Files And Directories In Linux From Terminal

Removing files and directories can create serious troubles. You might lose important files and data from your system. So, make sure that you run these commands wisely.

You can use the tree command to view the files and directories so that you can delete them properly. Know the directory structure in your Linux before starting to remove the files and directories.

Run the following command to install tree command in Linux:

sudo apt-get install tree

Run tree command with:

tree

Commands To Delete Files And Directories In Linux

Commands To Delete Files In Linux

Run the rm command along with your file name which you want to delete and enter:

rm file_name.txt

Just in case if the file is not in the current directory, you need to provide the file location:

rm ./pathtothefilelocation/file_name

Run the following command to delete multiple files at once in Linux:

rm filename1 filename2 filename3

You can also use the wildcards to delete the groups of files with the same format.  You will know more about this command from the example below. You will see two commands where we are deleting png files and pdf files.

rm *.png
rm *.pdf

If you want confirmation before deleting the file, run the rm command with -i option.

rm -i filename

To remove files without prompting even if the files are write-protected, use the -f option.

rm -f filename

Commands To Delete Directories In Linux

Let’s see the commands to remove directories in Linux based operating system with the following examples.

READ More Relevant Stuff:  How To Fix /bin/rm: cannot execute [Argument list too long]

Run the following command to remove an empty directory:

rm -d directoryname

Run the following command to remove multiple directories at once:

rm -d directoryname directoryname1 directoryname2

Run the following command to remove a directory with the files inside:

rm -r directory1 directory2 directory3

Note: rm -r command removes the directories and all files and sub-directories contained within them.

Run the following command to remove password-protected directory forcefully:

rm -rf directory

Remove Directories with rmdir command

Run the following command to delete a single directory in the current directory:

rmdir directoryname

You can also provide the path to the directory:

rmdir /path/to/directory

Run the following command to delete multiple directories at once:

rmdir directoryname1 directoryname2 directoryname3

This much for now. Please let us know if there is any error in this post.  We are regularly updating our blog posts.

Linux Commands Tags:Linux command, Remove file command, simple linux commands

Post navigation

Previous Post: Install Linux, Apache, MySQL, PHP On Ubuntu 20.04 (LAMP)
Next Post: Easily Create Linux Bootable USB Drive With Ventoy

Related Posts

How To Fix /bin/rm: cannot execute [Argument list too long] How To Fix /bin/rm: cannot execute [Argument list too long] Fix
Systemctl Command Examples Systemctl Command Examples Linux
How To Recursively Change The File's Permissions In Linux [CHMOD Linux] How To Recursively Change The File’s Permissions In Linux [CHMOD Linux] Linux
Fix “Updating from such a repository can’t be done securely” Error In Linux Fix “Updating from such a repository can’t be done securely” Error In Linux Fix
Fix "system has not been booted with systemd as init system (pid 1). can't operate" Error Fix “system has not been booted with systemd as init system (pid 1). can’t operate” Error Linux Commands
5 Ways To Count The Number Of Lines In A File In Linux 5 Ways To Count The Number Of Lines In A File In Linux Linux

Recent Posts

  • New Job Search October 10, 2025
  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • Customs Entry Writer

    • Iselin, NJ
    • Elsdon Group
    • Full Time
  • Freelance Writer – Remote

    • El Paso, TX
    • Outlier AI
    • Freelance
  • English Writer – Remote

    • New York, NY
    • Outlier AI
    • Full Time
  • Technical Writer – Remote

    • Charlotte, NC
    • Outlier AI
    • Full Time
  • Customs Entry Writer

    • Houston, TX
    • JSG (Johnson Service Group, Inc.)
    • Full Time
  • Analytics and AI Integration Engineer

    • San Ramon, CA (Remote)
    • Cxapp Us, Inc.
    • Full Time
  • Freelance Writer – Remote

    • San Jose, CA
    • Outlier AI
    • Freelance
  • Mazda Service Writer

    • Farmington, MI
    • Lithia Motors
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme