List default arguments of a linux command

Posted on

Problem :

I wanted to check what are default arguments for rsync.

Tried searching through man pages but did not found that.

Is there a way to get default arguments for linux command?

Solution :

To make sure and cover all the bases I’m going to answer three different interpretations of your question.

1. rsync command by itself

To start, if you ran the rsync command by itself like this:

linux-okrz:~> rsync

The command has been designed to default to the same behavior as adding the --help flag.

2. default behavior when using rsync to copy

Next, if you were to run the command like this:

linux-okrz:~> rsync one/file two/

It would simply follow its default protocol. To clarify, it’s not running any arguments. Arguments are for the purpose of changing the default behavior. So some examples of its default behavior would be:

  • Non-verbose action – rsync will work silently.
  • “quick check” algorithm that only looks for files that have changed in size or in last-modified time.
  • Non-recursive. In other words, it won’t sync into directories, you’d have to specify the files. (globbing would still work on files in the same directory e.g. “dir/*”)
  • Existing files in the destination directory retain their permissions
  • New files pass on their permissions which can then be changed by the destinations directory’s default ACL or umask.
  • user and group ownership will change to the destination user invoked if rsync is occurring across hosts and the users are not the same.
  • Will accept remote hosts in source or destination field

I hope it makes sense that these are not default arguments but rather its default behavior. You would then use arguments to change that default behavior as it suits your needs. The above was not a complete list by any means, but rather some of the default behaviors I saw listed in the man page.

3. command to use rsync with arguments by default

Lastly, if you wanted a command that ran rsync with specific arguments by default you could use an alias to accomplish that task. Example below:

colin@linux-okrz:~> alias myrsync='rsync -zahP'
colin@linux-okrz:~> myrsync one/ two/
sending incremental file list
./
file
          0 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/2)

I think in your case you’re probably asking about my second interpretation regarding the command’s default behavior, but I figured I’d include these three for anyone else that might stumble upon the same question with one of the other meanings in mind.

Please use following command. You can search “example” in man command.

man rsync

You can also refer following URL. You will get more information for rsync command.

http://www.computerhope.com/unix/rsync.htm

Leave a Reply

Your email address will not be published. Required fields are marked *