Sid_F
asked on
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/sci ence.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?
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/sci
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?
sorry
cd ~unixstuff
cp /vol/examples/tutorial/sci ence.txt ./
cd ~unixstuff
cp /vol/examples/tutorial/sci
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
You could try:
cd /vol/examples/tutorial/
cp science.txt ~unixstuff
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.
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.
ASKER
Screen dump
ubuntu-errors.jpg
ubuntu-errors.jpg
ASKER
I can save a file fine through the gui to the unixstuff folder
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).
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).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
~unixstuff is the home directory of a user called unixstuff.
To cd to a directory in your home directory, use
cd ~/unixstuff
To cd to a directory in your home directory, use
cd ~/unixstuff
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When you try to diagnose a problem like this, use ls
$ ls /vol/examples/tutorial/sci ence.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.
$ ls /vol/examples/tutorial/sci
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.
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/sc ience.txt .
So, in summary:
cd ~/unixstuff
cp ~/vol/examples/tutorial/sc
can you show results of commands below?
ls -l /vol/examples/tutorial/sci ence.txt
cd ~unixstuff
pwd
touch myfile
ls -la
ls -l /vol/examples/tutorial/sci
cd ~unixstuff
pwd
touch myfile
ls -la
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.
- 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.
ASKER
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.
I didn't fully understand the directory structure which was the initial problem. Thanks everyone for the input.
cp science.txt /vol/examples/tutorial/