[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

unix basic commands

Posted on 2011-10-10
15
Medium Priority
?
282 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:Sid_F
  • 3
  • 3
  • 2
  • +6
15 Comments
 
LVL 8

Expert Comment

by:pilson66
ID: 36942576
cd ~unixstuff
cp science.txt /vol/examples/tutorial/
0
 
LVL 8

Expert Comment

by:pilson66
ID: 36942580
sorry

cd ~unixstuff
cp /vol/examples/tutorial/science.txt ./
0
 
LVL 5

Expert Comment

by:KGNickl
ID: 36942586
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 35

Expert Comment

by:torimar
ID: 36942592
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
 
LVL 6

Author Comment

by:Sid_F
ID: 36942643
Screen dump
ubuntu-errors.jpg
0
 
LVL 6

Author Comment

by:Sid_F
ID: 36942692
I can save a file fine through the gui to the unixstuff folder
0
 
LVL 35

Expert Comment

by:torimar
ID: 36942739
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
 
LVL 4

Accepted Solution

by:
Christopher Raymond Mendoza earned 1600 total points
ID: 36942747
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
 
LVL 20

Expert Comment

by:simon3270
ID: 36944065
~unixstuff is the home directory of a user called unixstuff.

To cd to a directory in your home directory, use

    cd ~/unixstuff
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 400 total points
ID: 36944406
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
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36945010
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
 
LVL 20

Expert Comment

by:simon3270
ID: 36945306
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 36951859
can you show results of commands below?

ls -l /vol/examples/tutorial/science.txt
cd ~unixstuff
pwd
touch myfile
ls -la
0
 
LVL 20

Expert Comment

by:simon3270
ID: 36952209
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
 
LVL 6

Author Closing Comment

by:Sid_F
ID: 36954816
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question