Where's the file?

jon777

New Member
Joined
Aug 25, 2023
Messages
13
Reaction score
9
Credits
104
hello,
I moved a file to /..
In my mind I was moving the file to the parent directory.
Of course this is not the way you do it, but I'm wondering
where the file went? Not that it's very important a file, but
I'm just wondering if it can be found.
I was on an external drive if it is of importance.
 


Hello @jon777,
Any file named with (.) in front of the file name will be hidden in Linux. So It maybe you moved the file but hid it.
Try in file manager show hidden. You did not say which distro you are using so not sure how to tell you to do that in your set up.
 
As a user, trying to move a file to /.. will fail thus:
Code:
[tom@min ~]$ mv file1 /..
mv: cannot move 'file1' to '/../file1': Permission denied
The user doesn't have permission to move a file the root directory, which is where /.. is.

One can show that /.. is the root directory by changing directory with the command using /..
Code:
[tom@min ~]$ cd /..
[tom@min /]$ ls
bin   dev  initrd.img      lib    lost+found  mnt     opt   root  sbin  sys  usr  vmlinuz
boot  etc  home   initrd.img.old  lib64  media       mounts  proc  run   srv   tmp  var  vmlinuz.old

However, as root user, the moving of a file will be successful:
Code:
[root@min ~]# cd /etc
[root@min /etc]# touch file2
[root@min /etc]# mv file2 /..
[root@min /etc]# cd /
[root@min /]# ls
bin   dev  file2  initrd.img      lib    lost+found  mnt     opt   root  sbin  sys  usr  vmlinuz
boot  etc  home   initrd.img.old  lib64  media       mounts  proc  run   srv   tmp  var  vmlinuz.old

To move a file to the parent directory, the command is:
Code:
mv file2 ..

And if the user wished to mv the file from the parent directory to elsewhere, the command would be:
Code:
mv ../file1 <some-other-directory>
which uses ../ rather than /..

Basically, it appears the shell ignores the two dots after / and interprets /.. as /
 
Last edited:
As a user, trying to move a file to /.. will fail thus:
Code:
[tom@min ~]$ mv file1 /..
mv: cannot move 'file1' to '/../file1': Permission denied
The user doesn't have permission to move a file the root directory, which is where /.. is.

One can show that /.. is the root directory by changing directory with the command using /..
Code:
[tom@min ~]$ cd /..
[tom@min /]$ ls
bin   dev  initrd.img      lib    lost+found  mnt     opt   root  sbin  sys  usr  vmlinuz
boot  etc  home   initrd.img.old  lib64  media       mounts  proc  run   srv   tmp  var  vmlinuz.old

However, as root user, the moving of a file will be successful:
Code:
[root@min ~]# cd /etc
[root@min /etc]# touch file2
[root@min /etc]# mv file2 /..
[root@min /etc]# cd /
[root@min /]# ls
bin   dev  file2  initrd.img      lib    lost+found  mnt     opt   root  sbin  sys  usr  vmlinuz
boot  etc  home   initrd.img.old  lib64  media       mounts  proc  run   srv   tmp  var  vmlinuz.old

To move a file to the parent directory, the command is:
Code:
mv file2 ..

And if the user wished to mv the file from the parent directory to elsewhere, the command would be:
Code:
mv ../file1 <some-other-directory>
which uses ../ rather than /..

Basically, it appears the shell ignores the two dots after / and interprets /.. as /
Yes, you have to be root to move to /.. or use sudo, which I did, probably
automatically when denied permission with sudo !!
And the file indeed is to be found in the root directory.
Thanks for clearing that out.
 
Hello @jon777,
Any file named with (.) in front of the file name will be hidden in Linux. So It maybe you moved the file but hid it.
Try in file manager show hidden. You did not say which distro you are using so not sure how to tell you to do that in your set up.
It's moved to the root directory. Thanks for answering.
 

Members online


Latest posts

Top