I am creating a bash script that installed VSFTPD / FTP. After the installation some configuration is required in the "/etc/vsftpd/vsftpd.conf" file.

This includes making sure the following lines are set to this:


What would be the best approach for scripting a way for these edits to be made post installation?

  • I would go with sed Nov 24, 2014 at 16:04
  • Are those lines (with the same or different values) already in the default conf? That is, what are you changing from and to?
    – jasonwryan
    Nov 24, 2014 at 16:26
  • It can vary but that is the end result I need to get to. Nov 24, 2014 at 16:31
  • Note that not all versions of sed support sed -c, with gnu sed 4.2.2 I'm getting sed: invalid option -- 'c'. Also, if those keys are commented in the original file (or missing) the sed solution below will not give you the end result that you actually need. Nov 24, 2014 at 23:31

1 Answer 1


I would use sed it's really powerfull, this bash file would change the values:



  sed -c -i "s/\("anonymous_enable" *= *\).*/\1$anonymous_/" $path_to_conf
  sed -c -i "s/\("local_enable" *= *\).*/\1$local_/" $path_to_conf
  sed -c -i "s/\("chroot_local_user" *= *\).*/\1$chroot_/" $path_to_conf

You could use a loop to get this done, if you have to change a lot of variables, but with only three keys it's nicer like this (in my opinion).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .