LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what can I do if I forgot adding '-C' option when extracting files? (https://www.linuxquestions.org/questions/linux-newbie-8/what-can-i-do-if-i-forgot-adding-c-option-when-extracting-files-803870/)

seflyer 04-23-2010 07:34 PM

what can I do if I forgot adding '-C' option when extracting files?
 
I describe what happened:
I tried to install gfortran on my computer. When I extract the tarball, I forgot the '-C' option of the command 'tar', which should be added, according to the instruction of installation. That is to say, I wrote in the \tmp directory:

$tar -zxvf gfortran.tar.gz

which should be:

$tar -zxvf gfortran.tar.gz -C /

Then, the tarball creates a '/usr' directory under '/tmp' directory, and it contains only a /local directory, which contains only a /gfortran directory.
The thing is, when I modify the name of this directory, for example, from /usr to /usr-modi, I found that the name of the directory /usr under the root directory is also changed from /usr to /usr-modi.

How can I delete this annoying /usr directory under /tmp, without tragically affect /usr under the root directory? Any idea?
Thanks!

kbp 04-23-2010 08:48 PM

You need to be aware of the difference between relative and absolute paths... a directory with a leading '/' is an absolute path

'/usr' means the 'usr' directory under '/' (the root)
'usr' means the 'usr' directory in your current directory

To modify the 'usr' directory under '/tmp', it's absolute path is '/tmp/usr'

eg.
$ pwd
/home/me
$ mv /tmp/usr /tmp/usr-modi
$ ls /tmp
usr-modi


If your current directory was '/tmp' then you could also refer to it by the relative path 'usr' or './usr'

eg.
$ pwd
/tmp
$ ls
usr
$ mv usr usr-modi

To fix your current problem, try these steps:

$ mv /usr-modi /usr
$ cd /tmp
$ tar -zxvf gfortran.tar.gz -C /

hth

seflyer 04-24-2010 08:36 AM

Quote:

Originally Posted by kbp (Post 3945907)
You need to be aware of the difference between relative and absolute paths... a directory with a leading '/' is an absolute path

'/usr' means the 'usr' directory under '/' (the root)
'usr' means the 'usr' directory in your current directory

To modify the 'usr' directory under '/tmp', it's absolute path is '/tmp/usr'

eg.
$ pwd
/home/me
$ mv /tmp/usr /tmp/usr-modi
$ ls /tmp
usr-modi


If your current directory was '/tmp' then you could also refer to it by the relative path 'usr' or './usr'

eg.
$ pwd
/tmp
$ ls
usr
$ mv usr usr-modi

To fix your current problem, try these steps:

$ mv /usr-modi /usr
$ cd /tmp
$ tar -zxvf gfortran.tar.gz -C /

hth

Thanks! But I guess I didn't explain clearly.
In fact, when I said I try to modify the name of the directory '/usr', I did mean that I modified the one under /tmp.
So the problem is that, when I input:

#mv /tmp/usr /tmp/usr-modi

then, not only '/usr' under /tmp changed its name, '/usr' under the root directory also did.
It seems that the misused 'tar -zxvf gfortran.tar.gz' has constructed a connection between these two '\usr' directories. I want to delete the one under \tmp, but I am afraid I would delete the one under \root at the same time...

seflyer 04-24-2010 12:48 PM

Now the problem disappears! I guess, after all, I made a mistake pointed out above by kbp without knowing it. Thanks again!

kbp 04-25-2010 09:34 AM

If you could post the output of:

'ls -l /tmp/u*'

and

'ls -l /usr*'


All times are GMT -5. The time now is 01:17 PM.