Solved

How to delete all files in a current directory starting with a dot?

Posted on 2016-09-18
2
51 Views
Last Modified: 2016-09-18
Hello!

I use Ubuntu 14.04 and in a terminal I became root with sudo su and I wanted to delete root's trash manually. It deleted everything except for a few files that start with a dot. Like .htaccess etc. So I went to that directory (which is "files") and I ran this command:

rm -rf .*

Open in new window


It did delete those files, BUT I also got an error message that the system couldn't delete "." and ".." What does it mean? Like if I tried to delete the whole directory tree? Like I said, when I was running that command I was in the lowest directory. This one to be exact: /root/.local/share/Trash/files/
I shot down my PC and then turned it on. Everything seems to be normal at first glance. So now I want to ask is what went wrong and if what I did could really cause any serious damage to the system in general? In other words, should I be worried now or everything is OK?
0
Comment
Question by:Member_2_7970041
2 Comments
 
LVL 27

Accepted Solution

by:
serialband earned 500 total points
ID: 41804229
. and .. are the current and parent directory, respectively

It's also better not to use rm -rf with *, unless you understand what you're deleting.  It's better to use rm -rf .??* for dot files.
0
 

Author Comment

by:Member_2_7970041
ID: 41804269
Thanks for your reply!

Looks like I confused DNS "." with a Linux "." So in my case it wasn't the whole directory tree, starting from above, but only the current directory and the one above it, i.e. "files" and "Trash", correct? And then I got an error, since the system couldn't delete those two, considering my current location then. So those are good news then. No damage is done. I checked those two directories and they do exist now.

Next time I'll just leave those alone, since those files are less than 1K each. Or delete those one by one, using their full names.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now