Share your knowledge at the LQ Wiki.
Go Back > Blogs > ak kumar
User Name


Rate this Entry

linux tips

Posted 07-20-2010 at 12:52 PM by ak kumar

TIP 1:

cpio works like tar, only better.

STEP 1 (Create two directories with data ../dir1 an ../dir2)

mkdir -p ../dir1
mkdir -p ../dir2
cp /etc/*.conf ../dir1/.
cp /etc/*.cnf ../dir2/.

Which will backup all your cnf and conf files.

STEP 2 (Piping the files to tar)

cpio works like tar but can take input
from the "find" command.

$ find ../dir1/ | cpio -o --format=tar > test.tar
$ find ../dir1/ | cpio -o -H tar > test2.tar

Same command without the ">"

$ find ../dir1/ | cpio -o --format=tar -F test.tar
$ find ../dir1/ | cpio -o -H tar -F test2.tar

Using append

$ find ../dir1/ | cpio -o --format=tar -F test.tar
$ find ../dir2/ | cpio -o --format=tar --append -F test.tar

STEP 3 (List contents of the tar file)

$ cpio -it < test.tar
$ cpio -it -F test.tar

STEP 4 (Extract the contents)

$ cpio -i -F test.tar

TIP 1:

Working with tar. The basics with encryption.

STEP 1 (Using the tar command on the directory /stuff)

Suppose you have a directory /stuff
To tar everything in stuff to create a ".tar" file.

$ tar -cvf stuff.tar stuff

Which will create "stuff.tar".

STEP 2 (Using the tar command to create a ".tar.gz" of /stuff)

$ tar -czf stuff.tar.gz stuff

STEP 3 (List the files in the archive)

$ tar -tzf stuff.tar.gz
$ tar -tf stuff.tar

STEP 4 (A way to list specific files)

Note, pipe the results to a file and edit

$ tar -tzf stuff.tar.gz > mout

Then, edit mout to only include the files you want

$ tar -T mout -xzf stuff.tar.gz

The above command will only get the files in mout.
Of couse, if you want them all

$ tar -xzf stuff.tar.gz


$ tar -zcvf - stuff|openssl des3 -salt -k secretpassword | dd of=stuff.des3

This will create stuff.des3...don't forget the password you
put in place of secretpassword. This can be done interactively as

$ dd if=stuff.des3 |openssl des3 -d -k secretpassword|tar zxf -

NOTE: above there is a "-" at the end... this will
extract everything.
Posted in Uncategorized
Views 664 Comments 1
« Prev     Main     Next »
Total Comments 1


  1. Old Comment
    You could have used code tags to make your post readable
    Posted 07-21-2010 at 02:32 AM by TheIndependentAquarius TheIndependentAquarius is offline


All times are GMT -5. The time now is 12:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration