unix basic commands

I'm starting to learn linux/unix basic commands.
I have a text file called science, I have saved it to /vol/examples/tutorial/

In the exercise I am doing I have already created a folder called /unixstuff in my home folder

I want to copy a the file science to my unixstuff folder, the advised command is
cd ~unixstuff
This gets me to the unixstuff folder I then type
cp /vol/examples/tutorial/science.txt .

I keep getting no such file or directory. I can drill down to /vol/examples/tutorial and can see the file science, I created the file with text editor so I presume the extension is correct, I tried it also witout the extension.

I'm sure its something simple I am missing?
LVL 6
Sid_FAsked:
Who is Participating?
 
Christopher Raymond MendozaConnect With a Mentor Commented:
Hello Sid F,

Based on your screenshot, your file science.txt is not in /vol/examples/tutorial/ but rather in ~/vol/examples/tutorial/.

So I guess these commands should work:
    cd ~unixstuff
    cp ~/vol/examples/tutorial/science.txt ./
0
 
pilson66Commented:
cd ~unixstuff
cp science.txt /vol/examples/tutorial/
0
 
pilson66Commented:
sorry

cd ~unixstuff
cp /vol/examples/tutorial/science.txt ./
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
KGNicklCommented:
I would think the command you did should work. Could be a permissions problem with the directory you are in? Possibly you don't have write access to ~unixstuff? Might want to check the permissions on the directory first. Can you create and save a file? What are the permissions set at? If you have permissions try.

You could try:

cd /vol/examples/tutorial/
cp science.txt ~unixstuff
0
 
torimarCommented:
Linux does not have required file extensions as Windows has. You are free to use an extension, though, but that would be simply a part of the name.
If you only see "science" as a name, then that's it. Linux does not hide stuff away from the user as Windows tries to.

If you are unsure about filenames (or they are too long to type), simply type the first 2 or 3 letters, then hit the TAB key. Linux will complete the name or suggest a completion for you.
0
 
Sid_FAuthor Commented:
Screen dump
ubuntu-errors.jpg
0
 
Sid_FAuthor Commented:
I can save a file fine through the gui to the unixstuff folder
0
 
torimarCommented:
Where does the folder "vol" reside? Is it actually a first tier folder, like /usr, /home, /root etc?
If not, you need to specify the full path.

In your "cd" command you used "vol" without slash, meaning "vol" is a sub-folder of the folder you are presently in. In the "cp" command, you used a slash (/vol), meaning it is a first tier folder, so Linux searches for it under "/", the main root.
So either use a complete path (easier and recommended), or an exact relative path, relative to the one you're in (harder).
0
 
simon3270Commented:
~unixstuff is the home directory of a user called unixstuff.

To cd to a directory in your home directory, use

    cd ~/unixstuff
0
 
TintinConnect With a Mentor Commented:
Either of the following commands will work

cp ~/vol/examples/tutorial/science.txt .

Open in new window


or

cp ../vol/examples/tutorial/science.txt .

Open in new window

0
 
Hugh McCurdyCommented:
When you try to diagnose a problem like this, use ls

$ ls /vol/examples/tutorial/science.txt

if that's found then the cp should work.  So, let's assume that's not found.

$ ls -ld /vol

Does that work?  Based on that I read, probably not.  In any event, if it doesn't work, then the cp will fail and there's little point to trying cp until you figure out where vol is.  Since you can drill down to it, you have some idea.

Now if   ls /vol   did work then you try

$ ls -ld /vol/examples

And keep adding more directories (folders) until you find the problem.


One other thing you might want to learn, if you haven't, is was highlighting text and then clicking the middle mouse button does in Linux.  (It's a different type of copy/paste).  It can be useful with a problem like the above so you can do less typing.

The other trick (still thinking as I type) is the up arrow key.  This works at the bash shell and likely many others.  It repeats the last command.  Less typing.

0
 
simon3270Commented:
Looking closely, there is a ~ before the /vol in the prompt in the jpg view, i.e. the vol directory is also a subdirectory of your home directory.  Also the first command in that jpg is "cd vol/examples/turorial/", with no "/" before the "vol".

So, in summary:
  cd ~/unixstuff
  cp ~/vol/examples/tutorial/science.txt .
0
 
omarfaridCommented:
can you show results of commands below?

ls -l /vol/examples/tutorial/science.txt
cd ~unixstuff
pwd
touch myfile
ls -la
0
 
simon3270Commented:
Again:
- vol is a subdirectory of the user's home directory - /vol does not exist, but ~/vol does.
- there is no user called unixstuff, so "cd ~unixstuff" will fail.  There *is* a directory called unixstuff in the user's home directory, so "cd ~/unixstuff" will go to that directory.
0
 
Sid_FAuthor Commented:
Thank you. The two accepted answers met the requirements and gave me another option of ../
I didn't fully understand the directory structure which was the initial problem. Thanks everyone for the input.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.