JupyterLab notebooks have a safety feature which prevents you from deleting a folder if it is not empty. You may have hit an error stating:
"Delete Failed Directory /home/jovyan/<folder> not empty"
While thoughtful in wanting to protect us, this can be a major hassle if you have lots of subfolders or files in this folder. The following instructions will describe how to use the command line to delete a folder.
In the following example, we will delete the 'asdf' directory.
- On the File menu, select New -> Terminal.
- Navigate to the directory above the folder you wish to delete using the
cdcommand. In this case, the folder we want to delete is in our home directory, so changing directories is not necessary.
- Use the
lscommand to verify that the folder we are trying to delete is in that directory.
Terminal Tip The green line is a command prompt in the terminal. The
lscommand lists the contents of the current directory. When the terminal lists the contents, you will see that folders are shown in blue.
- Use the
rm -rf asdfcommand. This removes the specified file or folder.
-rmeans recursively which is necessary if you are deleting a folder and its contents.
-fmeans force which means you won't get asked about every file/folder below the directory you are trying to delete.
- To verify the folder is deleted, you can run
- The folder will disappear from the navigation panel on the left shortly.