Wednesday, August 21, 2013

Add CentOS6 Repo to Amazon AMI

Step 1, add centos.repo to /etc/yum.repos.d
[base]
name=CentOS-6 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=os
#baseurl=http://mirror.centos.org/centos/6/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
#[updates]
name=CentOS-6 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=updates
#baseurl=http://mirror.centos.org/centos/6/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=extras
#baseurl=http://mirror.centos.org/centos/6/extras/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=centosplus
#baseurl=http://mirror.centos.org/centos/6/centosplus/i386/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=contrib
#baseurl=http://mirror.centos.org/centos/6/contrib/i386/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

Step 2,
sudo rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

Tuesday, August 20, 2013

add swap to ec2 ubuntu

You can add a 1 GB swap to your instance with these commands:
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
To enable it by default after reboot, add this line to /etc/fstab:
/swapfile swap swap defaults 0 0

Thursday, August 8, 2013

Ubuntu Apache: how to hide server version and operation system from users?

1, find the file: conf.d/security
root@cmnew:/etc/apache2# less /etc/apache2/conf.d/security

2, change two parts;
ServerTokens Prod
ServerSignature Off

2, restart apache
root@cmnew:/etc/apache2# /etc/init.d/apache2 restart



Tuesday, August 6, 2013

get linux disk space data

freespace:
[root@ip-10-99-41-92 cloudwatch]# df --local --block-size=1M / | grep / |  tr -s ' ' | cut -d ' ' -f 4
6949







usedpercent
[root@ip-10-99-41-92 cloudwatch]# df --local /  | grep /  | tr -s ' ' | cut -d ' ' -f 5 | grep -o "[0-9]*"
13

[root@ip-10-99-41-92 cloudwatch]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda1             8256952   1057996   7115100  13% /
tmpfs                   304240         0    304240   0% /dev/shm