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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-12-2008, 08:55 PM
|
#1
|
|
LQ Newbie
Registered: Sep 2008
Posts: 24
Rep:
|
Guide me for copy and rename commands
Please guide me for using cp and rename for existing directories. What i want to do is
(1) i like to rename an existing dir. Which command should i use?
(2) i like to copy a directory including its files and sub directories to another place. Pls show me how to do it.
(3) i have a tar.gz file and guide me how to untar it into a directory with name i want to give.
My linux box is installed from LiveCD of Ubuntu 8.04LTS. Is there any command to delete a directory tree such as windows deltree command.
|
|
|
|
11-12-2008, 09:28 PM
|
#2
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
1) Use the "mv" command to rename files or directories.
2) Look at the "man cp" manpage. Use the -R option. If you use the -a option, you will retain the original permissions and ownerships.
3) Look in the "info tar" manual. If this is a tarball, then it has a base directory already and you run: tar -xvzf <tarball-name>
The dash is optional if all of the options are together. The f option precedes the filename. There are numerous options for tar. For example, you can save a timestamp when creating an archive and then later create an incremental backup. Also look at the "info find" manpage. Often find is used to locate files with certain criteria and the list is used by tar.
|
|
|
|
11-12-2008, 09:29 PM
|
#3
|
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797
|
In general, it will be good for you to get familiar with the man pages. For your questions, you want to look at:
man cp
man mv
man rename
man tar
man rm
man rmdir
Some general answers:
cp (copy) does not copy contents unless you use the -R flag (recursive)
mv (move) IS recursive by default--ie if you "mv" a directory, the contents go with it.
mv can also be thought of as "rename" (I am not familiar with the actual rename command, and I don't use it.
For example, the rename a file, and keep it in the same directory:
mv oldname newname
The way to learn all this is to simply try it. Try some different commands to see what happens, read the man pages, and try some more.
|
|
|
|
11-12-2008, 09:31 PM
|
#4
|
|
Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Rep: 
|
Deleting a directory tree is a forced recursive removal, so
rm -rf /directory/to/remove
|
|
|
|
11-12-2008, 09:49 PM
|
#5
|
|
Member
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609
Rep:
|
Give a man a fish and he will be fed for a day.
Teach a man to fish and he will be fed for a lifetime.
Please read the following link.
http://www.ss64.com/bash/
|
|
|
|
11-12-2008, 10:28 PM
|
#6
|
|
LQ Newbie
Registered: Sep 2008
Posts: 24
Original Poster
Rep:
|
Guide for copy and rename commands
Thank you to all for yr kind guidance. I've already reading with man cp man rename but i missed mv command. Anyway i will now try to read what you have suggested and try all things you've pointed out. recently our isp has some DNS problems and it is very slow or have no connections. As OKOS has said, i do agree learning to fish is for life. Now i try to get into the link you mentioned, but connection is too slow to get connected. Anyway i try later.
|
|
|
|
11-13-2008, 09:22 PM
|
#7
|
|
Member
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609
Rep:
|
Glad to be of help
Here at LQ someone could probably help you with the DNS issue also.
Cheers
okos
|
|
|
|
11-14-2008, 07:27 AM
|
#8
|
|
Member
Registered: Sep 2008
Location: Calcutta,India
Distribution: Fedora 11, OpenSUSE 11.0
Posts: 116
Rep:
|
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:41 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|