0

I have accidentally deleted(in a way) or I can say dislocated reference to my /home/user/Desktop directory , Is there any way to undo what I have done.

The following Describes what I have done

$ cp xyz.java /home/user/Desktop
$ cp xyz1.java /home/user/Desktop

After these commands I am getting blank Desktop With wallpaper and when I try to open my Desktop Directory by

cd /home/user/Desktop

command it gives following not a directory error

bash: cd: /home/user/Desktop: Not a directory

PS: Before copying the file to correct Desktop Directory I mis-spelled Desktop as Deskop and system Created a file name Deskop in my /home/user folder when I opened it, the file contained data of xyz.java in it.

could anyone guide me through this and also please tell me what happened to my Desktop files and If, they are now orphaned in my memory How do i restore them.I have one more question in my mind after this Disaster:

How do I undo the commands and their execution results with command-line?

muru
  • 197,895
  • 55
  • 485
  • 740
Chinmaya B
  • 6,122
  • 7
  • 24
  • 43

1 Answers1

3

I doubt these commands did anything:

rinzwind@schijfwereld:~$ mkdir test
rinzwind@schijfwereld:~$ touch test1
rinzwind@schijfwereld:~$ cp test1 test
rinzwind@schijfwereld:~$ ls -l test*
-rw-rw-r-- 1 rinzwind rinzwind    0 feb  8 20:20 test1

test:
total 0
-rw-rw-r-- 1 rinzwind rinzwind 0 feb  8 20:20 test1
rinzwind@schijfwereld:~$ cd test
rinzwind@schijfwereld:~/test$ ls
test1
rinzwind@schijfwereld:~/test$ 

Directory test is still there and has test1 in it.

Before you continue do a

ls -l ~

and examine the results. There should be a

drwxrwxr-x 2 rinzwind rinzwind 4096 feb  8 20:20 Desktop

The "d" makes it a directory. If that is the case all is well.

If not and it shows a "-" (aka. it has become a file) ... do (as rthe user you want this desktop created ($USER will be expand to that user name)):

cd ~
rm /home/$USER/Desktop
mkdir Desktop

(do not add -r to the rm) as the user that is suppose to own this directory. Otherwise add in

chown $USER:$USER Desktop

Warning: if you do this with a directory the "rm" will fail with an error stating you are trying to delete a directory. This will have you restore to an EMPTY desktop. If you had files in there they are gone.


From comments

-rw-r--r--  1 root       root        Desktop

Put "sudo" in front of the "rm" above. So ...

cd ~
sudo rm /home/$USER/Desktop
mkdir Desktop
Rinzwind
  • 299,756