Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I find myself needing to do this a few times daily and would love an easier way to do it.

The domain's email is handled by a third party, so the server needs to be told this by listing its domain in /etc/remotedomains.

I then remove the domain from localdomains:

pico /etc/localdomains

Search for "" (being careful not to land on "")

Remote "" from /etc/localdomains

Save and close

And place it within remotedomain:

pico /etc/remotedomains

Goto end of file and add ""

Save and close

A way to do this in one command would be great! :)

share|improve this question
not one command, but I always do vim -p /etc/localdomains /etc/remotedomains /domain dd gt p :xa. it cuts out the steps of opening closing and saving each file, though I'm pretty sure it could be more optimized. – xenoterracide Apr 20 '11 at 12:57

1 Answer 1

Is on its own line? You could use sed to get rid of it from localdomains (-i tells it to modify the file in-place, ^$ tells it to find an entire line matching, and d tells it to delete that line):

$ sed -i '/^$/d' /etc/localdomains

And then just append it to the end of remotedomains

echo "" >> /etc/remotedomains:

It's technically two commands, but I can't imagine that matters; you can run them on one line by separating them with ;

share|improve this answer
Indeed, is on its own line. Thanks for your suggestion :) – KJBweb Apr 20 '11 at 13:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.