星期四, 4月 26, 2007

SUSE Linux 下的 SAMBA 伺服器

SUSE Linux 下的 SAMBA 伺服器
基本上跟RedHat系列的設定差不多
只是預設分享的目錄有點不太一樣
RedHat 預設分享homes 及 printers兩個目錄
[root@localhost ~]# cat /etc/samba/smb.conf |grep '\[' | grep -v '^;' | grep -v '^#'

[global]
[homes]
[printers]

但是SUSE Linux 預設分享的資料夾比較多, 多了profiles users groups print$
故要注意安全性的問題
linux-lab:/etc/samba # cat smb.conf | grep '\['
[global]
[homes]
[profiles]
[users]
[groups]
[printers]
[print$]


上面的print$ 為印表機驅動程式的分享

若以samba來當PDC
可以直接用yast 來設定
Domain Controller 為Primary (PDC)
及設定workgroup 的名稱 (即網域名稱)
附註只要有跑過yast的設定來分享
那gobal的設定部份就會加上
add machine script = /usr/sbin/useradd -c Machine -d /var/lib/nobody -s /bin/false %m$

方便加入Windows的機器, 也就是說Windows的機器提出要求後, 系統會自動加入帳號, 非以往要手動建立帳號,
在RedHat那邊有此script 的設定, 只是註解起來

設定好PDC 之後, 相關性的設定會儲存在 /var/lib/samba
linux-lab:/var/lib/samba # pwd
/var/lib/samba

相關檔案如下
linux-lab:/var/lib/samba # ls
account_policy.tdb group_mapping.tdb ntprinters.tdb share_info.tdb
brlock.tdb locking.tdb perfmon unexpected.tdb
browse.dat messages.tdb printing usershares
connections.tdb netlogon profiles
drivers ntdrivers.tdb registry.tdb
gencache.tdb ntforms.tdb sessionid.tdb

觀察兩個目錄 profiles and netlogon
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/

Windows機器加入後會自動加入機器帳號
linux-lab:/var/lib/samba # tail -n 2 /etc/passwd
hacluster:x:90:90:heartbeat processes:/var/lib/heartbeat/cores/hacluster:/bin/false
student-max$:x:1001:100:Machine:/var/lib/nobody:/bin/false

Windows加入網域後,以linux 本機帳號登入後檢查
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/

登出 Windows機器後檢查
linux-lab:/var/lib/samba # ls profiles/
linux-lab:/var/lib/samba # ls netlogon/
還是沒有資料 ---------->這時候會發現與RedHat不同處

在RedHat系列,設定為
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
; guest ok = yes

在SUSE Linux 設定為
[profiles]
comment = Network Profiles Service
path = %H
read only = No
store dos attributes = Yes
create mask = 0600
directory mask = 0700
其路徑在 %H
故存放的地點為 使用者家目錄下的 .msprofile 資料夾
故我們測試一下
在還沒使用 samba 服務登入Windows之前使用者家目錄
linux-lab:/home/max # ls
.bash_history .emacs .gnu-emacs .mozilla .urlview .xim.template Documents
.bashrc .exrc .inputrc .muttrc .xcoralrc .xinitrc.template bin
.dvipsrc .fonts .kermrc .profile .xemacs .xtalkrc public_html

登入Windows機器之後
linux-lab:/home/max # ls
.bash_history .exrc .kermrc .profile .xim.template bin
.bashrc .fonts .mozilla .urlview .xinitrc.template public_html
.dvipsrc .gnu-emacs .msprofile .xcoralrc .xtalkrc
.emacs .inputrc .muttrc .xemacs Documents
linux-lab:/home/max # ls .msprofile/

多了.msprofile資料夾,但是是空的,因為登出才會回存^^
在Windows機器上, 於我的文件新增一個資料夾sakana測試
登出Windows機器觀察

linux-lab:/home/max # ls .msprofile/
Application Data My Documents PrintHood Templates ntuser.ini ??????
Cookies NTUSER.DAT Recent UserData ntuser.pol
Favorites NetHood SendTo ntuser.dat.LOG ?????????????????????

linux-lab:/home/max # ls .msprofile/My\ Documents/
My Music My Pictures desktop.ini sakana

果然有回存到samba伺服器上面
^^

SUSE Linux 下的 NFS 伺服器

SUSE Linux 下的 NFS 伺服器
在SUSE Linux 下面
有nfs 和 nfsserver兩個daemon 於SUSE Linux下

但是啟動nfs 服務
是使用
#rcnfsserver start
來啟動nfs服務

但是要注意 rquotad 預設跟RedHat 系列不一樣
預設是沒有啟動
可用
#rpcinfo -p 127.0.0.1
觀察
如果要啟動rquotad
必須安裝
quota的套件
可用
#yast -i quota 來安裝

安裝完畢之後要啟動
#rcquotad start
# chkconfig quotad --list
quotad 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig quotad on
# chkconfig quotad --list
quotad 0:off 1:off 2:off 3:on 4:off 5:on 6:off

提到quota
如果開機要啟動quota
要在開機啟動boot.quota

預設是沒有啟動的
linux-lab:~ # chkconfig boot.quota --list
boot.quota 0:off 1:off 2:off 3:off 4:off 5:off 6:off

也非使用rcboot.quota來控制
linux-lab:~ # rcboot.quota status
-bash: rcboot.quota: command not found

如果chkconfig boot.quota --list 沒看到那就要使用insserv 這個指令加進來
linux-lab:~ # insserv boot.quota

可是還是跟rc的方式無關喔只是開機的時候要不要帶起來
linux-lab:~ # rcboot.quota status
-bash: rcboot.quota: command not found

下了insserv 這個指令就會把boot.quota帶起來
linux-lab:~ # chkconfig boot.quota --list
boot.quota 0:off 1:off 2:off 3:off 4:off 5:off 6:off B:on
上面那個B: on 代表 boot的時候會帶起來

可以使用chkconfig 來控制要不要帶起來
linux-lab:~ # chkconfig boot.quota off

linux-lab:~ # chkconfig boot.quota --list
boot.quota 0:off 1:off 2:off 3:off 4:off 5:off 6:off

linux-lab:~ # chkconfig boot.quota on
linux-lab:~ # chkconfig boot.quota --list
boot.quota 0:off 1:off 2:off 3:off 4:off 5:off 6:off B:on

********************************************************************
有關於autofs 設定檔的位置沒有太大的差異
但是對於timeout的寫法是有差異的

於RedHat 系列或是他的註解說明內
/misc /etc/auto.misc --timeout=60
但是這樣的寫法在SUSE Linux會有錯誤
Starting service automounter/usr/sbin/automount: option -t requires a numeric argument, got imeout

原因是timeout的寫法與註解及RedHat系列不一樣
故寫法為
#監控目錄 該目錄的設定檔 幾秒不用就Timeout
/misc /etc/auto.misc --timeout 60

沒有等於"="的寫法才是正確的

如果要設定全部的選項
可以去修改 /etc/sysconfig/autofs
AUTOFS_OPTIONS=""

啟動的方法一樣是
#rcautofs start

SUSE Linux 下的 DNS 伺服器

SUSE Linux 下的DNS 伺服器
預設Zone file擺放路徑為
/var/lib/named

跟RedHat系列擺放的 /var/named 有一點差異

預設也是有裝 bind-chrootenv
故zone會擺放在
/var/lib/named/var/lib/named

可參考 /etc/sysconfig/named
內有設定 NAMED_RUN_CHROOTED="yes"

另外在/etc/named.conf 裡面的設定
大多數是使用 include 的方式
其設定資料夾在 /etc/named.d 下
以及/etc/named.conf.include

其餘的部份與RedHat 相去不遠

星期三, 4月 25, 2007

SUSE Linux 下的 Log 機制

在SUSE Linux下面 log的機制
在SUSE Linux 使用syslog-ng 來取代傳統的syslogd
故沒有慣用的/etc/syslog.conf 來設定log機制

預設的syslog-ng的設定檔
在/etc/syslog-ng/syslog-ng.conf.in
(修改上述的檔案)


如果要使用習慣的syslogd
可以使用
#yast -i syslogd
來安裝syslogd套件即可使用在RedHat慣用的/etc/syslog.conf


在設定檔 /etc/syslog.conf 的寫法部份
man syslog.conf 會找到
You may prefix each entry with the minus ``-'' sign to
omit syncing the file after every logging.

使用 - 來代表非同步寫入
一般來說kernel 或是 mail 會使用非同步的方式來寫入避免造成太大的loading

可以用
logger -p mail.err "test"
測試log傳入

此外在RedHat的預設習慣是把mail的所有log
導向 /var/log/maillog
在SUSE Linux 則是 /var/log/mail


有關於Log Server的作法
相關的設定檔在/etc/sysconfig/syslog

檔案內容預設沒有
SYSLOGD_OPTIONS="-m 0"
以上為RedHat 預設的作法

在SUSE Linux 上面可以
#vi /etc/sysconfig/syslog
加入
SYSLOGD_PARAMS="-r"


有關於logrotate可參考
/etc/logrotate.d/syslog 的內容

SUSE Linux 下的 Process 觀察

在SUSE Linux 下面的process觀察
SUSE Linux 使用的daemon 名稱為apache2 執行的使用者為wwwrun
故啟動apache為
#rcapache2 start

欲使用top觀察可以查看使用者wwwrun

也可以使用批次導向的方式存檔監控
#top -b -n 10 -d 3 -u wwwrun > /tmp/top-www.log

星期二, 4月 24, 2007

SUSE Linux 下的X Window

SUSE Linux 在X Window 啟動與RedHat Linux不同為
並非在/etc/inittab 啟動
而是使用 xdm這個script 在runlevel 5 中執行
可觀察
#ls /etc/init.d/rc5.d grep xdm

設定是否啟動
#chkconfig --list grep xdm

另外如果是使用gnome的桌面環境
其設定檔也非RedHat 系列的
/etc/gdm/custom.conf

SUSE Linux 設定檔在
/etc/opt/gnome/gdm/gdm.conf

其檔案名稱與早期的gdm.conf一樣
且預設 xdmcp 為啟動

也可以使用
#gdmsetup 來設定相關細節


注意
在使用
#X -query 同學主機 :1
或是
#X -indirect 同學主機 :1

之前在RedHat系列是改完 gdm.conf 或是custom.conf
使用
#init 3
#init 5
重新啟動 X
就可以生效
但是在SUSE Linux發現用此方法不太work
建議使用
#rcxdm stop
#rcxdm start

因為發現
#init 3 ---> xdm竟然不會停止

所以使用
#rcxdm 的方式解決

也可以在X Window 下 使用Xnest 在開一個X
#Xnest -query 同學主機 :1

附註
在VMWare內
使用yast2 或是 sax2 設定顯示卡會有問題, 出不來
要使用
#sax2 -r

才可以

強制使用者下次登入必須換密碼

強制使用者下次登入必須換密碼
在大量建立使用者之後為了安全的考量
故要強制使用者下次登入時必須換密碼

可以使用
1. #chage -d 0 使用者名稱
或是
2. #passwd -e 使用者名稱

SUSE Linux的umask設定

SUSE Linux的umask設定
在RedHat系列的umask 定義於 /etc/bashrc

在SUSE Linux 的umask 則是設定於 /etc/profile
由於SUSE Linux 預設所有使用者都設定固定的群組
非RedHat系列有 私人群組
故統一都是設定
umask 022

SUSE Linux 的inode概念

SUSE Linux 預設使用 reiserfs為預設的檔案系統

reiserfs 是屬於 dynamic inode allocation 的 fs,
而不像是 ext3 是採用格式化就先建立一定數量的 inode 配置

故下指令
#df -i 的時候會看到
inode的顯示為0

但是
#ls -li
還是會看到 inode number的顯示

故#df -i 沒有顯示inode count為正常現象

SUSE Linux 下觀察super block

SUSE Linux 下觀察super block

之前在Redhat 習慣使用dumpe2fs 來觀察super block
[root@localhost ~]# whatis dumpe2fs
dumpe2fs (8) - dump ext2/ext3 filesystem information

但是dumpe2fs為ext2/ext3 的filesystem 指令

所以如果要觀察reiserfs的 superblock
那就要使用
debugreiserfs /dev/裝置位置

SUSE Linux下的Vim

SUSE Linux下的Vim 預設沒有將backspace功能寫入
如果習慣使用Backspace
可以
#vi /etc/vimrc

set backspace=2

也可以順便把語法檢查開啟(取消前面的" 註解)
syntax on

就可以支援 backspace鍵的使用及語法檢查

星期一, 4月 23, 2007

SUSE Linux 下的lsattr and chattr

在 SUSE Linux上面預設使用reiserfs 檔案系統
對於有些人會使用lsattr 及 chattr會出現
lsattr: 不希望的裝置輸出入控制 (ioctl) While reading flags on /目錄名稱/檔案名稱

如果要使用lsattr 或chattr
Step 1:::
要確定該filesystem 有加上attrs的屬性
假設要在/data的目錄下使用, 裝置為/dev/sda6
#vi /etc/fstab
/dev/sda6 /data reiserfs acl,user_xattr,attrs 12

#mount
#mount -o remount /data
#mount

確定有attrs屬性掛載

Step2:
使用
#reiserfsck --clean-attributes /dev/sda6
輸入Yes確定要清除屬性

Step 3:
測試
#touch /data/test
#lsattr /data/test


Notes:
[root@localhost ~]# whatis lsattr
lsattr (1) - list file attributes on a Linux second extended file system
[root@localhost ~]# whatis chattr
chattr (1) - change file attributes on a Linux second extended file system

星期六, 4月 21, 2007

OpenSUSE 安裝來源

OpenSUSE 10.2的安裝來源

#yast2 inst_source
-->新增 --> Ftp --> 下一個
-->伺服器名稱: ftp.cs.pu.edu.tw
-->伺服器上得目錄: Linux/OpenSuse/distribution/10.2/repo/oss
-->下一個 -->會去檢查安裝來源並點選同意的協定
-->如此就可以新增安裝來源

#yast2 inst_source
-->新增 --> Ftp --> 下一個
-->伺服器名稱: ftp.cs.pu.edu.tw
-->伺服器上得目錄: Linux/OpenSuse/distribution/10.2/repo/non-oss
-->下一個 -->會去檢查安裝來源並點選同意的協定
-->如此就可以新增安裝來源
可以多利用靜宜大學的ftp來源
ftp://ftp.cs.pu.edu.tw/Linux/OpenSuse/distribution/10.2/repo/oss
ftp://ftp.cs.pu.edu.tw/Linux/OpenSuse/distribution/10.2/repo/non-oss

星期六, 4月 14, 2007

[轉貼]Novell decided to make ext3 the default file system in SUSE Linux Enterprise 11

全文link
http://www.novell.com/linux/filesystems/faq.html

大意是Novell 順應客戶的要求把default filesystem把ReiserFS 換成 EXT3

Frequently Asked Questions

Why has Novell decided to make ext3 the default file system in SUSE Linux Enterprise 11 instead of remaining with ReiserFS or choosing OCFS2?

This change is almost completely in response to recent customer demand. Novell is seeing increasing numbers of customers who prefer ext3 to ReiserFS, and our choice of default for SUSE Linux Enterprise 11 reflects this. Today, ext3 and ReiserFS v3 are mostly on par: ext3 has very recently gained some scalability enhancements (h-trees) and online expansion support (in SUSE Linux Enterprise Server 10). Furthermore, ext3 now features more than three years of journaling hardening, which makes it competitive with ReiserFS v3. OCFS2 is a parallel cluster file system designed for specific workloads, but it is unlikely that it will have root/boot support by SUSE Linux Enterprise 11. Finally, Novell is following the development of ext4, and expects it to become a solid nextgeneration enterprise file system.

Is Novell abandoning ReiserFS?

Not at all. Novell continues to support and improve ReiserFS v3. It is also included in mainline kernel distributions and will continue to receive enterprise support in future SUSE Linux Enterprise distributions. Customers who deploy SUSE Linux Enterprise Server 9 or SUSE Linux Enterprise 10—and determine that ReiserFS is best for their companies’ applications or service use cases—should use ReiserFS. Novell has always recommended using the best file system for the application or service. File systems seem to “live forever,” so ReiserFS v3 will be supported for the foreseeable future in SUSE Linux Enterprise distributions.

Why did SUSE Linux Enterprise use ReiserFS in the first place?

About seven years ago, SUSE needed an enterprise scalable journaled file system, and ReiserFS was the only one available. After arranging for support with NameSys (the Reiser development team) and building internal expertise, ReiserFS was the obvious choice. At that time, ext3 did not yet exist; it did not appear until about four years later. In addition, ext3 has only recently (within the last year) gained key enterprise-level features such as online expansion and scalability, which ReiserFS v3 has had for years.

After ReiserFS v4 is accepted in the mainline kernel, will Novell switch back to supporting it in future versions of SUSE Linux Enterprise?

While it is possible that Novell will support ReiserFS v4 in future enterprise deployments (when it is stable, enterprise worthy and included in the mainline kernel), it is unlikely that it will become the default installation choice.

Will Novell support ext4 in future versions of SUSE Linux Enterprise?

Novell anticipates that future versions of SUSE Linux Enterprise will support ext4, but only after it is accepted in the mainline kernel and is deemed enterprise worthy and stable. There are compatibility questions that still need to be resolved between ext3 and ext4 (for example, 48-bit block numbers), which will dictate when and how Novell supports this new file system.

Is this change in the default file system going to appear in the future service packs of SUSE Linux Enterprise 10?

No. Novell doesn't make default configuration changes in service packs. Doing so would cause too much disruption to customer deployments of SUSE Linux Enterprise 10.

There are other file systems included in SUSE Linux Enterprise 10 besides ReiserFS, ext3, XFS and OCFS2. Are they supported?

The other file systems are included for convenience and are not directly supported by Novell. Other vendors may offer support for these systems (for example, IBM for the JFS file system). In addition, there are third-party addon file systems (such as PolyServe or Symantec–Veritas), which are supported by their respective vendors on SUSE Linux Enterprise.

SUSE® Linux Enterprise : File System Support

File Systems in SUSE Linux Enterprise 10

The SUSE Linux Enterprise platform—including its related products, SUSE Linux Enterprise Server and SUSE Linux Enterprise Desktop—is the only Linux* distribution that offers broad out-of-the-box support for a number of file systems. In SUSE Linux Enterprise 10, Novell® provides enterprise support for the ReiserFS v3, ext3, XFS, and OCFS2 file systems. Each of these file systems has its strengths for specific types of applications and workloads. This gives customers more flexibility, enabling them to deploy the file system that best meets the needs of their existing environment. For a more detailed overview of file systems, including those delivered with SUSE Linux Enterprise 10, please refer to the Novell File System Primer

In SUSE Linux Enterprise 10 and prior versions, the best file system for scalability and all-around performance has been ReiserFS v3. For more specific uses, other file systems have been recommended. For example, OCFS2 is the recommended file system for organizations with Oracle* RAC workloads running on both SUSE Linux Enterprise Server 9 SP2 and the latest SUSE Linux Enterprise 10 release. Similarly, ext3 has been recommended for small file systems, typically those used in edge services in prior distributions. XFS has been recommended for large file systems that also contain large files (such as video rendering). Novell will continue to support all of these file systems well into the future.

File System Future Directions

Today’s open source developers expect organizations to communicate software changes as early as possible. Novell realizes this and is committed to keeping the community up to date. For the upcoming SUSE Linux Enterprise 11, Novell will be changing the default file system in new installations from ReiserFS v3 to ext3. The openSUSE™ builds will first reflect this change, starting with openSUSE 10.2. The openSUSE community builds provide the foundation for the next enterprise distribution release: SUSE Linux Enterprise 11.

星期一, 4月 09, 2007

什麼的注音方法

每次要輸入''什麼''這兩個字,注音輸入法老是會忘記
乾脆就把他寫在blog上面


http://www.edu.tw/EDU_WEB/EDU_MGT/MANDR/EDU6300001/allbook/kyjd/z4.html?open

將Linux 放進USB 隨身碟~~Slax Linux

最近有一個1GB的USB隨身碟閒置, 剛好今天做完星期一的論文摘要,
有一些空閒時間, 就想說利用時間玩一下USB 開機的Linux

找了一些文章, 後來發現帝國反抗君的Slax介紹比較符合自己的需求
http://blog.roodo.com/ystuan/archives/1327524.html

就想說來實作一下, 想不到還算很順利的成功呢^^

以下為Lab 步驟
O.S: Fedora core 6
USB 隨身碟: 1GB (假設裝置於/dev/sda,假設掛載目錄為/media/disk)

1.到SLAX 的下載頁面下載要使用SLAX版本(我選的是SLAX KillBill Edition v 5.1.8.1)
http://www.slax.org/download.php
下載回來的是 slax-killbill-5.1.8.1.iso 這個iso檔
假設下載的位置在/home/max/Desktop

2.參考在GNU/Linux上製作Slax USB的方法
網頁如下
http://os.newsforge.com/article.pl?sid=05/07/08/1522251

首先建立一個資料夾來掛載iso檔
#mkdir /mnt/usb

將iso檔掛載到/mnt/usb
#mount -o loop /home/max/Desktop/slax-killbill-5.1.8.1.iso /mnt/usb/

將SLAX的檔案複製到USB 隨身碟上
#cp -ra /mnt/usb/* /media/disk

把核心及initrd 複製到USB 隨身碟下
#cd /media/disk/boot
#cp vmlinuz /media/disk
#cp initrd.gz /media/disk

將isolinux.cfg 重新命名為 syslinux.cfg
#cd /media/disk
#mv isolinux.cfg syslinux.cfg

修改syslinux.cfg的內容, 將原本有/boot 或是 boot路徑移除, 因為已經把vmlinuz 及initrd.gz複製到USB 隨身碟下面
#vim syslinux.cfg
原內容
label slax
kernel boot/vmlinuz
append vga=769 changes=slaxsave.dat max_loop=255 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444 root=/dev/ram0 rw

label linux
kernel boot/vmlinuz
append vga=769 changes=slaxsave.dat max_loop=255 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444 root=/dev/ram0 rw

修改為(就是把boot/ 或是 /boot的路徑去除)
label slax
kernel vmlinuz
append vga=769 changes=slaxsave.dat max_loop=255 initrd=initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444 root=/dev/ram0 rw

label linux
kernel vmlinuz
append vga=769 changes=slaxsave.dat max_loop=255 initrd=initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444 root=/dev/ram0 rw

使用syslinux 製作開機
#syslinux -s /dev/sda1

解決中文化的問題
到SLAX multilang modules 網頁下載modules
http://www.slax.org/modules.php?category=multilang
下載這三個
Taiwan(cht) input method - gcin
Taiwan(cht) Language Pack
CJK Display Support (optimized) 1.0
假設存放在/home/max/Desktop

將下載下來的 .mo檔 複製到 /media/disk/base 下面
#cp /home/max/Desktop/CJK_Display_Support_optimized_1_0-3.mo /media/disk/base
#cp /home/max/Desktop/Taiwan_cht_input_method_gcin_1172.mo /media/disk/base
#cp /home/max/Desktop/Taiwan_cht_Language_Pack_2006_0801.mo /media/disk/base


3.重開機,將電腦的BIOS設定為USB開機

enjoy it.......^^
以後走到哪裡都是Linux真是愉快