Linux, MacOS, and Windows commands to create and manage a folder
Creating a folder
In Linux, macOS, and Windows, you can create a folder using the following command:
mkdir <folder_name>
For example, to create a folder called new-folder, you would run the following command:
mkdir new-folder
Listing the contents of a folder
To list the contents of a folder, you can use the following command:
ls <folder_name>
For example, to list the contents of the new-folder folder, you would run the following command:
ls new-folder
Changing the current directory
To change the current directory, you can use the following command:
cd <folder_name>
For example, to change the current directory to the new-folder folder, you would run the following command:
cd new-folder
Deleting a folder
To delete a folder, you can use the following command:
rmdir <folder_name>
Note: You can only delete an empty folder. If the folder contains files or other folders, you will need to delete those first.
Other helpful commands
Here are some other helpful commands for creating and managing folders:
- pwd: Print the current working directory.
- mkdir -p: Create a directory and any intermediate directories that do not exist.
- rm -rf: Delete a directory and all of its contents recursively.
- touch: Create a new empty file.
Examples
Here are some examples of how to use these commands:
# Create a new folder called "new-folder"
mkdir new-folder
# List the contents of the "new-folder" folder
ls new-folder
# Change the current directory to the "new-folder" folder
cd new-folder
# Delete the "new-folder" folder
rmdir new-folder