"cp" is not working

14,719

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/
Share:
14,719

Related videos on Youtube

Double S
Author by

Double S

Updated on September 18, 2022

Comments

  • Double S
    Double S almost 2 years

    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?

    • Jos
      Jos about 8 years
      Try cp b vlsi/. However, that supposes that the file b is in your current directory, and so is the sub-directory vlsi.
    • Jos
      Jos about 8 years
      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
      Jos about 8 years
      Try again. You probably typed a space between ~ and /vlsi/.
    • Double S
      Double S about 8 years
      you are right thanks..can you please provide me an answer for this: cp: cannot create regular file ‘/./b’: Permission denied
    • Jos
      Jos about 8 years
      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.