Install standard
desktop GNOME
Move or migrate user accounts to from old Linux server a
new Linux
www.nixcraft.com
How do I Move or migrate user
accounts to from old Linux server a new Cent OS Linux server including mails?
This new system a fresh installation.
A. You can migrate users from old
Linux server to new Linux sever with standard commands such as tar, awk, scp
and others. This is also useful if you are using old Linux distribution such as
Redhat 9 or Debian 2.x.
Following files/dirs are required for
traditional Linux user management:
* /etc/passwd - contains various pieces of information for each user account
* /etc/passwd - contains various pieces of information for each user account
* /etc/shadow -
contains the encrypted password information for user’s accounts and optional
the password aging information.
* /etc/group -
defines the groups to which users belong
* /etc/gshadow -
group shadow file (contains the encrypted password for group)
* /var/spool/mail -
Generally user emails are stored here.
* /home -
All Users data is stored here.
You need to backup all of the above files
and directories from old server to new Linux server.
Commands to type on
old Linux system
First create a tar ball of old uses (old
Linux system). Create a directory:
# mkdir /root/move/
Setup UID filter limit:
# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
Copy /etc/gshadow (rarely used):
# cp /etc/gshadow /root/move/gshadow.mig
Make a backup of /home and /var/spool/mail dirs:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail
# mkdir /root/move/
Setup UID filter limit:
# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
Copy /etc/gshadow (rarely used):
# cp /etc/gshadow /root/move/gshadow.mig
Make a backup of /home and /var/spool/mail dirs:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail
Where,
·
Users that are added to the
Linux system always start with UID and GID values of as specified by Linux
distribution or set by admin. Limits according to different Linux distro:
·
RHEL/CentOS/Fedora
Core : Default is 500 and upper limit is
65534 (/etc/libuser.conf).
·
Debian and
Ubuntu Linux : Default is 1000 and upper
limit is 29999 (/etc/adduser.conf).
·
You should never ever create
any new system user accounts on the newly installed Cent OS Linux. So above awk
command filter out UID according to Linux distro.
·
export
UGIDLIMIT=500 - setup UID start limit for
normal user account. Set this value as per your Linux distro.
·
awk -v
LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd >
/root/move/passwd.mig - You need to pass
UGIDLIMIT variable to awk using -v option (it assigns value of shell variable
UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator
to : . Finally awk read each line from /etc/passwd, filter out system accounts
and generates new file /root/move/passwd.mig. Same logic is applies to rest of
awk command.
·
tar -zcvpf
/root/move/home.tar.gz /home - Make a
backup of users /home dir
· tar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir
Use scp or usb pen or tape to copy
/root/move to a new Linux system.
# scp -r /root/move/* user@new.linuxserver.com:/path/to/location
# scp -r /root/move/* user@new.linuxserver.com:/path/to/location
Commands to type on
new Linux system
First, make a backup of current users and
passwords:
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak
Now restore passwd and other files in /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak
Now restore passwd and other files in /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow
Please note that you must use >> (append)
and not > (create)
shell redirection.
Now copy and extract home.tar.gz to new
server /home
# cd /
# tar -zxvf /path/to/location/home.tar.gz
# cd /
# tar -zxvf /path/to/location/home.tar.gz
Now copy and extract mail.tar.gz (Mails)
to new server /var/spool/mail
# cd /
# tar -zxvf /path/to/location/mail.tar.gz
# cd /
# tar -zxvf /path/to/location/mail.tar.gz
Now reboot system; when the Linux comes
back, your user accounts will work as they did before on old system:
# reboot
# reboot
Please note that if you are new to Linux
perform above commands in a sandbox environment. Above technique can be used to
UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of
changes but overall the concept remains the same.
Further readings
· Read man pages of awk, passwd(5), shadow(5), group(5), tar command
Tested on . CentOS, Fedora, Redhat
Command Tukar ownership = chown pecal:mail
pecal
Pastikan httpd service starts
automatically, when linux comes us (add httpd service):
#
chkconfig --add httpd
Configurasi tambahan.
Setting
/etc/mail/sendmail.cf
# SMTP
daemon options
O
DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
O
DaemonPortOptions=Port=smtp,Addr=192.168.0.206, Name=MTA
[root@pulasan
root]# cat /etc/mail/access
localhost RELAY
127.0.0.1 RELAY
svcbagus.com OK
192.168.0.206 RELAY
[root@pulasan
root]# cat /etc/mail/local-host-names
localhost
mypartner.biz
svcbagus.com
[root@pulasan
root]# cat /etc/aliases
mailer-daemon: postmaster
postmaster: root
bin: root
daemon: root
adm: root
lp: root
sync: root
shutdown: root
halt: root
mail: root
news: root
uucp: root
operator: root
games: root
gopher: root
ftp: root
nobody: root
apache: root
named: root
xfs: root
gdm: root
mailnull: root
postgres: root
squid: root
rpcuser: root
rpc: root
ingres: root
system: root
toor: root
manager: root
dumper: root
abuse: root
newsadm: news
newsadmin: news
usenet: news
ftpadm: ftp
ftpadmin: ftp
ftp-adm: ftp
ftp-admin: ftp
ab: bkr
zi: tiang@yahoo.com
it_ipk: diah,jang_jang@yahoo.com
sae: sae@m3p.edu.my,sae3p@yahoo.com
hafiz: apis,lan@yahoo.com
hf: an,hf@tm.net.my
nn: nnm,nnm@tm.net.my
eddy:
ad,eddi@yahoo.com,ed@eds.com.my
decode: root
audit:
ha,fairies@yahoo.com,has@a.gov.my,izz@a.gov.my,faro@a.gov.my,az@a.gov.my,sur@a.gov.my,norshikin@a.gov.my,da@a.gov.my
Setting SMTP Melalui Relay
Server.
[root@posmen ~]# vi
/etc/mail/sendmail.cf
Masukkan
IP Server relay (cth IMSS) pada line berikut untuk scan email keluar :
#
"Smart" relay host (may be null)
DS[192.168.0.205]
[root@posmen ~]# service sendmail
restart
Stopping Spam with
Sendmail
Email spam can be defined as unnecessary and
unwanted email received by a user that probably does not know the sender and
never requested the communication. It is a very disruptive, costly, and
widespread abuse of Internet communication standards. Sendmail has made it (relatively) easy to block new spamming techniques being employed to send junk email using your system. It even blocks many of the more usual spamming methods by default. You would need to consciously activate them by changing your /etc/mail/sendmail.mc file in a particular way to make your system susceptible.
For example, forwarding of SMTP messages, also referred to as SMTP relaying, has been disabled by default since Sendmail version 8.9. Before this change occurred, Sendmail would direct your mail host (x.org) to accept messages from one party (y.com) and send them to a different party (z.net). Now, however, you have to specifically tell Sendmail to permit a domain to relay mail through your domain. Simply edit the /etc/mail/relay-domains file and restart Sendmail by typing the service sendmail restart command as root to activate the changes.
However, many times, your users may be bombarded with spam from other servers throughout the Internet that are beyond your control. In these instances, you can use Sendmail's access control features available through the /etc/mail/access file. As root, add the domains that you would like to block or specifically allow access, such as:
badspammer.com 550 Go away and don't spam us anymore tux.badspammer.com OK
10.0 RELAY |
Because /etc/mail/access is a database, you need to use makemap to activate your changes by recreating the database map. This is easily done by running the makemap hash /etc/mail/access < /etc/mail/access command as root.
This example shows that any email sent from badspammer.com would be blocked with a 550 RFC-821 compliant error code and message back to the spammer, except for email sent from the tux.badspammer.com sub-domain, which would be accepted. The last line shows that any email sent from the 10.0.*.* network can be relayed through your mail server.
As you might expect, this example only scratches the surface of what Sendmail can do in terms of allowing or blocking access. See the /usr/share/doc/sendmail/README.cf for more detailed information and examples.
Membaiki “yum update” yang
gagal berfungsi.
Error
Messsage :
---> Package
perl-Compress-Raw-Bzip2.i386 0:2.021-1.el5.rf set to be updated
---> Package perl-Compress-Raw-Zlib.i386 0:2.021-1.el5.rf set to be updated
--> Processing Dependency: perl-Compress-Zlib for package:
solarspeed-openwebmail
--> Finished Dependency Resolution
solarspeed-openwebmail-2.52-SOL4AV.i386 from installed has depsolving
problems
--> Missing Dependency: perl-Compress-Zlib is needed by package
solarspeed-openwebmail-2.52-SOL4AV.i386 (installed)
Error: Missing Dependency: perl-Compress-Zlib is needed by package
solarspeed-openwebmail-2.52-SOL4AV.i386 (installed)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
---> Package perl-Compress-Raw-Zlib.i386 0:2.021-1.el5.rf set to be updated
--> Processing Dependency: perl-Compress-Zlib for package:
solarspeed-openwebmail
--> Finished Dependency Resolution
solarspeed-openwebmail-2.52-SOL4AV.i386 from installed has depsolving
problems
--> Missing Dependency: perl-Compress-Zlib is needed by package
solarspeed-openwebmail-2.52-SOL4AV.i386 (installed)
Error: Missing Dependency: perl-Compress-Zlib is needed by package
solarspeed-openwebmail-2.52-SOL4AV.i386 (installed)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
#cuba install guna “yum install
perl-Compress-Zlib”
#Jika gagal cari fail RPM
perl-Compress-Zlib dan install
#gunakan rpm –Uvh –nodeps ***** untuk
upgrade pakej yang diperlukan perl-Compress-Zlib jika perlu.