0

Okay so for a research project, I am charged with working on a digital video game that happens to be formed by the use of Unix and emacs (don't know if they are the same thing because I just started using it). But, anywayyy, I first tried to use

cp .ArtTunnel.jpg ../steph

but that didn't work at all of course. I have also tried to use

cp .ArtTunnel.jpg steph

but that also didn't work. When I tried either one, it said it isn't a file or directory. So how exactly do you copy a image from one directory to another?

  • 1
    The basic syntax of your command is correct - however a . as the first character of the filename .ArtTunnel would imply the file is hidden - which would be unusual for files of that type. – steeldriver Mar 8 at 20:54
  • 1
    Perhaps you meant to use ./ to indicate filename in current working directory, not .ArtTunnel. As steeldriver pointed out these files are meant to be ignored by ls and treated as "hidden" by filemanager, though they're in no way "hidden" really - they still exist on disk and nothing prevents utilities from reading their contents – Sergiy Kolodyazhnyy Mar 8 at 21:30
0

You have two issues at play here. The first is your source path is unlikely to be correct. Unless the filename actually starts with a dot, it looks like you are trying to specify the current directory, but failing to include the slash between the period and the filename.

Your second issue is basically similar, when you say “steph”, you are telling copy to create a file named “steph”. If you want an existing directory, named “steph” to be your target, it needs to end with a slash.

cp ArtTunnel.jpg ../steph/

Note that the “./“ isn’t required before the ArtTunnel.jpg filename, when you execute this command from the same directory as the file currently exists in.

  • 1
    Also, it is generally best practice to include the full text of any error message you are getting, as part of your question. – Don Simon Mar 8 at 21:22
  • Correct. If you don’t put the trailing slash at the end of a name you assume is an existing directory, cp will create the file as that name, and give no error. If you include the trailing slash, and there is no such directory, cp fails with an error. – Don Simon Mar 8 at 21:47
0
cp image-file-path  destination path

E.g

cp file.jpg /root/home/user/

And please make sure you have read and write permission on folder where you trying to copy file.

ls -ld /destination-directory-path
0

If the ArtTunnel.jpg is not a hidden file the "." is unnecessary. If the file is in the current directory (you can list all files in the directory with the "ls" command). The "prompt" before your command sometimes lists your current directory, and you can also list it with the "pwd" command.

cp ArtTuneel.jpg ../steph/ copies the file to the directory steph if steph is one level up from your current directory. If steph is not located one level above your current directory, you'll have to use a different "path" to locate it.

Unix\Linux (hereafter *NIX) users should have a "home" directory with all their files, and it can be represented in your commands as "~". So cp ArtTunnel.jpg ~/Documents/ for example would copy ArtTunell.jpg to the Documents directory of the current user.

Using ~ and .. gives you "relative paths." The entire *NIX directory structure starts at the "root" directory, represented by a lone slash: /

Paths that start with the slash are "absolute" paths. For the user "moi" the absolute path of the home directory is normally located at /home/moi.

*NIX is designed with multiple users in mind, and so file permissions play a big role in where you can copy files, what files you can view, and whether you can execute programs. Everything is caught in a matrix of "read-write-execute" permissions. You normally can copy freely in your home directory. Watch out for the permissions issues though.

There's some "online" documentation and manuals accessible from the terminal by typing man command-name, in your case man cp. The *NIX manuals are pretty terse however. Sometimes the GNU Project's "info" documentation is more informative. It can be accessed by typing info command-name, in your case info cp.

This tutorial describes the "cp" command gently, but gives some good details: https://www.cyberciti.biz/faq/copy-command/. This is a more general *NIX command tutorial: http://www.linfo.org/command_line_lesson_1.html. There are also good video tutorials out there. If you're unfamiliar with Emacs, it has a built-in tutorial you can run by pressing Ctrl+h, followed by "t".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.