Techieshelp.com

How to Create and Delete Folders in Linux

Again this is a realy quick and simple guide that I thought id type up as I taught myself Linux. Here we will create a folder and then delete it. We will also learn how to delete a folder and all its contents in Linux also.

Create a Directory in Linux

To do this we can use the mkdir command. We create a folder called test here.

mkdir test

We use the ls command to see that we have created the test directory.


Now if we wanted to set permissions on the test directory we could use this guide.

Remove a Directory in Linux

If we wanted to delete this directory we can use the rmdir command, bare in mind this command can only be used with empty folders. As seen below we list the directory with the ls command, we delete it then to make sure its gone run ls again.

Delete a Folder, Sub Folders and all Contents in Linux

Lets say though we had a folder than had multiple files and sub folders in it that we wanted to get delete. Here I have created a test folder with test1,test2 and test3 folders and also a test file as seen here.

To delete these folders we must drop back to the root folder in which the top level test folder is, do this with the cd .. (change directory) command.

We then use the rm -ir command to delete the top level folder and all its files and sub folders. You will be promoted to descend and deleted the files and folders, select yes to do so.

If you also want to learn Linux then consider a VPS, check out this link 25% OFF VPS Hosting.