New to linux and stuck in the tar
While in /home/user1, create a new tar file which contains the entire contents of your current directory. Name the new tar file: user1.tar Have the new tar file created in your current directory. When you create the tar file, create it so that the extraction path will be the current directory.
Performing tar -cvf user1.tar /home/user1 yielded results with the 1st immediate line stating tar: Removing leading '/' from memeber names followed by a massive amount of files. I am literally in my 2nd day of linux and not sure if I did this correctly with my command. The manual pages advised of multiple options but I attempted others like z and tvf and other options as well that failed giving errors: Cowardly refusing to create an empty archive |
Not sure I am following your issue. Are you saying you have created a tar file and it is empty?
|
Quote:
No. I am wondering if the command I performed is correct for the above instruction. A small brown box with the name I assigned showed up in the /home/user1 directory |
To see what is in the tar file you created, type:
Code:
tar -tf user1.tar | less Code:
man tar |
Quote:
As suggested "-t" is handy to see if you actually created anything useful. |
Quote:
Code:
tar cf user1.tar --exclude=user1.tar /home/user1/ An even more advanced feature --transform allows you to use a sed-like pattern to find and replace parts of the file name and path. Code:
tar -c --transform='s#home/user1/#./#' -f user1.tar --exclude=user1.tar /home/user1/; By the way you can compress the tarball with the z, j, or J options. Code:
tar zcf user1.tar.gz --exclude=user1.tar.gz /home/user1/ Code:
man tar |
An easier way than the --transform option is to just point tar at the current directory with a dot ( . )
Code:
cd /home/user1/ |
just a comment: you tried to put the result into tar, because user1.tar is inside /home/user1. That is obviously impossible. As a solution you can specify an exclusion or a much better way (at least for me) to avoid putting the final tar among the source files:
Code:
# for example: |
-C means change directory but you might need to create one first, as c only creates the file.
hence: tar -C /home/user1 -cf /some_dir/user1.tar . Fred. |
All times are GMT -5. The time now is 02:28 AM. |