< -- BuySellAds Ad Code ALLEN -->
  • Home
  • Linux
  • How to Create and Delete Folders in Linux

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.

how to create a directory in linux
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.

how to delete a directory in Linux

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.

delete folder and sub folders in linux

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.

how to change directory in linux

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.

how to delete sub folders in linux

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

Tags: learn linux, linux

Allen White

Allen is an IT Consultant and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5, 6 and HP ASE, AIS - Network Infrastructure.

Leave a comment

Categories

Vote!

What Web Browser Do You Use?

View Results

Loading ... Loading ...

Vote!

What do you prefer..VMware or Hyper-V?

View Results

Loading ... Loading ...