0

I have been trying to move a file from one directory (on the Ubuntu 18.04 for windows terminal) to other directory and it dissapeared, to do it I ran the following command and entered the sudo password correctly, however when I moved to the new_directory nothing was there.

sudo mv new_file.txt /new_directory

Just to clarify this happens anytime with any file or directory I try to use (even if a create a new file and directory the output will be always the same - nothing there). However I have Anaconda installed on Ubuntu and using the Jupyter Navigator I can create and move files between folders, that means that the problem happens only when I use the ubuntu terminal.

Before arriving to this point I have been trying to move the files just using the mv command but permission was denied

Input:

mv new_file.txt /new_directory

Output:

mv: cannot move 'new_file.txt' to '/new_directory': Permission denied

I also changed file and directory permissions just in case but it didn´t work

chmod 777 new_file.txt
chmod 777 new_directory

I have had a look to similar issues here but I think they do not fit my problem (I don´t think the file is in a hidden directory or in a directory with a similar name as I have been doing trials on purpose creating several files & directories with different names). On the other hand I don´t know why I cannot execute the mv command without giving sudo permissions as this never happened to me before.

Thanks in advance, any help will be appreciated.

1 Answer 1

1

Your command is incorrect.

If your destination for the mv command begins with a /, the path is absolute.

/ is the path for your root file system so your command is telling bash to move your file to a directory directly under / which probably doesn't exist and will require special permissions due to its protected location directly under /. (You really shouldn't make a folder here for personal files).

If you are trying to move a file into a folder that is under your current directory, you should use:

mv new_file.txt new_directory/

You add the backslash at the end to indicate that you want it to be moved into that directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .