The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 02:10:30 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: how to tarball a directory in unix  (Read 3457 times)
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« on: April 28, 2009, 06:28:15 PM »

Okay ive been working with:

Code:
tar -cvzf bakup.2009.4.28.tgz [dirnameoneleveldowniwantbackedup]



is this a 'tarball' ... just wanted to know from yall's
experience how to tarball a unix directory the best way
and if i have the correct directives cvzf

« Last Edit: April 28, 2009, 06:30:06 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: April 28, 2009, 06:49:46 PM »

you're just fine. I have a habit of being *in* the dir that I want to tarball, and put the ball one up. For example:

tar -czvf ../all.tar.gz *

... this is because I often want the 'ball to just have the files in the root, not in a subdir when I spit it back out. Could be that I have my head up my butt though.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #2 on: April 28, 2009, 06:56:46 PM »

so the how does ../  differ from ./ ?
Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: April 28, 2009, 07:02:49 PM »

../ means "one above where I currently am" ./ means "right here in this damn directory."
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #4 on: April 29, 2009, 03:52:13 AM »

So what does the ./ mean in i guess when you
run a file from somewhere else, like ./usr/games/fortune

Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: April 29, 2009, 10:52:33 AM »

./usr/games/fortune

is the same as
usr/games/fortune

... it means "from right here." but not the same as

/usr/games/fortune

which means from the root and

../usr/games/fortune

which would mean, go UP one directory, then down into the usr/games and run fortune.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #6 on: April 29, 2009, 12:50:46 PM »

to explain anotherway.

. = here
.. = parent
/ =directory

so ./ = here-directory, which is redundant and blabbery. the . alone is the important part really. same thing with ..

if you type>>   cd .
you wont go anywhere.
type>> cd ..
and you go up 1 dir
type>> cd /
and you end up at root
type>> cd ./
you just typed 1 more char than you needed to.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: April 29, 2009, 01:03:29 PM »

type>> cd ./
you just typed 1 more char than you needed to.

Actually, 5: c d . / [enter] ... because that command does exactly... nothing Wink
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #8 on: April 29, 2009, 02:16:59 PM »

cd -

goes to the directory in which you previously were, regardless of your current location and

cd ~

goes to your home directory, though if you type cd ~ and then hit tab, it will spell out your home directory's full path.

./ may be redundant, but the superstitious UNIX sysadmin in me always does it to execute shell scripts anyway. Don't ask me why.
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #9 on: April 29, 2009, 02:47:45 PM »

Well, isn't the local directory after the defined constants in the shell? So if you

root# ./myscript.sh

and

root# myscript.sh

... you're actually in an (unlikely but possible) situation where there is a script in the search path named myscript.sh that would be found and executed before the one in your current directory... I think anyway. I always do ./myscript as well, because it's really clear to the shell what I want.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #10 on: April 29, 2009, 02:53:19 PM »

Well yeah if you have like a myscript.sh in your /bin or /usr/bin

That's probably why I do it, I had just forgotten the reason long ago.
Logged

hai
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #11 on: April 30, 2009, 03:27:19 AM »

Well yeah if you have like a myscript.sh in your /bin or /usr/bin
That's probably why I do it, I had just forgotten the reason long ago.

Not sure if it is so much in vogue anymore.
Big thing in ancient days before www was to make a script of some common name like lets say "ls"
Then place it in some directory like "/tmp"
then when administrator logged in, if he did not have his path set correctly, then it would execute your ls (which would call the real one) and u could steal root priviledges.

Big thing in those days was to make directories called like ".../.../..." and the hide warez in them on FTP sites
Logged
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #12 on: May 03, 2009, 07:29:02 PM »

Here is a one-liner:

Code:
tar -cvzf /path_name_of_tarball/bakup.2009.4.28.tgz -C /path_name_of_dir .

With "-C" you cd into the directory. The "." at the end is important. It means that all files from that directory
will be packed into the tarball.
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!