LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 12-07-2014, 08:33 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Rep: Reputation: Disabled
Trying to move a file from folder to folder in Ubuntu get a message: Permissio Denied


I have a Ubuntu VM. I have never moved files from one directory to another and now it is the time. I have this:

Quote:
alex@alex-VirtualBox:~/LEGENDRE/QUADRATURE$/mv four1.f08 /LEGENDRE
Response:

Quote:
mv: cannot move `four1.f08' to `/LEGENDRE': Permission denied
Why? It does not let me enter a PW, nothing.

Last edited by AlexBB; 12-07-2014 at 08:40 PM.
 
Old 12-07-2014, 09:13 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,667

Rep: Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710Reputation: 710
Do you have a directory named LEGENDRE both in your home directory and at the root directory? What are the permissions listed by 'ls -l /LEGENDRE'?
 
1 members found this post helpful.
Old 12-07-2014, 09:37 PM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 516

Rep: Reputation: 120Reputation: 120
Top level directories (like your /LEGENDRE) usually belongs root, because only root can create directories at "/".
So you can't move files there as regular user.
Either change permissions to /LEGENDRE directory to be able to write there or move your file as root, using "sudo" (or "su").
Keep in mind in latter case your file will be owned by root, so you can't access it as regular user later.
 
1 members found this post helpful.
Old 12-08-2014, 05:09 PM   #4
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
You guys scared me quite a bit. I do have a directory called LEGENDRE but I don't know where it is. I mean I use its files every day but how would I know if it is home or at the root? I work a lot of GFortran but my knowledge of the Ubuntu OS is rudimentary. This is why I post at newbies section here. I should probably read on the subject a little bit. Also I will try to check the permission the way Mr. Devil :-) and smallpond are suggesting. Now I am away from my Ubuntu machine, sorry. I will post explaining what happened.
 
Old 12-08-2014, 07:56 PM   #5
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 516

Rep: Reputation: 120Reputation: 120
According to you command:
Code:
alex@alex-VirtualBox:~/LEGENDRE/QUADRATURE$/mv four1.f08 /LEGENDRE
you have two directories named LEGENDRE.
The first one located at your home directory (tilde symbol "~" stands for your home directory, assume it is "/home/alex")
Since it located at your home directory, and hence inherits parent's directory permissions, you can access this folder and manipulate files located there.

The second LEGENDRE located at your filesystem root "/" (most top level directory).
Since root ("/") isn't your directory, you have no permissions to create, delete and modify files at /LEGENDRE because this folder inherits permissions from "/" i.e. belongs root user.
this command should list your top level directories with the permissions and ownership
Code:
ls -l /
Assuming there should be a string for LEGENDRE
 
1 members found this post helpful.
Old 12-08-2014, 08:47 PM   #6
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
Teufel, I am sorry but this is incorrect. What I actually wanted was to move the file in question four1.f08one step down, if it makes sense. I wanted to drop it behind QUADRATUTE, look:

VirtualBox:~/LEGENDRE/four1.f08 <== this is how I wanted it to place. So, I hoped it would move from the folder

/LEGENDRE/QUADRATURE/four1.f08 to the folder:

/LEGENDRE/four1.f08.

Does it make sense? Thanks, - A.
 
Old 12-08-2014, 08:51 PM   #7
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
smallpond, the way you wrote that command it did not work. That slash had to be removed.

Quote:
ls -l LEGENDRE
did work and gave me a list of all files in the LEGENDRE directory but no permissions.

Teufel's command

Quote:
ls -l /
Gave me some output. I think it was mostly system files. I've never seen them before. boot was one of them. It also said "total 88" but printed about 25.

Last edited by AlexBB; 12-08-2014 at 08:56 PM.
 
Old 12-08-2014, 08:58 PM   #8
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
So, the major question is: How can i start transferring files from one directory to another?
 
Old 12-08-2014, 09:02 PM   #9
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 556

Rep: Reputation: 52
You're probably looking for
Code:
sudo mv four1.f08 ../LEGENDRE
You should really read a bit about relative and absolute paths. This isn't particular to some linux distributions, but to UNIX systems in general.

LATER EDIT: You actually don't need the 'sudo', as you're in your home directory. So you can skip that.

Last edited by vincix; 12-08-2014 at 09:12 PM.
 
1 members found this post helpful.
Old 12-08-2014, 09:32 PM   #10
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 516

Rep: Reputation: 120Reputation: 120
Quote:
Originally Posted by AlexBB View Post
Teufel, I am sorry but this is incorrect. What I actually wanted was to move the file in question four1.f08one step down, if it makes sense. I wanted to drop it behind QUADRATUTE, look:

VirtualBox:~/LEGENDRE/four1.f08 <== this is how I wanted it to place. So, I hoped it would move from the folder

/LEGENDRE/QUADRATURE/four1.f08 to the folder:

/LEGENDRE/four1.f08.

Does it make sense? Thanks, - A.
It explains where is your fault: you added unnecessary slash at your command so we went wrong way (to the filesystem root):
if you want to move a file from ~/LEGENDRE/QUADRATURE to ~/LEGENDRE (one level up) try this:
Code:
cd ~/LEGENDRE/QUADRATURE
mv four1.f08 ~/LEGENDRE
Added:
Note that the ~/LEGENDRE isn't the same as /LEGENDRE
They are two different directories.
Extra tilde (~) is substitution for your home directory, so fully qualified path for ~/LEGENDRE is
Code:
/home/alex/LEGENDRE
Compare it to
Code:
/LEGENDRE
They are different

Last edited by Teufel; 12-08-2014 at 09:49 PM.
 
1 members found this post helpful.
Old 12-08-2014, 09:52 PM   #11
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
Teufel, thank you. Your command worked, HOWEVER, I did something stupid. This is what happened. First of all I had no file to move, because yesterday out of desperation, after I tried different commands I simply created a new four1.f08 file in that directory where I wanted it to be, copied all code to a clipboard and pasted it then to a new file. Then I destroyed the old one.

So, now I had to crease a new file in ~/LEGENDRE/QUADRATURE. I then moved it to ~/LEGENDRE/ and then I decided to try to move it back for practice. So, I used this command mv four1_1.f08 ~/QUADRATURE(an empty file actually). I cannot find the file I wanted to move back in QUADRATURE folder. Instead the command created a file QUADRATURE in what appears to be the root directory. And the empty file I created for the purpose of training has disappeared. Oh' Lordie. = A.
 
Old 12-08-2014, 10:41 PM   #12
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 516

Rep: Reputation: 120Reputation: 120
You've twisted my brain
Quote:
now I had to crease a new file
What does "crease" means? Is it "create" or is it "erase"? Or is it "create+erase"?
You have to calm down.
If you lost a file, may be it not erased, just moved somewhere. Try to find it:
Code:
cd /home/alex
find -name  four1.f08
if it exists somewhere under your home directory, "find" command will find it.

And some tips:
1.Use bash autocompletion. When you typing a file name or directory name, do not type it completely, type few first letters and then press "Tab" key. If you have only one file/directory name that matches to typed letters, autocompletion will extend it to the full name. If there is no matching names, nothing will be added to the typed part. If there is a few matches, all of them will be listed, continue with the next letters. Autocompletion helps to prevent such an errors where you typed erroneous file/directory name.
2.Do not forget that "~" is the substitution for you home directory. I.e. "cd ~" is equal to "cd /home/alex"
3.Do not rush. Do not experiment with unfamiliar commands on important files. Create some temporary directory with files to train there.
 
1 members found this post helpful.
Old 12-09-2014, 11:58 AM   #13
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
Teufel, thank you. I am at work now and will do what you suggested later tonight. That word meant "create" not "crease," sorry for misspelling. Since the file was really temporary and I was focusing on other things I realized after 30 minutes that I forgot its name. So, I cannot now find where it is. It sound comical but it is true. I work with Ubuntu for 2-3 hours every nigh and on weekends, hopefully I will find that file eventually, but now I want to follow what you said, perhaps try another transfer and report back but it will take some time. Thank you very much.
 
Old 12-09-2014, 08:42 PM   #14
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
OK, it seems, everything is working. I carefully read all posts and practiced a few moves. Now it is simple. I moved a test file from one directory to another, back and forth. Now I will pay attention to tilde and such. The issue is resolved. I marked all posts as useful and they really are. Thank you very much.
 
  


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
[SOLVED] move file and folder date stamps smithy2010 Linux - Newbie 3 05-08-2010 11:52 AM
find and move to folder and file dulahdaglace Linux - Newbie 1 09-15-2009 11:44 PM
How to automatically move files from one folder into another folder? xmrkite Linux - Software 6 11-05-2006 11:39 AM
i move my /etc folder in my /home folder Casanogab Linux - Newbie 8 03-31-2006 02:21 PM


All times are GMT -5. The time now is 03:24 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration