greening install

common

常用工具

yum update
yum install vim
yum install net-tools
yum install git
yum install svn
yum install wget

新增套件

epel

請參考:epelInstall EPEL and additional repositories on CentOS and Red Hat

#下載epel套件
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm;

#本機安裝epel套件
rpm -ivh epel-release-6*.rpm

Remi

請參考:Remi

#下載remi套件
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#本機安裝remi套件
rpm -Uvh remi-release-6*.rpm

Linux 常用指令

#用檔名找檔案。可用*符號。
find / -name 檔名

#指令歷程
history

#檢視檔案、目錄
ll
ls
ls -lh (檔案大小以易讀的方式顯示)

#Repository 清單
yum repolist

#移除套件
yum remove 套件名稱,例php

#硬碟配額
df -h

#查詢 centos 的版本
cat /etc/*release*

vim 指令

[Command mode]

:q 離開
:w 儲存
:wq 儲存後離開
:q! 強制離開
:w! 強制儲存
:w ~/檔名 另存新檔
u 回復上一個動作
a : 切換Insert mode

#移動
1G 或 gg : 移動到檔案的第一行
G : 移動到檔案的最後一行

#搜尋、取代
/abc : 向下搜尋abc
?abc : 向上搜尋abc
n : 下一筆搜尋結果
N : 上一筆搜尋結果
:noh 取消選取的highlight

#複製、貼上
ggVG : 全選
dd : 刪除整行
2dd : 刪除下列2行
y0 : 複製游標所在的那個字元到該行行首的所有資料
y$ : 複製游標所在的那個字元到該行行尾的所有資料
yy : 複製游標所在的那一行
P : 貼上於目前游標的上一行
p : 貼上於目前游標的下一行

[Insert mode]

ESC : 切換Command mode

PostgreSQL 指令

功能 指令
顯示所有資料庫 \l
切換資料庫 \c <資料庫名稱>
查看表 \dt
查看表結構 \d
查看索引 \di
查看某個表的狀況 \d [表名]
查看所有用戶 \du
結束 \q
以下皆以分號「;」結尾執行查詢
創建資料庫 create database <資料庫名稱>;
新建用戶 create role <管理者名稱>;
新建用戶 create user <管理者名稱>;
刪除用戶 drop role <管理者名稱>;
刪除用戶 drop user <管理者名稱>;
新增表 create table <表名> ( <欄名> <型別> , ... );
查看表 select <欄名> from <表名>;
刪除表 drop table <表名> ;
修改欄位 alter table <表名> rename<舊欄名> to<新欄名> ;
清除表內容 delete from <表名>;
插入資料 INSERT INTO <表格名> (<欄位1>, <欄位2>, ...) VALUES (<值1>, <值2>, ...);