TechPlip
    • Alternatives
    • Android
    • Apple
      • Apple TV
      • iPhone
    • Best
    • Smart TV
    • Smart Watch
      • Apple Watch
      • Fitbit
    • Social
      • Twitter
      • Whatsapp
    • Windows
    TechPlip
    Home»How to»How to Delete (Remove) a Directory in Linux
    How to

    How to Delete (Remove) a Directory in Linux

    By AdminFebruary 25, 2021Updated:February 25, 2021No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Delete a Directory in Linux
    Share
    Facebook Twitter LinkedIn Pinterest Email

    The majority of PC users will have either Windows or Mac as their operating system. The third one, Linux, is preferred by only the programmers and coders. Working in Linux is like using Command Prompt on Windows. It will help if you write a bunch of codes to do anything. For instance, to delete a directory or a Linux file, you need to write a line of code in the Terminal Window. You can’t right-click the file and delete it just like in Windows.

    Working in Linux is fun when you know the tips and tricks. This article will instruct you on how to delete a directory on Linux with different codes. With the codes, you can delete or remove a file or a whole folder from your PC.

    Delete a Directory in Linux

    How to Delete a Directory in Linux (Files)?

    The simple way to delete a file in Linux is by executing the below command,

    rm linux.txt

    This command will delete the file named “linux” if the file is in the working folder. If you want, you can also delete a file from a different folder by providing the path of the file.

    rm ./techplip./linux.txt

    This command will delete the file named “linux” in techplip folder. You can also delete multiple files at a time by providing more than one file name.

    rm linux.txt mypage.txt

    This command will delete two files named “linux” “mypage” at once. If you want Linux to provide a warning before deleting a file, you can use the -i (interactive). For instance,

    rm -i linux.txt

    This will prompt yes or no before deleting the file. You can reply with y for Yes and n for No.

    If the file you are going to delete is write-protected, you will be asked for confirmation even without the -i command. In that case, you can reply with y. If you don’t want to have the confirmation, you can use the -f (force) command.

    rm -f linux.txt

    This will delete the file without asking for any confirmation even though the file is write-protected.

    How to Delete a Directory in Linux (Folders)?

    If you want to delete an entire folder, you can use the code with -d (directory) command

    rm -d linux

    This will delete the linux folder. You can also use the interactive (-i) on the folder.

    rmdir linux

    You can also use the command rmdir. The rmdir command will delete the folder Linux but not the files in the folder. rm will delete both the files and the folder at once. You can use all the commands like -i and -f in the directories too. If you want to delete more than one folder, provide the folder’s names that you want to remove, just you did it for multiple files.

    Related: Best Text Editor for Ubuntu Linux

    These are the commands and codes you need to know to delete a file or a directory in Linux. Use these commands on the Terminal Windows to delete files and manage your directories. If you want to know any other commands in Linux, let us know in the comments below.

    Guide
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Right-Click on Chromebook in 3 Easy Ways
    Next Article How to View Saved Passwords on Mac [3 Easy Ways]
    Admin

    I am the Admin of TechPlip.com and I have written a variety of tech-related subjects - from news to reviews. I am a tech enthusiast focused in providing the best tech contents.

    Related Posts

    How to Watch Disney Plus on Sony Smart TV

    January 27, 2023 How to

    How to Reset Garmin Watch to Factory Settings

    January 25, 2023 Garmin

    How to Take a Screenshot on Chromebook [4 Ways]

    January 23, 2023 Chromebook

    Leave A Reply Cancel Reply

    10 Best Language Learning Apps [2023]

    January 30, 2023

    How to Watch Disney Plus on Sony Smart TV

    January 27, 2023

    How to Reset Garmin Watch to Factory Settings

    January 25, 2023

    How to Take a Screenshot on Chromebook [4 Ways]

    January 23, 2023

    How to Install and Stream Paramount Plus on Roku

    January 21, 2023

    How to Save Battery on Fossil Smartwatch

    January 20, 2023

    How to Install YouTube on Apple TV [2023]

    January 5, 2023

    How to Cancel Planet Fitness Membership

    January 3, 2023
    • Home
    • Privacy Policy
    • Affiliates Disclosure
    • Contact Us
    © 2023 TechPlip.

    Type above and press Enter to search. Press Esc to cancel.