Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The first hyphen means output goes to stdout. The output is then piped to the second command where tar reads it from stdin. Actually the command can be shortened since "-" is the default:
tar = Stands for "tape archive" This is a legacy-name for when mag tape was king of backup.
c = 'create' (as opposed to extract)
v = 'verbose'. You can miss this out but it won't tell you which files are being worked on.
f = means specify a file to use as the device. Remember, everything in linux is a 'file' so
the beauty of linux (and unix) is that what works with a specical file like a tape device
will also work for any file - including an entry in a block-special filesystem or a the special
file stdout which is used next in this case.
- = 'stdout' This is the default output for all programs. It is usually - but not allways the
screen. Typically, stdout is 'piped' to another program for further processing.
. = 'current directory'. Therefore this whole comman is context dependent. You must have done a cd
into the desired directory before executing it.
| = 'redirect stdout' to 'stdin' of the following program.
() = create a new shell. Thus the stdin of the tar command is fed to a new shell. Inside this shell,
you can do a whole load of commands.
cd /root/ = 'change directory (inside this subshell only) to a new place - this is the destination
of the backup)
; = 'end of this line - what follows is a new command as if you pressed RETURN first.'
tar xvf - = 'rn tar again' but this time x means eXtract. 'f' has the same meansing, but this time '-'
means stdin'
I like setting up no password handshaking between servers, such as for a migration, then run the following from any directory. Most of the time I will set up the script to run after hours in cron for each directory I want to move:
tar cf - . | ssh <servername> "cd /path-to-dir; tar xf -"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.