Solved

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

Posted on 2016-09-18
2
55 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 28

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
gdb doesn't stop on breakpoint 2 48
add some character at the end of line in vi 7 59
Hacked File Timestamps 4 49
wipe a usb using python 5 22
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

914 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

14 Experts available now in Live!

Get 1:1 Help Now