Pages Menu
Categories Menu

Posted by on Jan 30, 2018 in tips & tricks | 0 comments

How to Delete a Directory in Linux & Mac OS X Terminal

How to Delete a Directory in Linux & Mac OS X Terminal

How to remove directories in Linux and Mac OS terminals | When using the terminal on Linux or on Mac OS we sometimes need to delete the directory or folder. When trying to delete a directory using the rmdir command, you may find the answer “rmdir: ‘dir’: Directory not empty” and you can not delete that directory. To delete a directory that contains files or other subdirectories, then you can use the following command:

In the example above, you can try replacing NAMEAFOLDER with the folder you want to delete, eg the name of the folder you want to delete is “CREAM” then the command typed in the terminal is

The above command if executed it will delete all the files and directories in the folder / directory mentioned in the command, the CREAM folder and the contents in it. However, the command will prompt an approval to delete each file, if there are 10 then 10 approval requests will appear. The parameter r here means recursive, so the CREAM folder and its contents will be deleted recursively, but will fail if there are any more folders. It is actually good for security, so no mistake in removing the directory. But it would be troublesome.

If you are sure you want to delete the CREAM folder, you can change -r to -rf, rf means recursive + force, command to delete directory in terminal become like this:

The above command if executed it will delete the CREAM folder and all the contents contained there in without asking for confirmation.

Deletes FILE in Linux and Mac OS Terminal

While to delete files in terminal Linux and Mac OS is almost the same way that is using rm command, for example the file name you want to delete is tips.jpg, then the command becomes as follows:

Those are some ways of deleting folders or directories in LINUX and MAC OS terminal, please use which one is safe and comfortable according to you.

Facebook
Google+
Twitter
Download Premium Magento Themes Free | download premium wordpress themes free | giay nam dep | giay luoi nam | giay nam cong so | giay cao got nu | giay the thao nu