commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Finally, we can make the file "unchangeable"
sudo chattr +i
If archive has leading directory level same as archive name and you want to strip it, this command is for you.
The command extracting the tar contents into particular directory ...
At client side:
tar c myfile | nc localhost 7000 ##Send file myfile to server
tar c mydir | nc localhost 7000 ## Send directory mydir to server
This is how I've done it in the past
Simple tar pipe to be used to copy directories while including hidden files and maintaining file permissions
This command will :
-Archive all *.dmp files individually (one file per archive) from current directory .
-Delete original file after has been compressed.
This works more reliable for me ("cut -c 8-" had one more space, so it did not work)
The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.
Backup your entire system on a tar ball file format.
the -a flag causes tar to automatically pick the right compressor to filter the archive through, based on the file extension. e.g.
"tar -xaf archive.tar.xz" is equivalent to "tar -xJf archive.tar.xz"
"tar -xaf archive.tar.gz" is equivalent to "tar -xzf archive.tar.gz"
No need to remember -z is gzip, -j is bzip2, -Z is .Z, -J is xz, and so on :)
Simple Compressed Backup of the /etc
Sometimes you might need to have two copies of data that is in tar. You might unpack, and then copy, but if IO is slow, you might lower it by automatically writing it twice (or more times)
The result of this command is a tar with all files that have been modified/added since revision 1792 until HEAD. This command is super useful for incremental releases.
Useful when you have multiple files or binary files that you need to transfer to a different host and scp or the like is unavailable.
To unpack on the destination host copy paste output using the opposite order:
openssl enc -d -base64 | gunzip | tar -x
Terminate openssl input using ^d
Note: gzip is outside of tar because using -z in tar produces lots of extra padding.
Create a encrypted tar.gz file from a directory on the fly. The encryption is done by GPG with a public key. The resulting filename is tagged with the date of creation. Very usefull for encrypted snapshots of folders.