Solved

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

Posted on 2016-09-18
2
70 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 29

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

820 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