LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 11-12-2008, 08:55 PM   #1
Ye Myint
LQ Newbie
 
Registered: Sep 2008
Posts: 24

Rep: Reputation: 15
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.
 
Old 11-12-2008, 09:28 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.
 
Old 11-12-2008, 09:29 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
Old 11-12-2008, 09:31 PM   #4
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Deleting a directory tree is a forced recursive removal, so

rm -rf /directory/to/remove
 
Old 11-12-2008, 09:49 PM   #5
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Rep: Reputation: 37
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/
 
Old 11-12-2008, 10:28 PM   #6
Ye Myint
LQ Newbie
 
Registered: Sep 2008
Posts: 24

Original Poster
Rep: Reputation: 15
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.
 
Old 11-13-2008, 09:22 PM   #7
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Rep: Reputation: 37
Glad to be of help

Here at LQ someone could probably help you with the DNS issue also.

Cheers

okos
 
Old 11-14-2008, 07:27 AM   #8
ritam_bkp
Member
 
Registered: Sep 2008
Location: Calcutta,India
Distribution: Fedora 11, OpenSUSE 11.0
Posts: 116

Rep: Reputation: 17
read this manual
http://rute.2038bug.com/index.html.gz
 
  


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
mulitple copy a existing directory and rename it at the end sequentially in BASH neo2k Linux - Newbie 2 08-20-2008 10:45 AM
copy and rename the existing directory using BASH script neo2k Linux - Software 3 08-20-2008 10:43 AM
What copy commands does Linux have? IonMarais Linux - Newbie 4 10-26-2006 02:40 AM
where to get the commands guide ? shemjaza Linux - Newbie 3 12-26-2003 10:01 PM


All times are GMT -5. The time now is 04:33 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration