linux terminal delete folder code example
Example 1: delete directory linux
rm -rf dir1
Example 2: remove directory in cmd
# for removing empty directory
$ rmdir myDirectory
# to remove a directory that contains files and subdirectory
$ rm -r myDirectory
Example 3: delete file linux terminal
rm filename
# or add -rf if you don't want to see confirm
Example 4: remove a file or dir in linux or mac or ubuntu
note:your_file_name can be a dir or a file
sudo rm -r your_file_name
Example 5: remove folder and contents linux
# Remove Single File Using rm:
rm file1.txt
# Remove Directory and it's contents:
rm -r dir1 # '-r' is short for '-recursive'
# Remove empty Directory:
rm -d dir1 # '-d' is short for '-dir'
Example 6: how to delete a dir in linux
#In linux Terminal:
#To make a directory:
mkdir directory_name
#To delete a directory:
rmdir directory_name