Install samba
# yum install samba
Configure samba
# vi /etc/samba/smb.conf
[global]
workgroup = Linux
netbios name = CentOS_Srv
;name resolve order = bcast host lmhosts wins
server string = CentOS Samba v.%v
security = user
passdb backend = tdbsam
[www]
comment = Public WWW
path = /var/www
create mask = 0660
directory mask = 0771
writable = yes
valid users = user1 user2
Add User for samba
# useradd user1 -d /mnt/data/home/user1
# chown user1:user1 /mnt/data/home/user1
# passwd user1
# Enter your password
# smbpasswd -a user1
# /etc/init.d/smb restart
Configure Firewall for samba
Change IPTables
# vi /etc/sysconfig/iptables
#Includes the following before the REJECT line:
-A INPUT -p udp -m udp --dport 137 -j ACCEPT
-A INPUT -p udp -m udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
# service iptables restart
Run samba when OS starting
# chkconfig --levels 235 smb on
Client test
net use Z: \\192.168.6.2\www /user:user1
http://wiki.centos.org/HowTos/SetUpSamba
Thursday, September 15, 2011
Wednesday, September 14, 2011
Config Network Adapter for CentOS Linux
vi /etc/sysconfig/network-scripts/ifcfg-eth0
#####################################
# for static ip
#DEVICE="eth0"
#BOOTPROTO="static"
#HWADDR="00:30:48:56:A6:2E"
#IPADDR="10.1.1.5"
#NETMASK="255.255.255.192"
#ONBOOT="yes"
#####################################
# for dhcp ip
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
vi /etc/sysconfig/network
NETWORKING=yes
# for static ip
#HOSTNAME=host1.mysite.com
#GATEWAY=10.1.1.1
ifdown eth0
ifup eth0
or /etc/init.d/network restart
Monday, September 5, 2011
Using comparison operators in a unsafe way
// Using operators in a unsafe way
// declare a variable to null
string s = null;
// in this example below will be fine because the right side won't be invoke when left side is true.
if(s == null || s.Length == 0)
// for 'and' operator comparison
// if left side get true the right side will invoke
// if left side get false the right side will never invoke
// this example below will be throw a exception while right side is execute.
if(s == null && s.Length == 0)
// declare functions
func1(param){return param;}
func2(param){return param;}
// which function being call
if(func1(true) && func2(true)) func1 func2
if(func1(false) && func2(true)) func1
if(func1(true) || func2(true)) func1
if(func1(false) || func2(true)) func1 func2
// the concept above can also apply to C/C++, java and javascript ....
// declare a variable to null
string s = null;
// for the 'or' operator comparison
// if left side get true the right side will never be invoke
// if left side get false, the right side will come.// if left side get true the right side will never be invoke
// in this example below will be fine because the right side won't be invoke when left side is true.
if(s == null || s.Length == 0)
// for 'and' operator comparison
// if left side get true the right side will invoke
// if left side get false the right side will never invoke
// this example below will be throw a exception while right side is execute.
if(s == null && s.Length == 0)
// declare functions
func1(param){return param;}
func2(param){return param;}
// which function being call
if(func1(true) && func2(true)) func1 func2
if(func1(false) && func2(true)) func1
if(func1(true) || func2(true)) func1
if(func1(false) || func2(true)) func1 func2
// the concept above can also apply to C/C++, java and javascript ....
Thursday, September 1, 2011
Change IP Address Using Netsh.exe Command
Netsh command
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
to change DNS
netsh int ip set dns "Local Area Connection" static 192.168.0.254 primary
The "Local Area Connection" is your Adapter name, It could also be "local area connection 2" or "wireless network connection"...
Syntax
netsh int ipv4 set address [name=]InterfaceName [source=]{dhcp | static [addr=]IPAddress[mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}
MSDN Document
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
to change the ipv4 address, subnet mask and getway
netsh int ipv4 set address "Local Area Connection" static 192.168.0.2 255.255.255.0 192.168.0.254 1netsh int ip set dns "Local Area Connection" static 192.168.0.254 primary
The "Local Area Connection" is your Adapter name, It could also be "local area connection 2" or "wireless network connection"...
Syntax
netsh int ipv4 set address [name=]InterfaceName [source=]{dhcp | static [addr=]IPAddress[mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}
MSDN Document
Tuesday, August 2, 2011
javascript undefined
var a;
var b = null;
var c = "";
// d is not declare
// var a;
typeof(a) return undefined
a == undefined return true
a === undefined return true
// var b = null;
typeof(b) return object
b == undefined return true
b === undefined return false
// var c = "";
typeof(c) return string
c == undefined return false
c === undefined return false
// d is no declare
typeof(d) return undefined
d == undefined throw exception
d === undefined throw exception
var b = null;
var c = "";
// d is not declare
// var a;
typeof(a) return undefined
a == undefined return true
a === undefined return true
// var b = null;
typeof(b) return object
b == undefined return true
b === undefined return false
// var c = "";
typeof(c) return string
c == undefined return false
c === undefined return false
// d is no declare
typeof(d) return undefined
d == undefined throw exception
d === undefined throw exception
Saturday, July 30, 2011
jQuery Examples
// ajax callback functions
success(data, textStatus, jqXHR)
A function to be called if the request succeeds.
error(jqXHR, textStatus, errorThrown)
A function to be called if the request fails.
complete(jqXHR, textStatus)
A function to be called when the request finishes
(after success and error callbacks are executed).
success(data, textStatus, jqXHR)
A function to be called if the request succeeds.
error(jqXHR, textStatus, errorThrown)
A function to be called if the request fails.
complete(jqXHR, textStatus)
A function to be called when the request finishes
(after success and error callbacks are executed).
Sunday, July 10, 2011
How to sned mail using gmail SMTP in c#
string subject = "gmail test ";
string message = "<h3>test sending gmail message content in HTML body</h3>";
MailMessage mailMsg = new MailMessage();
mailMsg.From = new System.Net.Mail.MailAddress("sender@gmail.com", "display name", System.Text.Encoding.UTF8);
mailMsg.To.Add(new MailAddress("reciver@gmail.com"));
mailMsg.SubjectEncoding = System.Text.Encoding.UTF8;
mailMsg.BodyEncoding = Encoding.UTF8;
//
mailMsg.Subject = subject;
mailMsg.Body = message;
mailMsg.IsBodyHtml = true;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
// user name and password to SMTP
client.Credentials = new System.Net.NetworkCredential("sender", "1234");
//gmail smtp port: 587
client.Port = 587;
client.Host = "smtp.gmail.com";
// gmail required SSL
client.EnableSsl = true;
client.Send(mailMsg);
string message = "<h3>test sending gmail message content in HTML body</h3>";
MailMessage mailMsg = new MailMessage();
mailMsg.From = new System.Net.Mail.MailAddress("sender@gmail.com", "display name", System.Text.Encoding.UTF8);
mailMsg.To.Add(new MailAddress("reciver@gmail.com"));
mailMsg.SubjectEncoding = System.Text.Encoding.UTF8;
mailMsg.BodyEncoding = Encoding.UTF8;
//
mailMsg.Subject = subject;
mailMsg.Body = message;
mailMsg.IsBodyHtml = true;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
// user name and password to SMTP
client.Credentials = new System.Net.NetworkCredential("sender", "1234");
//gmail smtp port: 587
client.Port = 587;
client.Host = "smtp.gmail.com";
// gmail required SSL
client.EnableSsl = true;
client.Send(mailMsg);
Subscribe to:
Posts (Atom)