943,960 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Apr 9th, 2008
0

Rename

Expand Post »
Is it just me, or is copying then removing the old file a hassle? Why doesn't Linux have a built in rename command for single files / directories?
Reputation Points: 118
Solved Threads: 30
Posting Shark
linux is offline Offline
931 posts
since Aug 2006
Apr 9th, 2008
0

Re: Rename

Hey there,

You can use "mv" for files and directories.

Perhaps I'm misunderstanding.

Hope that helps

, Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Apr 9th, 2008
0

Re: Rename

I'm sorry. Looking at your profile, I think you're just kidding You got me

,Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Apr 13th, 2008
0

Re: Rename

yeah mv
Moderator
Featured Poster
Reputation Points: 1784
Solved Threads: 575
Moderator
jbennet is offline Offline
16,520 posts
since Apr 2005
Apr 15th, 2008
0

Re: Rename

but that moves and renames whilst removing the old file !?
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
Apr 15th, 2008
0

Re: Rename

switches can change that
Moderator
Featured Poster
Reputation Points: 1784
Solved Threads: 575
Moderator
jbennet is offline Offline
16,520 posts
since Apr 2005
Apr 15th, 2008
0

Re: Rename

I'm pretty mv sure it's cp then rm

, Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Apr 25th, 2008
1

Re: Rename

No, thats actually exactly wrong.

The mv command does not make a new file. Period. The datablocks holding the information remain unchanged. All that happens is that the entry in the directory file that holds the inode information is copied to the new directory, and then the inode information is removed from the old directory.

To demonstrate this; create a file, and change ownership to someone in your group, but first chmod the file to 600. Chmod the directory the file is located in to 770, and make sure that it is owned by your group and/or you.

Create a new directory (770), with the same ownership. Now, technically, you will not have write access to the file (600 owned by Joe). But, since you have permissions to change the inode information contained in both directory listings, you will be able to run an mv command on the file. You will not, however be able to read from that file to perform the cp command. You can mv, but not cp. You have no access to the stored data, just to the inodes pointing to the data. Therefore, you change the location from which those inodes can be accessed, but do not modify the original file. This is a true mv.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008
Apr 25th, 2008
0

Re: Rename

Well, not exactly

I threw that one out there without thinking, I'll admit and you are correct in the circumstance that both files are on the same partition.

If you mv /bob/dir1 to /bob/dir2 - assuming /bob is one partition/filesystem containing dir1 and dir2 - then the pointer to inode explanation is correct.

However, if you mv a file from /bob/dir/1 to /joe/dir/1 - assuming /bob is one partition/filesystem and /joe is another partition/filesystem - Unix (at least, Solaris) actually does do a cp and then an rm. The same test you propose will not allow you to mv or cp the file you don't have permissions to access in that situation.

Hopefully, this post is finally resolved. If I'm not mistaken it all started out as a joke

Take care,

Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jun 3rd, 2008
0

Re: Rename

touche!

I had not thought about that. In that case, you would be correct.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in IT Professionals' Lounge Forum Timeline: how to create a proper blog
Next Thread in IT Professionals' Lounge Forum Timeline: Gates Kicks Off Tech-Ed By Saying Good-Bye





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC