LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command line (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-638166/)

DaftDave 04-27-2008 08:00 AM

Command line
 
Have been trying to learn basic commands and using the command line. So i created an HTML file which i called: new_file and saved it to my desktop. I then tried to move new_file to the var directory using:

$ mv new_file var

But i keep getting an error:

$ mv: cannot stat 'new_file'; No such file or directory.

Could someone enlighten an old n00b please. Thanks

Neavirc 04-27-2008 08:13 AM

As you use relative path, you need to be in the same directory where new_file is. Type command `ls` and make sure that you'll see output like this

$ ls
new_file

That means you in the right directory. Otherwise type `cd /home/daftdave/path/to/directory/containing/new_file_file` and repeat your actions.

P.S. To decide in which directory you are, just issue the command `pwd`

homey 04-27-2008 08:16 AM

If you are not in the directory where the file exists, you need to use the full path to the file. Also, the command you are using is just going to rename your file to var as you didn't do like this...
mv new_file /var
Even so, you are likely to have permission denied unless you do it as root user.

XavierP 04-27-2008 08:21 AM

From the dollar sign, I am assuming you tried to do this as your normal user. Once you have resolved the issue with the new_file file, you will probably hit permissioning problems.

Firstly, that command won't move the file to the var directory. It will rename it as var. The command you need is
Code:

mv new_file /var
The leading forward slash tells the system that you are moving to a directory.

Secondly, you will need to be root (or have root powers) to do this. So do this:
Code:

sudo mv new_file /var
<enter your own password>

or
Code:

su
<enter root password>
mv new_file /var
exit

The first one gives you extra powers for the duration of the command, the second one turns you into the root user and then you execute the command as root.

Neavirc 04-27-2008 08:21 AM

There is one more thing which will be useful to you. I'm about documentation.

To know how to use a program exactly, which options that understands you should type smth like this:

$ man pwd

Following is the detailed manual of how to use some of basic command line utils:

http://www.gnu.org/software/coreutils/manual/

DaftDave 04-27-2008 11:47 AM

No matter whether i try to move 'new_file' to the var directory as root or as dave@admin:~$ i still keep getting the same error message: rm cannot move 'new_file': no such file or directory? And i was using: mv new_file /var

Nylex 04-27-2008 11:55 AM

Have you actually checked that the file is in the current directory? Are you using the correct file name (especially with regards to capitalisation)?

DaftDave 04-27-2008 12:12 PM

Success! The error was of my own doing by mistyping the file name. Thanks for all the help

mrrangerman 04-27-2008 12:19 PM

Quote:

DaftDave

No matter whether i try to move 'new_file' to the var directory as root or as dave@admin:~$ i still keep getting the same error message: rm cannot move 'new_file': no such file or directory? And i was using: mv new_file /var
Like Nylex said the file has to be in the directory you are currently in. To add to that you can move a file from another directory from where you are but you need to give the path.

mv /path/to/file/file.name /path/to/put/file/

To rename the file you would add the new name at the end of the command like so.

mv /path/to/file/file.name /path/to/put/file/newfile.name

mrrangerman 04-27-2008 12:24 PM

Quote:

DaftDave
Success! The error was of my own doing by mistyping the file name.
Ahh That makes a big difference, yea linux is case sensitive Dave dave DAVE are seen as all different words or directory names.


All times are GMT -5. The time now is 10:23 PM.