Just a copy of a big dir when you wan't things like ownership and date etc etc to be untouched. Note: Updated with the ideas from "mpb".
It's the same like 'cp -p' if available. It's faster over networks than scp. If you have to copy gigs of data you could also use netcat and the tar -z option in conjunction -- on the receiving end do: # nc -l 7000 | tar -xzvpf - ...and on the sending end do: # tar -czf - * | nc otherhost 7000
Use tar command for a backup info with a date of creation Show Sample Output
creates a compressed tar archive of files in /path/foo and writes to a timestamped filename in /path.
tar directory and compress it with showing progress and Disk IO limits. Pipe Viewer can be used to view the progress of the task, Besides, he can limit the disk IO, especially useful for running Servers. Show Sample Output
This is a shortcut to tar up all files matching a wildcard. Tar doesn't have the --include (apparently).
tar doesn't support wildcard for unpacking (so you can't use tar -xf *.tar) and it's shorter and simpler than for i in *.tar;do tar -xf $i;done (or even 'for i in *.tar;tar -xf $i' in case of zsh) -i says tar not to stop after first file (EOF)
Same, but count of signs is little less :) .
If you want to decompress the files from an archive to current directory by stripping all directory paths, use --transform option to strip path information. Unfortunately, --strip-components option is good if the target files have same and constant depth of folders. The idea was taken from http://www.unix.com/solaris/145941-how-extract-files-tar-file-without-creating-directories.html Show Sample Output
A quick find command to identify all TAR files in a given path, extract a list of files contained within the tar, then search for a given string in the filelist. Returns to the user as a list of TAR files found (enclosed in []) followed by any matching files that exist in that archive. TAR can easily be swapped for JAR if required. Show Sample Output
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. Show Sample Output
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.
This works more reliable for me ("cut -c 8-" had one more space, so it did not work)
Finally, we can make the file "unchangeable" sudo chattr +i
Really useful when out of space in your current machine.
You can ran this also with cat for example:
tar zcvf - /folder/ | ssh root@192.168.0.1 "cat > /dest/folder/file.tar.gz"
Or even run other command's:
tcpdump | ssh root@10.0.0.1 "cat > /tmp/tcpdump.log"
Remove the "echo" to actually archive.
Many similar commands are found on commandlinefu but I end up needing this very specific one from time to time.
To extract any of them, use the standard tar.bz2 extract command:
tar xvjf folder1.tar.bz2
Show Sample Output
This command is for UNIX OSes that have plain vanilla System V UNIX commands instead of their more functional GNU counterparts, such as IBM AIX.
tars the current directory (and its children) in an archive of the same name (plus ".tar" :)) in the parent directory without the absolute path, so that when the archive is extracted, only the current directory name is created for the path. Assumes bash/zsh.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: