Ubuntu – Want to remove Folder “.” and “..” which I have copied from the phone SD Card

deletedirectorysd card

Here is my terminal code :

   root@mehedi-Inspiron-1545:/home/mehedi/SD Card/sdcard/ ls -al
total 46676
drwxrwxr-x  3 mehedi mehedi     4096 জুল    11 05:36 .
drwxrwxr-x 13 mehedi mehedi     4096 জুল    11 05:33 ..
-rw-rw-r--  1 mehedi mehedi    83277 জুল    10 10:18 17861803_1540974315927302_7704865319494415873_n.jpg
drwxrwxr-x  2 mehedi mehedi     4096 জুল    10 10:18 Adobe Reader
-rw-rw-r--  1 mehedi mehedi    18952 জুল    10 10:18 config.bin
-rw-rw-r--  1 mehedi mehedi   407930 জুল    10 10:18 download_20170115_010150.jpeg
-rw-rw-r--  1 mehedi mehedi    66275 জুল    10 10:18 DVB-T-w-Gliwicach-kierunki-2014.02.17.jpg
-rw-rw-r--  1 mehedi mehedi  3395403 জুল    10 10:19 Nasi_Lemak,_Mamak,_Sydney.jpg

Now can anyone tell me how to delete the folder named . and .. this two was copied from my SD Card.

Best Answer

These are standard Linux notations for current directory (.) and parent directory (..). They have nothing to do with Android or SD card. This is just standard filesystem behavior,and they exist for every directory on the filesystem.

$ pwd 
$ ls -a
./  ../
# going to . directory doesn't do anything, you remain in same place
$ cd .
$ pwd
# going to .. brings you up one level to parent folder
$ cd ..
$ pwd

Important exception is that with / root directory, the .. will point to itself, since there's no higher directory to go to.

You cannot perform removal on them either (which wouldn't make sense, since you're trying to get rid of your current working directory or its parent):

$ pwd 
$ rm -r .
rm: refusing to remove '.' or '..' directory: skipping '.'

So what should you do about them ? Nothing. They're part of the Linux package, so to speak. This is not broken, so don't try to fix it.

Frequent usage of . is via ./ notation. This can be used in case where you'd run a script or executable in your current working directory like ./myscript.sh or as argument to command, signifying a file in current directory, like ls ./myfile.txt. The last approach is often used with globstar to expand to multiple filenames in current directory, such as ls ./*. This approach is particularly useful with filenames that may contain leading - and thus such filenames may be misinterpreted by commands as arguments, while ./-myfile.txt avoids that issue.

It's also important to note that since filenames containing leading dot are considered hidden on Linux, these two "pointer" directories can be seen if you explicitly specify for the command that you use to process hidden filenames ( unless your command, such as find does that by default).

See also: https://unix.stackexchange.com/a/63087/85039