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 Cancel Planet Fitness Membership in 3 Steps
    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 Enable Google Sheets Dark Mode

    May 22, 2022 Dark Mode

    Best Golf Apps on iPhone

    May 21, 2022 Apple

    How to Find MAC Address on MAC

    May 20, 2022 Apple

    Leave A Reply Cancel Reply

    How to Enable Google Sheets Dark Mode

    May 22, 2022

    Best Golf Apps on iPhone

    May 21, 2022

    How to Find MAC Address on MAC

    May 20, 2022

    How to Change Time on Fitbit Versa/Charge/Alta

    May 19, 2022

    How to Turn Off Xbox One Controller [Two Methods]

    May 18, 2022

    How to Use Apple Watch Control Center

    May 17, 2022

    How to Get Pi Symbol on Keyboard

    May 16, 2022

    What does SAAS stand for and How It Works

    May 15, 2022
    • Home
    • Privacy Policy
    • Affiliates Disclosure
    • Contact Us
    © 2022 TechPlip.

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