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

20131112

Ubuntu 9.04 change ssh login banner

這裡可以改靜態的文字
#vi /etc/motd

但是如果我要顯示現在IMAP Login Session數,如下
# vi /etc/update-motd.d/99-imap
===============================================
#!/bin/sh
echo "IMAP Login sessions: `netstat -tuen|grep :993|wc -l`"
===============================================
:wq
# update-motd --enable d


20111207

UNetbootin

Introduction
UNetbootin allows you to create bootable Live USB drives for Ubuntu, Fedora, and other Linux distributions without burning a CD. It runs on Windows, Linux, and Mac OS X. You can either let UNetbootin download one of the many distributions supported out-of-the-box for you, or supply your own Linux .iso file if you've already downloaded one or your preferred distribution isn't on the list.
UNetbootin

20100429

Crontab 環境變數,這算是很重要的基本觀念,所以不能忘~~~

不廢話,如何看到Crontab啟動時所帶的環境變數
要觀察crontab 的話需要透過 crontab來啟動sh
vi /tmp/x.sh
export > /tmp/xx.txt
crontab -e
*/1 * * * * /tmp/xx.txt #每分鐘跑一次
cat /tmp/xx.txt
export HOME='/root'
export LOGNAME='root'
export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
export PWD='/root'
export SHELL='/bin/sh'
如此一來就看到Crontab了
但也非常的清楚的看到,寫好的sh不會自己套上Bash的環境變數
所以會需要用到的環境變數需要在sh內就定義好
免得發生跑出來的結果不是自己預期的效果
比如說SH中有包含中文字,sh處理完後變成亂碼
像這樣就可以在sh的內容中將LANG="en_US.UTF-8" export
export LANG="en_US.UTF-8"
這樣亂碼的問題就解除了

當然也可以寫在/etc/crontab 裡面
方法1
vi /etc/crontab
LANG="en_US.UTF-8" #加在開頭的地方
方法2
vi /etc/crontab
* 17 * * 1-5 root export LANG="en_US.UTF-8";/tmp/x.sh #加在row也可以
差別是
方法1:所有/etc/crontab內的row都會套用到這個環境變數
方法2:只有該row套用這個環境變數

這算是很重要的基本觀念,所以不能忘~~~

謝謝 Tsung 前輩
參考來源Crontab 基本環境變

20090930

Postfix 如何備份所有進出的信件??

在 postfix 的 main.cf 裡加上:
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc
sender_bcc_maps = hash:/etc/postfix/sender_bcc

然後編輯 recipient_bcc 跟 sender_bcc
格式很簡單, 如果帳號是 foo 要備份到 bar 就直接打
foo bar
即可, 一行一行加進去就行, 不備份的就不加了,
另外也可以把所有帳號的郵件都備份到 bar 裡面.

記得檔案編完要下 postmap 指令轉一下 table

ps. 好像要較高版本 (2.2?) 的 postfix 才有這個功能,
答案來自EarlyCAT

參考網址酷學院討論串

20090112

TestDisk

TestDisk is OpenSource software and is licensed under the terms of the GNU Public License (GPL).

TestDisk is a powerful free data recovery software! It was primarily designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error (such as accidentally deleting a Partition Table). Partition table recovery using TestDisk is really easy.

TestDisk can

* Fix partition table, recover deleted partition
* Recover FAT32 boot sector from its backup
* Rebuild FAT12/FAT16/FAT32 boot sector
* Fix FAT tables
* Rebuild NTFS boot sector
* Recover NTFS boot sector from its backup
* Fix MFT using MFT mirror
* Locate ext2/ext3 Backup SuperBlock
* Undelete files from FAT, NTFS and ext2 filesystem
* Copy files from deleted FAT, NTFS and ext2/ext3 partitions.

TestDisk has features for both novices and experts. For those who know little or nothing about data recovery techniques, TestDisk can be used to collect detailed information about a non-booting drive which can then be sent to a tech for further analysis. Those more familiar with such procedures should find TestDisk a handy tool in performing onsite recovery.

Operating systems

TestDisk can run under

* DOS (either real or in a Windows 9x DOS-box),
* Windows (NT4, 2000, XP, 2003, Vista),
* Linux,
* FreeBSD, NetBSD, OpenBSD,
* SunOS and
* MacOS

Source files and precompiled binary executables are available for DOS, Win32, MacOSX and Linux from the download page

Filesystems

TestDisk can find lost partitions for all of these file systems:

* BeFS ( BeOS )
* BSD disklabel ( FreeBSD/OpenBSD/NetBSD )
* CramFS, Compressed File System
* DOS/Windows FAT12, FAT16 and FAT32
* HFS, HFS+ and HFSX, Hierarchical File System
* JFS, IBM's Journaled File System
* Linux ext2 and ext3
* Linux LUKS encrypted partition
* Linux RAID md 0.9/1.0/1.1/1.2
o RAID 1: mirroring
o RAID 4: striped array with parity device
o RAID 5: striped array with distributed parity information
o RAID 6: striped array with distributed dual redundancy information
* Linux Swap (versions 1 and 2)
* LVM and LVM2, Linux Logical Volume Manager
* Mac partition map
* Novell Storage Services NSS
* NTFS ( Windows NT/2000/XP/2003/Vista/2008 )
* ReiserFS 3.5, 3.6 and 4
* Sun Solaris i386 disklabel
* Unix File System UFS and UFS2 (Sun/BSD/...)
* XFS, SGI's Journaled File System

轉載自 http://www.cgsecurity.org/wiki/TestDisk

20081007

利用ISP的Mail Server來relay mail

這個方法真的很讚,假使我一封信1mb但是我要寄給10個人(不同domain name)的話,outbound就有可能需要1mb*10的流量,以我們申請的網路2m/512可能就操到破表了,所以如能藉由ISP的mail server來relay我們寄出去的信,這樣一來outbound就只有1mb了。
設定方式如下

[sendmail]
1.編輯 /etc/mail/sendmail.mc
# vi /etc/mail/sendmail.mc
define(`SMART_HOST',`msa.hinet.net')
2.restart service


[postfix]
1.Edit /etc/postfix/main.cf, and add or edit this line:
relayhost = msa.hinet.net
2.restart service


參考資料
Gavin's Linux學習手札
Ubuntu Blog