I want to delete a directory from my remote Linux server. Can I do it using SSH ? My problem is that I don't know the command to achieve this goal. Can you help me to delete it?
I want to delete a directory from my remote Linux server. Can I do it using SSH ? My problem is that I don't know the command to achieve this goal. Can you help me to delete it?
Delete directory via SSH
Syntax
rm -r -f directory_name
where,
-r = recursively deletes the directory and all files in it, including subdirectories
-f = will not ask for confirmation before deleting
For example:
rm filename.txt: deletes filename.txt, will ask for confirmation before deleting
rm -f filename.txt: deletes filename.txt, will not ask for confirmation before deleting.
rm -rf tmp/: deletes the directory tmp, and all files in it, including subdirectories. It will not ask for confirmation.
Always be careful with this command. If you provide the second parameter (-f), it will simply delete the directory without any confirmation.
I would like to add my comments to this discussion. Are you logged in as a privileged user? You can check this using below command:
ls -al
It will show you all the directory details including sub-directories and attributes in it. It will also show you if you are privileged to modify or delete the directory.
Bookmarks