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 No Comments on Remove Files And Directories In Linux From Terminal

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:  Fix “Updating from such a repository can’t be done securely” Error In Linux

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

Linux How To Unzip Files Tutorial For Everyone Linux How To Unzip Files Tutorial For Everyone Linux
How To Setup UFW (Uncomplicated Firewall) On Ubuntu 22.04 LTS How To Setup UFW (Uncomplicated Firewall) On Ubuntu 22.04 LTS How To Ubuntu
Linux Kernel 6.2 Officially Released Linux Kernel 6.2 Officially Released Linux
Extract tar.xz File In Linux Distros :Tar Command Example Extract tar.xz File In Linux Distros :Tar Command Example Linux
Basic Cat Command Examples In Linux 15 Basic Cat Command Examples In Linux How To Ubuntu
Tutorial To Install And Use Linux Screen Tutorial To Install And Use Linux Screen Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • 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
  • Linux Wget Examples September 27, 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]
  • TV Writer

    • New York, NY
    • SPECTRUM
    • Full Time
  • Technical Writer

    • Chantilly, Loudoun County, VA
    • ManTech
    • Full Time
  • Technical Documentation Specialist

    • Peoria, IL
    • EPITEC
    • Full Time
  • Technical Writer

    • Swiftwater, PA
    • Cynet Systems Inc.
    • Full Time
  • Senior Technical Writer

    • San Diego, CA
    • Compunnel Inc.
    • Full Time
  • Technical Writer

    • Crane, IN
    • Bowhead / UIC Technical Services
    • Full Time
  • Senior Data Scientist

    • Waltham, MA (Remote)
    • Global Partners LP
    • Full Time
  • Communications Writer

    • Lynchburg, VA
    • Patrick Henry Family Services Operations, Inc.
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme