顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2015年9月30日 星期三

[SSHFS]安裝設定使用(ssh遠端掛載目錄)


安裝
Centos 安裝套件後,使用者必須加入fuse群組才能使用FUSE功能
yum install fuse-sshfs
usermod -a -G fuse username
設定
新增/etc/fuse.conf,增加以下內容,掛載時才可以使用-o allow_other參數
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other
手動掛載
如果想要讓資料夾可以被帳號以外的其他使用者帳號存取可加入-o allow_other參數
sshfs -o allow_other username@IP:/path/to/folder /path/to/local/folder
手動缷載
fusermount -u /path/to/local/folder
開機自動掛載
/etc/fstab下新增 (SSH Trust要先做好!!!)
 username@ip:/path/to/folder /path/to/local/folder   fuse.sshfs idmap=user,identityfile=/home/username/.ssh/id_dsa,allow_other,uid=User_uid,gid=User_gid 0 0

資料來源:
http://blog.miniasp.com/post/2013/11/30/Useful-tool-SSHFS-SSH-Filesystem.aspx
http://what-a-good-day.blogspot.tw/2015/05/ssh-mount-linux.html
http://unix.stackexchange.com/questions/37168/unable-to-use-o-allow-other-with-sshfs-option-enabled-in-fuse-conf
http://fuse.sourceforge.net/
https://www.variux.com/sshfs-automount-at-boot-with-fstab-on-ubuntu-14-04/

2015年5月11日 星期一

[備忘]如何解決舊版本Ubuntu無法更新套件或安裝套件的問題


如舊版本Ubuntu 12.10由於sources.list檔案中的更新套件的來源伺服器連不到無法使用,
所以會無法更新或安裝套件

解決方法:
在/etc/apt/sources.list.d/sources.list檔案中加入以下
deb http://old-releases.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricted universe multiverse
加入後更新一下套件清單apt-get update,即可更新或安裝套件


資料來源:http://askubuntu.com/questions/518856/upgrade-12-10-sources-list
參考連結:http://www.arthurtoday.com/2010/11/ubuntu-apt-get.html

2013年12月20日 星期五

PHP 錯誤訊息提示功能 php.ini display_errors

文章轉貼資料來源:IT達人
php.ini 檔案設定:
當display_errors = on 時若 php 的程式有問題即會把錯誤訊息顯示在瀏覽器上,這對開發人員非常方便,但當網站對外開放時,一般都會把這個功能關閉,因為php若遇嚴重錯誤時不管你有沒有開啟這個功能它都會顯示錯誤訊息在瀏覽器上通常正式上線的 php 網站都會將這個功能關閉。
檢查 php.ini 檔中的 display_errors 的設定是否為
display_errors = on (若有錯誤會顯示在瀏覽器上) 
將它改成
display_errors = off (關閉錯誤提示訊息)
設定好之後重新將apache 啟動即可

2013年6月30日 星期日

[備忘]Clamav freshclam doesn't update

轉貼來自於http://jerryclc.blogspot.tw/2012/06/etccron.html
Clamav freshclam doesn't update  Error message as below

ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
ERROR: Can't open /var/log/clamav/freshclam.log in append mode (check permissions!).



Modify "/etc/cron.daily/freshclam
==============================

#!/bin/sh

### A simple update script for the clamav virus database.
### This could as well be replaced by a SysV script.

### fix log file if needed
LOG_FILE="/var/log/clamav/freshclam.log"
if [ ! -f "$LOG_FILE" ]; then
    touch "$LOG_FILE"
    chmod 644 "$LOG_FILE"
   // modify chown clam.clam ==> clamav.clamav
    chown clamav.clamav "$LOG_FILE"
fi

/usr/bin/freshclam \
    --quiet \
    --datadir="/var/lib/clamav" \
    --log="$LOG_FILE"

2013年6月26日 星期三

[備忘]ProFTPD Server Log - xferlog 分析

以下文章轉貼資料來源:
1.http://www.the-art-of-web.com/system/xferlog/#.UcsA9Pl8k9s
2.http://www.linuxweblog.com/blogs/wizap/20080129/analyzing-proftpd-xferlog-file


 The xferlog Format
The default format of the xferlog for ProFTP contains the following information on each line:
current-time
Thu June 27 01:24:47 2013
transfer-time
whole seconds
remote-host
file-size
size of transferred file in bytes
file-name
transfer-type
a = ascii; b = binary
special-action-flag
C = compressed; U = uncompressed; T = tar'ed; _ = no action was taken
direction
o = outgoing; i = incoming; d = deleted
access-mode
a = anonymous; r = real
username
service-name
usually ftp
authentication-method
0 = none; 1 = RFC931 Authentication
authenticated-user-id
user id or '*'
completion-status
c = complete; i = incomplete
The three characters following the file name represent the transfer-type (ascii or binary), any special actions (usually _ meaning none) and the direction (outgoing, incoming or deleted).
  1. ascii format:
    • a _ i (uploaded)
    • a _ o (downloaded)
    • a _ d (deleted)
  2. binary format:
    • b _ i (uploaded)
    • b _ o (downloaded)
    • b _ d (deleted)

Now, to extract a list of all successfully uploaded files
(查已上傳成功的檔案):

awk '($12 ~ /^i$/ && $NF ~ /^c$/){print $9}' xferlog

(查已被下載的檔案):

awk '($12 ~ /^o$/ && $NF ~ /^c$/){print $9}' xferlog

(查已刪除的檔案):
awk '($12 ~ /^d$/ && $NF ~ /^c$/){print $9}' xferlog


and uploads that were unsuccessful(查上傳未完成的檔案):
awk '($12 ~ /^i$/ && $NF ~ /^i$/){print $9}' xferlog

2012年6月11日 星期一

[筆記]備忘:Centos6.2 安裝JAVA、Tomcat套件與設定

Centos6.2 安裝JAVA、Tomcat套件
#yum -y install tomcat6 tomcat6-webapps tomcat6-admin-webapps

# rpm -qa java*jdk tomcat6  //查詢套件版本
java-1.6.0-openjdk-1.6.0.0-1.43.1.10.6.el6_2.i686
tomcat6-6.0.24-36.el6_2.noarch
# rpm -qc tomcat6 | grep -E 'server|users'
/etc/tomcat6/server.xml  //查詢相關設定檔路徑
/etc/tomcat6/tomcat-users.xml

設定環境檔變數
#!vi /etc/profile    //加在最底部即可
============================================
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib
export PATH JAVA_HOME CLASSPATH
============================================

建立一個名為server.jsp用來判斷目前Tomcat服務是由哪一台叢集主機來負責
===================================================================
<%@ page contentType="text/html; charset=utf8" %>

<%@ page import="java.net.InetAddress" %>

<html>

<head>

<title>Server hostname and ip in jsp</title>

</head>

<body><h1>

  <%String ip = "";

  InetAddress inetAddress = InetAddress.getLocalHost();

  ip = inetAddress.getHostAddress();

  out.println("Server Hostname is: " +inetAddress.getHostName());%><br>

  <% out.println("Server IP Address is: "+ip); %><br>

</h1></body>

</html>
======================================================


2011年12月15日 星期四

Linux下支援語系設定檔i18n(解決中文亂碼問題)

裝機後必設定此語系檔
/etc/sysconfig/i18n
================================================
LANG="zh_TW.Big5"
SUPPORTED="zh_TW.Big5:zh_TW:zh:en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"
================================================

保存退出後,執行如下立即生效 (不需重開機)
#source /etc/sysconfig/i18n


可避免FileZilla上傳多層中文目錄會出現的錯誤訊息
Failed to convert command to 8 bit charset

2011年11月21日 星期一

[備忘]Redhat安裝Clamav步驟

安裝步驟

1.到ClamAV官網網址http://pkgs.repoforge.org/clamav/
wget下載如下三個套件
clamav-0.97.3-1.el6.rf.x86_64.rpm
clamav-db-0.97.3-1.el6.rf.x86_64.rpm
clamd-0.97.3-1.el6.rf.x86_64.rpm

2.
rpm -ivh clamav-db-0.97.3-1.el6.rf.x86_64.rpm

3.
rpm -ivh clamav-0.97.3-1.el6.rf.x86_64.rpm

或步驟2、3 可直接用rpm -ivh clamav-* 一行指令方式安裝

4.
rpm -ivh clamd-0.97.3-1.el6.rf.x86_64.rpm

Clamav完裝完成

5.啟動Clamd服務
/etc/rc.d/init.d/clamd start

6.執行更新病毒碼指令
freshclam

7.測試ClamAV是否能夠掃毒
clamscan /tmp

以上參考網路資料

2011年11月14日 星期一

[備忘]更改~/.bashrc直接申效Commond

1.設定 執行vi時使用vim
vi ~/.bashrc
=================================================================
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
~~~省略
=================================================================
2.立即申效command
source ~/.bashrc

2011年11月11日 星期五

[設定備忘]有效阻擋非法的垃圾信來源(針對郵件帳號或網域限制的方法)

測試工具
yum install mailx (安裝此套件後才有mail指今可用)
yum install telnet (安裝此套件後才有telnet指今可用)


1.vi /etc/postfix/check_sender 建立限制名單
===========================
#格式: 寄件來源 處理動作
#針對單一郵件帳號REJECT
xxx@example.com REJECT
#針對整個DOMAIN REJECT
example.com REJECT

===========================

2.postmap /etc/postfix/check_sender 會產生check_sender.db檔

3.vi /etc/postfix/main.cf 新增/修改如下條件
=======================================
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/check_sender,permit_mynetworks
=======================================
注意:實測結果,限制條件cehck_sender_access要放在最前面才能有效Reject check_sender名單上的寄件者或網域名稱

4. service postfix restart 後申效 或 /etc/init.d/posfix reload 後申效

最後在使用telnet localhost 25去測試設定是否有作用

下圖虛擬練習機上的main.cf 新增/修改畫面










2011年10月5日 星期三

[筆記]關於Network Interface Configuration - Bonding




Selected Linux Ethernet Bonding Modes ( 後面文字,Redhat上課筆記,供參考)

Network Interface Configuration - Bonding設定的主要用途: 頻寬合併(需搭配Switch支援)、分流、備援、容錯



主要談到以下三種Mode

Mode 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available. (需搭配Switch 有頻寬合併 、有容錯)


Mode 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails. (最佳的容錯機制 , 接手速度最快,Session中斷,掉五個封包以內,可備援接手)


Mode 3— Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.(無頻寬合併,接手速度相較Mode1慢,優點中斷時,含中斷前的所有資料,將會由備援接手)


關於Network Interface Configuration - Bonding相關參考連結

2011年9月22日 星期四

[備忘]Proftp


參考資料:鳥哥的Linux私房菜



MaxInstances 50 # 最多僅有 50 條 prftpd 的 PID

MaxClients 100 "很抱歉上線人數額滿了" # 最多允許 100 個使用者在線上

MaxClientsPerHost 5 # 同一個主機最多可以同時 5 個 FTP 連線

2011年9月10日 星期六

2011年9月2日 星期五

實用工具:WineHQ(2011.11.22更新)

課程上介紹到的工具之一,WineHQ
http://www.winehq.org/

用途:安裝WineHQ讓Linux平台上也能夠執行微軟平台上的應用軟體,讚!!!




























安裝參考連結:






編譯需安裝的套件

yum install gcc*

yum install make

yum install gcc-c++.i386
yum install bison.i386
yum install libXi-devel.i386
yum install rpm-build.i386
yum install freetype-devel.i386

2011年8月21日 星期日

[備忘指令]查目錄佔用空間的指令du -h --max-depth=1 目錄路徑

查目錄佔用空間的指令 du -h --max-depth=1 /usr/share/ | grep --color local  

or

du -B G --max-depth

Redhat圖型工具
[Application] [System Tool] [Disk Usage Analyzer] 選項:[Analyzer] [Scan Filesystem]

[備忘指令]cat指令參數用法

轉貼[引用]資料來源:鳥哥的Linux私房菜網站
-A  :相當於 -vET 的整合選項,可列出一些特殊字符而不是空白而已;
-b  :列出行號,僅針對非空白行做行號顯示,空白行不標行號! 
-E  :將結尾的斷行字元 $ 顯示出來;
-n  :列印出行號,連同空白行也會有行號,與 -b 的選項不同; 
-T  :將 [tab] 按鍵以 ^I 顯示出來; 
-v  :列出一些看不出來的特殊字符

2011年8月13日 星期六

[備忘指令]查詢顯示檔案隱藏屬性lsattr指令

查詢顯示檔案隱藏屬性
lsattr 絕對路徑檔名


將檔案隱藏屬性設為唯讀
chattr +i 絕對路徑檔名

2011年8月4日 星期四

Locate and Analyze a Log Summary Report設定

步驟1. vi /etc/aliases
最後一行增加/or修改 root:空 格root,abc@abc.com(管理者信箱)

步驟2 service postfix restart

設定好後預設每天的凌晨4:02分會系統會自動發Email(系統Log記錄)通知root和abc@abc.com信箱

2011年7月26日 星期二

Redhat 6遠端桌面連線Windows作業系統

安裝rdesktop套件
#yum install rdesktop

遠端連線 (全螢幕參數 -f)
#rdesktop -f 遠端主機IP

2011年3月27日 星期日

Centos5.5網路安裝

下載ISO檔(CentOS-5.5-i386-netinstall.iso)
http://ftp.isu.edu.tw/pub/Linux/CentOS/5.5/isos/i386/CentOS-5.5-i386-netinstall.iso

安裝來源我選擇http,

Web site name:ftp.isu.edu.tw
CetOS directory:/pub/Linux/CentOS/5.5/os/i386