I am trying to move a file from one directory to other by command line.I used this command
raghul@raghul-Aspire-5750Z:~/temp/newfolder$ mv copy.txt /temp/
I got error like this
cannot create regular file '/temp': Permission denied
Can someone help me to figure this out? I need to move a file from one directory to other.
First of all you are using the copy command cp
, not the move command mv
.
Secondly you are trying to copy the file to a new file named /temp
, ie. a file named temp
in the /
directory. This resides in the filesystem's root directory, which is mostly likely owned by root. Unless you have root permissions you can not write to the root directory.
Given that you are naming the file temp
, I assume that you want to move the file to the /tmp
directory, for which you will have permission to write to. Do this:
$ mv copy.txt /tmp
This will work only if you also have write permission on the file copy.txt
because you need to be able to remove it. If you just wanted to copy the file, just read permission is required.
Otherwise, if you really do wish to move the file to a /temp
directory, you can use sudo
to do that, provided that you are set up as a sudo user:
$ sudo mv copy.txt /temp
[sudo] password for raghul
I just noticed that you're in a personal directory called ~/temp/newfolder
. Is that the temp
you're trying to move the file to: your personal one, in which newfolder
is in? So you want to move the file up one directory?
Then the problem is that your command is missing the 'personal' tag ~
. The command should be:
mv copy.txt ~/temp/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With