0

I am a newcomer in Linux. I tried to copy a file into another directory but it says that the directory does not exist.

I tried this:

cp b / vlsi

Here b is the file which is at another directory named mas and I am quite sure that vlsi is a directory.

What is the error of my code?

5
  • Try cp b vlsi/. However, that supposes that the file b is in your current directory, and so is the sub-directory vlsi.
    – Jos
    May 10, 2016 at 19:09
  • In that case, vlsi is a subdirectory of your home directory and can be addressed as ~/vlsi, with ~ short for /home/yourusername. So the copy command should be cp b ~/vlsi/.
    – Jos
    May 10, 2016 at 19:21
  • Try again. You probably typed a space between ~ and /vlsi/.
    – Jos
    May 10, 2016 at 19:34
  • you are right thanks..can you please provide me an answer for this: cp: cannot create regular file ‘/./b’: Permission denied
    – Double S
    May 10, 2016 at 19:41
  • You must have made another typo, because now you are trying to copy the file b to the root directory / (the extra ./ does nothing). The command cp b ~/vlsi/ should work.
    – Jos
    May 10, 2016 at 19:43

1 Answer 1

0

The command is cp b vlsi/ meaning: copy the file b into the directory vlsi.

If the file b or the target directory are not in the current directory (the directory from which you are issuing the command), you need to give the whole path. In your case, the directory vlsi is not in the current directory, but in your home directory. So the full command becomes:

cp b /home/yourusername/vlsi/

However, instead of typing /home/yourusername you can simply type the symbol ~. So this command does the same thing:

cp b ~/vlsi/

You must log in to answer this question.

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