Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Hello, My question is for send mail server 12.5 we enabled forwarding on all users now How can I remove the forwarding on 3000 users at once. Below is the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    7

    Post How can we remove Email Forwarding from 3000 users


    Hello,

    My question is for send mail server 12.5
    we enabled forwarding on all users now How can I remove the forwarding on 3000 users at once.
    Below is the method which I have adopted right now to remove the forwarding from all users…
    sudo /bin/rm /home/username/.forward
    this is very hectic for me to delete one by one. Is there any script which we have to use so that my activity become more easier..?

    looking forward for your response and kind assistance

    Asim Faraz
    +92-333-3122419

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Code:
    sudo /bin/rm /home/*/.forward
    I would STRONGLY recommend to do a full backup before doing this.

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    Hmm, he said 3000 users, not all users.
    If there are more, then the backup is needed indeed :P

    Is there a list of these 3000 users?
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Aug 2010
    Posts
    7

    Post Email Forwarding removal

    yes indeed!

    you are right we do have more than 3000 users.
    Look the scenerio is like we have a list of users in notepad or excel file now i have to delete these specific users which are only in that file...
    rst of them should not be deleted in any case.
    thanks

  5. #5
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    oki,
    assuming
    - you have a list of usernames
    - the list is one name per line, ideally ending in unix linefeed convention. aka no windows style CR/LF
    - the username are sane (no special chars, spaces, etc)
    - the usernames are equal to the homedirectory names
    - the homedirectories are under /home
    - you are root

    then something like this comes to mind:
    Code:
    for USERNAME in `cat userlist`; do ls -la /home/$USERNAME/.forward ; done
    Look for erros, look for consistency, look for correct number ( | wc -l).
    If you are happy with what you see, replace the ls -la with a rm -f.
    You must always face the curtain with a bow.

  6. #6
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    You can simply use find command

    to find

    Code:
    find /home/ -name '.forward' -print
    and
    Code:
     find /home/ -name '.forward' -delete
    to delete them.

    And yes, it would be better to perform backup before doing this.

  7. #7
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,392
    The find will delete all.
    Jamikhan needs to delete only 3000
    You must always face the curtain with a bow.

  8. #8
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    Ohh, yes, thank you.
    I just missed that message.

  9. #9
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Quote Originally Posted by Irithori View Post
    Code:
    for USERNAME in `cat userlist`; do ls -la /home/$USERNAME/.forward ; done
    As irithori said, this will NOT work with usernames like "John Smith" as that will try to remove a user "John" and a user "Smith". Just wanted to point that out.

    You could do also the inverse:

    Code:
    for user in /home/*; do
    # check if $user should be deleted in some or the other way
    if [ fgrep SOME_ARGS ]; then
       rm -rf $user;
    fi
    done

  10. #10
    Just Joined!
    Join Date
    Aug 2010
    Posts
    7
    i will check all these options
    thanks in advance..
    but i need to be sure that it will not harm my user IDs..it will just remove email forwarding from them....?

    Jami

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •