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:
is preserving creation time, modification time, permission, the directory structure, etc.
gpg -o- foo.tgz.gpg | tar zxvf -
Very similar as doing "wget http://example.com/mytarball|tar xzv", this one involves the "tee" command between both, which will simultaneously write the tarball and copy it to stdout. So this command will locally save the tarball and extract it - both at the same time while it downloads.
Create an AES256 encrypted and compressed tar archive.
User is prompted to enter the password.
openssl enc -d -aes256 -in <file> | tar --extract --file - --gzip
Tar's up $DIR locally (w/bzip2) and sends remotely to $HOST:$PORT where netcat listens (using openbsd netcat). Start up receiving side command first, then execute this.
Note: the tar archive must not exist in order to create it. If exists it will only be updated and no already existent files in present search will still remain in the tar archive. The update option has to be used instead of create because the command tar may be executed more than once depending on the number of arguments that find throws. You can see maximum number of arguments with 'getconf ARG_MAX'
If you want to exclude only one file or directory you should use as --exclude=file_or_directory
You can ran this also with cat for example:
tar zcvf - /folder/ | ssh firstname.lastname@example.org "cat > /dest/folder/file.tar.gz"
Or even run other command's:
tcpdump | ssh email@example.com "cat > /tmp/tcpdump.log"
This will make a backup of all hidden files and folders in the home folder.
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