Kali Linux: How To Create And Delete Folders in Terminal
Creating a folder (directory) using the terminal in Kali Linux is a straightforward process. You can use the mkdir
command to accomplish this. Here's a step-by-step guide:
Open the Terminal:
You can open the terminal by clicking on the terminal icon in the taskbar or by pressing Ctrl + Alt + T
.
Navigate to the Desired Directory:
Use the cd
command to navigate to the directory where you want to create the new folder. For example, to navigate to the /home/username/Documents
directory, you would use:
If you want to create the folder in your current directory, you can skip this step.
Create the Folder:
Use the mkdir
command followed by the name of the folder you want to create. For example, to create a folder named new_folder
, you would use:
Verify the Folder Creation:
You can use the ls
command to list the contents of the directory and verify that the new folder has been created. For example:
Here is a summary of the commands:
Example
If you want to create a folder named Projects
in your home directory, the commands would be:
To delete a folder in the terminal on Kali Linux, you can use the rm
command with the -r
(recursive) option. This is necessary because rm
by itself only removes files, not directories. Here's how you can do it:
Open the terminal.
Navigate to the parent directory of the folder you want to delete. Use the cd
command for this. For example, if the folder you want to delete is located in /home/user/Documents
, you would navigate there by typing:
Delete the folder. Use the rm -r
command followed by the folder name. For example, to delete a folder named example_folder
, you would type:
If you want to avoid being prompted for confirmation for each file within the directory, you can add the -f
(force) option:
Caution: The rm -rf
command is very powerful and will permanently delete the specified folder and all of its contents without any confirmation. Be very careful when using it to avoid accidentally deleting important data.
Here is an example sequence:
Replace /path/to/parent_directory
with the actual path to the directory containing the folder you want to delete, and folder_to_delete
with the name of the folder you want to delete.
That’s it! You’ve successfully both created and deleted a folder using the terminal in Kali Linux.