aspose file tools*
The moose likes Linux / UNIX and the fly likes 2 in 1 Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "2 in 1 Question" Watch "2 in 1 Question" New topic
Author

2 in 1 Question

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 819
Hi All,
I'm telneting into a PC running Linux. On the Linux machine I'm logged in as root and on the laptop I'm telneting in with I'm trying to also use root but it fails (re-prompts me after giving invalid user error). When using a different user I can log in and then when I use the su command I can switch to the root user. Why is this so?
Second, I'm trying to unzip a file called <file.name>.tar.z. What command, parameters, and so forth should I use? I'm trying to unzip a file in directory /a/b to another one called /c/d (off the root diretory. I've used a,b,c,d as directory names for simplicity sake. Can anyone tell me what I should use and, if parameters are to be used what each will be used for? Thanks so much.

Rob
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

First question:

Telnet transmits passwords in cleartext over the network. You really don't want to be sending cleartext passwords, especially root passwords, over the Internet -- most people use ssh (kind of a secure super-Telnet) instead these days, and I highly recommend that you do, too.

Anyway, because sending your root password in cleartext over the Internet is basically a way of saying "Please take over my computer and use it to run a Nigerian money-laundering scheme", many implementations of telnetd will sensibly disallow remote root logins -- and it looks like yours it, thankfully, one of them!

Question 2:

[rob /]$ cd /c/d
[rob /c/d]$ tar xzf /a/b/foo.tar.z


[Jess in Action][AskingGoodQuestions]
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 819
Thanks so much I'll give it a try. By the way what are the xzf needed and what are each for? Thanks again.

Rob
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Rob Pike:
By the way what are the xzf needed and what are each for? Thanks again.

Rob


x: extract
z: uncompress, using gunzip
f: operate on the file, named next
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 819
Thanks again. I was wondering when using the Z option when it was needed and when it isn't. Could you just explain the different parameters used for setting up zip files and exploding them. I'm just starting to get into Linux and I'd like to know the differences between the different cases and the benefits of using each type of zip and unzip are. I'd so much appreciate. Thanks again.

Rob
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

"tar" is the "Tape ARchive" program. Traditionally, it stuck uncompressed files together onto a single file tape, or pulled a file off a tape and split it into separate files. The single file is a "tar archive", and when stored on disk instead of a tape, it's traditionally named "something.tar". To unpack a something.tar file, you just say "tar xf something.tar" .

If you compress a tar file using gzip, bzip, compress, compact, or pack (these are all different compression programs that are available on some UNIX systems!) then it's traditional to name the resulting file "something.tar.gz" (if you used gzip), "something.tar.Z" (compress,) or "something.tar.z" (compact or pack). In this case, to unpack the file, you have to either uncompress the file first, or, if you've got GNU tar (on Linux, that's the only game in town), you can just tell tar to do the uncompression for you. You can say "tar xzf something.tar.gz" and tar will figure out what kind of compression was used, and extract the files.

You can make a tar archive using "tar cf something.tar foo bar baz", where foo bar and baz are the files to include in the arvhive. You can make a compressed archive by adding the "z" again: "tar czf something.tar.gz foo bar baz".

Note, by the way, that you can get fairly friendly documentation for a command like "tar" using the "info" program: "info tar".
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 819
Thanks for the response. I didn't realize that you had to specify the .tar and .tar.gz, etc.., when using tar. I thought (using your example) that the archive something was specified and that the .tar, .z, .gz, etc.., were put in place using the parameters (i.e. czf) as guidelines. Thanks for the helpful information.

Rob
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16070
    
  21

".tgz" is a common shorthand for ".tar.gz". Either one is OK.

The "z" option on tar is a Linux convenience item. Not all unices support it. In any event, a ZIP (or jar) file basically compresses the individual files within the ZIP archive, whereas tar doesn't compress files at all, but the "z" option invokes a compressor (gzip, by default) to crunch the entire tarball.

"tar xvzf myfile.tar.gz" is functioanlly equivalent to:

gunzip myfile.tar.gz # produces file "myfile.tar"
tar xvf myfile.tar

The "v(ervose)" option lists the names of the files as they are being extracted. I like to do that.

Most Unix programs (although I think gzip may be an exception) don't really pay attention to filename extensions. They expect you to be doing the right thing regardless of what the file is named.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
jQuery in Action, 2nd edition
 
subject: 2 in 1 Question