LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2008, 08:00 AM   #1
DaftDave
Member
 
Registered: Mar 2008
Posts: 34

Rep: Reputation: 15
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
 
Old 04-27-2008, 08:13 AM   #2
Neavirc
LQ Newbie
 
Registered: Apr 2008
Posts: 12

Rep: Reputation: 0
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`
 
Old 04-27-2008, 08:16 AM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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.
 
Old 04-27-2008, 08:21 AM   #4
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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.
 
Old 04-27-2008, 08:21 AM   #5
Neavirc
LQ Newbie
 
Registered: Apr 2008
Posts: 12

Rep: Reputation: 0
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/
 
Old 04-27-2008, 11:47 AM   #6
DaftDave
Member
 
Registered: Mar 2008
Posts: 34

Original Poster
Rep: Reputation: 15
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
 
Old 04-27-2008, 11:55 AM   #7
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Have you actually checked that the file is in the current directory? Are you using the correct file name (especially with regards to capitalisation)?
 
Old 04-27-2008, 12:12 PM   #8
DaftDave
Member
 
Registered: Mar 2008
Posts: 34

Original Poster
Rep: Reputation: 15
Success! The error was of my own doing by mistyping the file name. Thanks for all the help
 
Old 04-27-2008, 12:19 PM   #9
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
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
 
Old 04-27-2008, 12:24 PM   #10
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
xine command line? or some other command line only engine? lumix Linux - Software 2 08-10-2007 10:46 AM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 10:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration