View Full Version : tar.gz and zip
Stecyk
12-20-2007, 01:59 PM
Hi,
Working off this prior thread: http://www.aota.net/forums/showthread.php?t=23436
I'd like to ask a question regarding tar.gz and zipped files.
I would like to an efficient way to untar and unzip files once they are loaded to the server.
Say, for example, I have:
1) File foo1.tar.gz located in \fqdirect1\ directory
2) File foo2.zip located in \fqdirect2\ directory
What command would I issue in each instance to untar/unzip the files into their respective directories?
I usually upload the files once in a blue moon. I have been unzipping on my PC and then uploading the files individually through an FTP software package. I suspect that there is a much better way. At present, I am doing this operation more than I'd like, so the answer would be very helpful.
Regards,
Kevin
Bruce
12-20-2007, 02:04 PM
1) File foo1.tar.gz located in \fqdirect1\ directory
2) File foo2.zip located in \fqdirect2\ directory
What command would I issue in each instance to untar/unzip the files into their respective directories?cd /fqdirect1/
tar -xzf foo1.tar.gz
cd /fqdirect2/
unzip foo2.zipNote that Linux (like all UNIX compatible systems) uses forward slashes for directory separators, unlike Windows which prefers backward slashes.
I use tar -xzpf file.tar.gz to uncompress a tar.gz file
I use unzip file.zip to unzip
Oops... Bruce beat me and gave a better explanation, despite my new ergonomic racing keyboard. Pays to be a genius!
Stecyk
12-20-2007, 02:06 PM
Thank you both. :yeah:
I am bookmarking this post, because I know I will be using it frequently.
Stecyk
12-20-2007, 02:14 PM
Hi,
Follow-up question, from SSH Telnet,
I tried,
cd /cgi-bin/
I got a response that says,
bash cd /cgi-bin/ No such file or directory
How do I move over to the cgi-bin?
Hmmm...When I issue a dir command, I see that I am in a different directory than expected.
More general, how do I navigate to a directory under cgi-bin and how do I navigate to a directory under www?
Thank you.
Regards,
Kevin
cd /big/dom/xdomain/cgi-bin/directory
cd /big/dom/xdomain/www/directory
Where xdomain is replaced by your actual xdomain and directory is replaced with the actual directory name or just left off to get into the top level of each of those two directories
-Bob
Stecyk
12-20-2007, 04:54 PM
Perfect Bob, thank you. This entire thread is very helpful to me.
Given that SSH Telnet is somewhat challenging to work with, is there another approach that you would recommend? It is challenging in that if you make a mistake while typing a long command, you need to start all over again.
Regards,
Kevin
--------
Key words in case I need to find this again:
stecyk, tar.gz, zip, directory, directories, zipping, tar, cgi, cgi-bin, ssh, ssh telnet
It's bookmarked, but in case I am using a different computer or browser.
Kevin
12-20-2007, 04:55 PM
You can use the up arrow to return to the previous command and then the other arrows to modify it.
You can also type in a partial file or directory name then hit tab to let the system complete it for you.
Stecyk
12-20-2007, 05:07 PM
Great thank you Kevin!
Arthur
12-21-2007, 04:11 AM
Alternative way to navigate to your cgi-bin directory;
cd ~/../cgi-bin
(home directory (~), down one, then into cgi-bin)
go to www directory;
cd ~/../www
go to home directory
cd
when you're in your home directory, go to /big/dom/xyourdomain;
cd ..
-Arthur
Stecyk
12-21-2007, 12:42 PM
Arthur,
Fantastic. That's helps the navigation process.
Knowing the helpful information in this thread has already saved me loads of time.
You mentioned that cd .. goes down a level. Is there a cd command to go up one level?
Best regards,
Kevin
sheila
12-21-2007, 11:20 PM
Actually
cd ..
goes up a level.
The current directory is
.
The parent directory is
..
Stecyk
12-22-2007, 12:09 AM
Thank you very much Sheila! :yeah:
Tom E.
12-22-2007, 08:54 AM
I you use a command frequently, you can save time by defining an alias for it:alias www='cd ~/../www'All you have to do now is type "www" to change to your www directory.
I knew this sounded familiar ... here's a recent post about some handy aliases and how to set them up (http://www.aota.net/forums/showthread.php?postid=159861#post159861)
Stecyk
12-22-2007, 12:45 PM
Hi Tom,
That does indeed look helpful and handy.
1) # .bashrc
2)
3) # User specific aliases and functions
4) alias ..='cd ..'
5) alias ...='cd ../..'
6) alias www='cd ~/../www'
7) alias ssl='cd ~/../www/Secure_Server'
8) alias la='ls -a'
9) alias ll='ls -la'
10) alias ms='mysql -uYOURMYSQLUSERNAME -p -hmysql.YOURDOMAIN.com YOURDATABASE'
11) alias md='mysqldump -q -uYOURMYSQLUSERNAME -p -hmysql.YOURDOMAIN.com YOURDATABASE > /big/dom/YOURDIRECTORY/backups/db_backup_`date +%Y-%m-%d`.sql'
12) # Source global definitions
13) if [ -f /etc/bashrc ]; then
14) . /etc/bashrc
15) fi
I've added line numbers above. While I understand most, can you put the commands into English for myself and others? You've created a very handy reference.
1) name of file, which is a text file that is stored in the home directory. (Use Tom's original (http://www.aota.net/forums/showthread.php?postid=159861#post159861), not my version with the line numbers.)
3) comment
4) up a level
5) ?
6) goes to www
7) ?
8) ?
9) ?
10) appears as though you are setting up the database to import a file?
11) exporting from a database
12) comment
13) some sort of an "if" statement?
14) ?
15) closing an "if" statement?
Best regards,
Kevin
Kevin
12-22-2007, 12:56 PM
5) causes '...' to go up 2 directories
7) ssl to cd into the secure server directory (if you have one)
8) causes 'la' to run 'ls -a' which is a directory listing with all hidden files shown
9) causes 'll' to run 'ls -la' which is a directory listing with all info and all hidden files shown
13-15) reads in the commands that are stored in /etc/bashrc which is the server level bash config file. That way you have the aliases and other settings that FutureQuest has set for all users. The if/fi is so that if the file doesn't exist you will not see an error every time you login.
Tom E.
12-22-2007, 01:12 PM
5, 7-9, 13-15) Thanks Kevin!
10) ms = run the mysql command line interface for the specified database and prompt for the password
11) md = do a mysqldump of your database (after prompting for password) and use the current date in the file name
Kevin
12-22-2007, 01:44 PM
btw, I prefer to customize the mysql command through a ~/.my.cnf file instead of an alias. The format is:
[client]
host=mysql.yourdomain.tld
user=yourmysqlusername
password=yourmysqlpassword
That way you can just run 'mysql databasename' to use the command line client. The mysqldump command will also use that information.
Since your mysql password is already stored in whatever scripts run your web site there is no reduction in security putting the password in this file.
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.