Friday, October 8, 2010

How to send email from the Linux command line

Use command mail & mutt :
MAIL command :
#mail -s “Test Only” inotri@gmail.com


To add content to the body of the mail while running the command you can use the following options.
# echo “This will go into the body of the mail.” | mail -s “Test Only” inotri@gmail.com

if you want mail to read the content from a file.
# mail -s “Test Only” inotri@gmail.com < /home/toni/test.only

Some other useful options in the mail command are:
-s subject (The subject of the mail)
-c email-address (Mark a copy to this “email-address”, or CC)
-b email-address (Mark a blind carbon copy to this “email-address”, or BCC)

Here’s how you might use these options:
# echo “Testing email from command-line” | mail -s “Test Only” inotri@gmail.com -c inotri@yahoo.com -b inotri@hotmail.com

MUTT command :

# echo “Sending an attachment.” | mutt -a backup.zip -s “Test with attach” inotri@gmail.com

SENDING MAIL FROM A SHELL SCRIPT

---Sample 1 ---
#!/bin/bash
df -h | mail -s “disk space report” inotri@gmail.com

---Sample 2 ---
#!/bin/bash
df -h > /tmp/diskfile_report.log
free -m >> /tmp/diskfile_report.log
mail -s “disk file report” inotri@gmail.com < /tmp/diskfile_report.log

---Sample 3 ---
#!/bin/bash
tar -zcf /tmp/backup.tar.gz /home/toni/files
echo | mutt -a /tmp/backup.tar.gz -s “daily backup of data” inotri@gmail.com

Thursday, September 23, 2010

How to Restart Windows via Remote Desktop

The Turn Off Computer is not available on the Start menu to shut down and restart, when you are using Remote Desktop. Here are 3 ways to shut down a remote computer when you are using Remote Desktop :
1. Press CTRL+ALT+END, and then click Shutdown.
2. Press ALT + F4, and then click Shut down
3. Use the shutdown command at a command prompt, like shutdown -r

Tuesday, September 14, 2010

Create NTP Server

Berikut waktu di server sebelumnya :
[root@smtp3 ~]# date
Mon Sep 13 14:39:12 WIT 2010
Install paket ntp, yg digunakan oleh penulis adl CentOS 5.4
[root@smtp3 ~]# yum install -y ntp
Letak file konfigurasi :
[root@smtp3 ~]# vi /etc/ntp.conf
Jika server ntp waktunya belum sesuai, dapat lakukan :
[root@smtp3 ~]# ntpdate -u 203.160.128.3
13 Sep 15:38:50 ntpdate[15551]: step time server 203.160.128.3 offset 2282.253975 sec
Setelah terinstall menjadi server NTP :
[root@smtp3 ~]# date
Mon Sep 13 15:39:03 WIT 2010
Untuk melihat & memastikan acuan server waktu yg digunakan :
[root@smtp3 ~]# ntpq -p