Scala初探
函数文本的语法就是,括号里的命名参数列表,右箭头,然后是函数体。
2014年5月29日 Linux 0 Read more >
RHEL6.* Server Security Hardening
师父:
http://debugo.com/rhel6-server-security-hardening-script/
不认识:
profile:http://linux.chinaitlab.com/administer/820910.html
- disabling services
原则:只保留最小化安装(不包含可视化桌面的那个最小)的系统服务+用户安装的服务。其他服务一律干掉。(附非官方最小安装服务列表:http://jiaxl.blog.51cto.com/3064605/954239)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
chkconfig NetworkManager off chkconfig abrt-ccpp off chkconfig abrtd off chkconfig acpid off chkconfig atd off chkconfig bluetooth off chkconfig certmonger off chkconfig cpuspeed off chkconfig cgconfig off chkconfig cpuspeed off chkconfig ip6tables off chkconfig iptables off chkconfig libvirt-guests off chkconfig netconsole off chkconfig netfs off chkconfig nfslock off chkconfig postfix off chkconfig rpcgssd off chkconfig rpcidmapd off chkconfig rhnsd off chkconfig restorecond off chkconfig httpd off chkconfig vsftpd off |
- config ntp client
1 2 |
crontab -e 38 * * * * /usr/sbin/ntpdate 172.18.5.193 >>/root/ntpdate.log 2>&1 |
ps:
38 ****这个火星文是cron的定时接口。详情见链接:
http://www.poluoluo.com/jzxy/201009/94264.html
ps:crontab 的数字前加“*/10”,则为每隔这些时间就执行一次。
>和>>都是重定向输出
1> 指标准信息输出路径(也就是默认的输出方式)
2> 指错误信息输出路径
2>&1 指将标准信息输出路径指定为错误信息输出路径(也就是都输出在一起)
补充问题4<&0:
<和<<都是重定向输入
<0指标准输入路径
4<&0 指的是将文件描述符4指定为标准输入(实际可选4到9之间任意一个数字)
习惯上
标准输入(standard input)的文件描述符是 0
标准输出(standard output)是 1
标准错误(standard error)是 2
> 会覆盖已有的文件内容,而>>会附加到已有内容之后。
- global env variables
这是为了永久修改时区
1 2 3 4 5 |
vim /etc/profile # adding. export TZ=Asia/Shanghai export TMOUT=1800 comment if-clause of umask statement,and use 'umask 022' to replace it. |
ps:
在.profile中使用export语句,它的作用是将变量设置在SHELL环境中,以在任意路径下使用。
comment :說明而已!好像是设置了新建文件的权限。
- use pam(可插拔认证模块 Pluggable Authentication Modules)(还是有待学习)
控制能su到root的用户。
1 2 3 4 5 6 7 8 9 |
vim /etc/pam.d/su: auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. # auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid # only users in wheel group can su to root # you can modify user to wheel group like this: usermod -G10 username # then check: /etc/groups |
关于PAM的入门介绍:http://www.infoq.com/cn/articles/linux-pam-one
- password policy
1 2 3 4 5 6 7 8 9 |
(1)/etc/pam.d/passwd password include system-auth # include 表示在验证错误时,系统会跳出当前登入 # substack 表示在验证错误时,不会提示用户是在这一步错误了,直到所有验证步骤结束返回错误信息。 (2)修改文件/etc/pam.d/system-auth password requisite pam_cracklib.so minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 # minlen the length of password # lcredit ucredit dcredit ocredit表示小写、大写、数字、符合,设定值为为负数如-1表示至少1个,为正数如3表示最多3个 |
- create user without creating home
这个文件给出了对用户的一系列定义:
CREATE_HOME 是否为新建用户创建home目录
UMASK 用户新建文件的权限
1 2 3 |
/etc/login.defs CREATE_HOME no UMASK 027 |
- /etc/ssh/sshd_config
1 2 3 |
PermitRootLogin no MaxAuthTries 3 MaxSessions 5 |
- lock accounts
需要锁定的账号:adm、lp、sync、shutdown、halt、mail、news、uucp、operator、games、gopher、ftp、mailnull、
nfsnobody、nobody、pegasus、http
参考配置
(1)***用户:#userdel username;
(2)锁定用户:#passwd -l username
(3)解锁用户:#passwd -u username
(4)禁止用户交互登录:修改/etc/passwd文件,用户shell修改为/sbin/nologin
补充说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
passwd -l adm passwd -l lp passwd -l sync passwd -l shutdown passwd -l halt passwd -l mail passwd -l news passwd -l uucp passwd -l operator passwd -l games passwd -l gopher passwd -l ftp passwd -l mailnull passwd -l nfsnobody passwd -l nobody passwd -l pegasus passwd -l http |
- banner
这是发挥逗比技能的舞台 = =。系统登录时的banner 。。。也是只针对文本界面的。。。
1 2 |
#vim /etc/motd (message of the day) Authorized users only. All activities will be monitored and reported. |
ftp的配置文件/etc/vsftpd/vsftpd.conf
配置文件的全部技能:http://blog.csdn.net/yichi7758/article/details/4640014
ftp的banner:
1 2 |
#vim /etc/vsftpd/vsftpd.conf ftpd_banner="Authorized users only.All activity may be monitored and reported." |
ftp的匿名登录:
1 |
anonymous_enable=NO |
- disable Control-Alt-Delete
修改/etc/init/control-alt-delete.conf文件,注释如下内容:
1 |
exec /sbin/shutdown -r now "Control-Alt-Delete pressed" |
ps:这一行只是针对费图形界面进行配置。图形界面依然可以激活重启对话框。
- syslog
1 2 3 4 5 6 7 |
#vim /etc/rsyslog.conf *.err;kern.debug;daemon.notice; /var/log/messages(直接添加行) authpriv.* /var/log/secure(已经有了,确定一下) 重启syslog服务 /etc/init.d/rsyslog restart 修改log目录权限 #chmod 640 -R /var/log/ |
- selinux
关了
1 2 |
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 |
- iptables
也关了
1 2 |
service iptables stop service ip6tables stop |
CentOS网卡无法引导启动
原文链接:http://blog.sina.com.cn/s/blog_77126fa501018s3d.html
device eth0 does not seem to be present, delaying initialization
vmlite虚拟机启动出错,就把这个虚拟机删除掉重新建立,系统虚拟硬盘使用之前的,启动系统后不能上网,通过ifconfig查看网卡没启动,遂启动网卡服务,但是出错,就是:device eth0 does not seem to be present, delaying initialization,然后想到是不是ifcfg-eth0的配置文件里保存了以前的MAC地址,就把这一行删除掉在重启网卡,还是一样的错误,随后网上查了下资料,把/etc/udev/rules.d/70-persistent-net.rules 删除后重启机器就可以了,因为这个文件绑定了网卡和mac地址,所以换了网卡以后MAC地址变了,所以不能正常启动,也可以直接编辑这个配置文件把里面的网卡和mac地址修改乘对应的,不过这样多麻烦,直接删除重启,它会自动生成个。
1、
vi /etc/sysconfig/network-scripts/ifcfg-eth0
ifcfg-eth0的配置文件里保存了以前的MAC地址,就把这一行删除掉在重启网卡
2、
/etc/udev/rules.d/70-persistent-net.rules 删除后重启机器
因为这个文件绑定了网卡和mac地址,所以换了网卡以后MAC地址变了,所以不能正常启动,也可以直接编辑这个配置文件把里面的网卡和mac地址修改乘对应的,不过这样多麻烦,直接删除重启,它会自动生成个。
2014年5月27日 Linux 0 Read more >
CentOSrsyslog服务器与客户端搭建
参考链接:
官网:
http://www.rsyslog.com/storing-messages-from-a-remote-system-into-a-specific-file/
http://www.rsyslog.com/sending-messages-to-a-remote-syslog-server/
http://www.rsyslog.com/doc/v5-stable/tutorials/log_rotation_fix_size.html#conclusion
师父:
http://debugo.com/linux-note-rsyslog/
不认识:
http://blog.csdn.net/hxh129/article/details/8089474(有详细的配置文件翻译)
-
服务器端:
1.安装rsyslog
2.编辑/etc/rsyslog.conf: 打开UDP、TCP监听
3.创建/etc/rsyslog.d/remoteserver.conf(写在这个文件中的规则,放在/etc/rsyslog.conf中也可生效。分文件是便于管理)
可用规则1:为每一个主机(IP)配规则
1 |
:fromhost,isequal, “debugo02″ /var/log/remoteserver.log |
可用规则2:为一个IP Group配规则
1 2 3 4 5 6 7 8 9 |
$ModLoad imtcp $InputTCPServerRun 10514 # do this in FRONT of the local/regular rules if $fromhost-ip startswith '192.0.1.' then /var/log/network1.log & ~ if $fromhost-ip startswith '192.0.2.' then /var/log/network2.log & ~ # local/regular rules, like *.* /var/log/syslog.log |
4.重启rsyslog服务:service rsyslog restart
-
客户端:
1.安装rsyslog
2.编辑/etc/rsyslog.conf: 将remote host行取消注释并填入rsyslog server IP:
1 2 |
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional *.* @@remote_server_ip:514 |
3.测试:logger “hello world”。根据server端配置路径查看日志内容。
-
logrotate
1.使用基于cron服务的logrotate(可man)
2.配置范例在文件/etc/logrotate.conf
3.用户自定义配置,使用/etc/logrotate.conf中提供的方法,并将配置文件放在/etc/logrotate.d/下面
打完收工
2014年5月27日 Linux 0 Read more >
使用ftp建立yum源
-
server端
-
建立ftp服务
-
建立vsftpd服务
-
createrepo /repo
-
-
reposync远程源到本地
-
client端
2014年5月26日 Linux 0 Read more >
centos安装epel及remi
原文:http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x
How to install RHEL EPEL repository on Centos 5.x or 6.x
The following article will describe how to configure a CentOS 5.x-based or Centos 6.x-based system to use Fedora Epel repos and third party remi package repos. These package repositories are not officially supported by CentOS, but they provide much more current versions of popular applications like PHP or MYSQL.
Install the extra repositories
The first step requires downloading some RPM files that contain the additional YUM repository definitions. The instructions below point to the 64-bit versions that work with our Cloud Server instances.
Centos 5.x
1 |
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
sudo rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
Centos 6.x
1 |
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
Once installed you should see some additional repo definitions under the /etc/yum.repos.d directory.
1 |
$ ls -1 /etc/yum.repos.d/epel* /etc/yum.repos.d/remi.repo
/etc/yum.repos.d/epel.repo
/etc/yum.repos.d/epel-testing.repo
/etc/yum.repos.d/remi.repo
Enable the remi repository
The remi repository provides a variety of up-to-date packages that are useful or are a requirement for many popular web-based services. That means it generally is not a bad idea to enable the remi repositories by default.
First, open the /etc/yum.repos.d/remi.repo repository file using a text editor of your choice:
1 |
sudo vim /etc/yum.repos.d/remi.repo
Edit the [remi] portion of the file so that the enabled option is set to 1. This will enable the remi repository.
1 |
name=Les RPM de remi pour Enterprise Linux $releasever – $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority
You will now have a larger array of yum repositories from which to install.
2014年5月16日 Linux 0 Read more >
Centos设置代理
-
yum源
编辑/etc/yum.conf 文件
添加:
#Proxy
proxy=http://username:password@yourproxy:8080/
-
全局代理
编辑/etc/profile 文件
添加:
# Proxy
http_proxy=”http://username:password@yourproxy:8080″
export_http_proxy
或
# Proxy
export http_proxy=”http://username:password@yourproxy:8080″
-
wget代理
编辑/etc/wgetrc
添加:
2014年5月15日 Linux 0 Read more >
查询或者修改数据的inner连接方法
http://home.51cto.com/index.php?s=/Home
1
UPDATE product p, productPrice pp
SET pp.price = pp.price * 0.8
WHERE p.productId = pp.productId
AND p.dateCreated < ‘2004-01-01’
2
UPDATE product p
INNER JOIN productPrice pp
ON p.productId = pp.productId
SET pp.price = pp.price * 0.8
WHERE p.dateCreated < ‘2004-01-01’
3
UPDATE product p
LEFT JOIN productPrice pp
ON p.productId = pp.productId
SET p.deleted = 1
WHERE pp.productId IS null
2013年11月1日 Linux 0 Read more >
js的正则表达式
语法上,
d这种需要声明为:
var patt = new RegExp(“\d+”);
{}[]()这些都需要使用”\”转义。
使用上,
js的正则表达式支持的断言方式仅有两种。只可以截断后边界。截断前边界可以考虑二次处理的方式。
2013年11月1日 Linux 0 Read more >
批处理的变量引用
变量引用:
%1与%~1的区别是%~1去掉了输入参量中的所有qoutes。
其他变量的引用方法可以用call /?查看