ithut (.) net

Howtos and Tutorials from behind the firewall

  • Home
  • Android
    • Root Your Phone
    • Android News
  • Urdu Tutorials
  • Top Tutorials
  • Forum
  • Policies
    • Copyright Policy
    • Comment Policy
  • Contact us
Twitter Youtube RSS
Monthly Archives: October 2011

How to send email from the Linux command line

Posted on October 13, 2011 by Muhamamd Zeeshan
6 comments

The Linux command line can be very powerful once you know how to use it. You can parse data, monitor processes, and do a lot of other useful and cool things using it. There often comes a need to generate a report and mail it out. It could be as simple a requirement as a notification that the day’s backup went through fine, or did not. I’ll help you get started with sending mails from the Linux command line and in shell scripts. We will also cover sending attachments from the command line. We will begin with the “mail” command.

MAIL

First run a quick test to make sure the “sendmail” application is installed and working correctly. Execute the following command, replacing “you@youremailid.com” with your e-mail address

# mail -s “Hello world” you@youremailid.com

Hit the return key and you will come to a new line. Enter the text “This is a test from my server”. Follow up the text by hitting the return key again. Then hit the key combination of Control+D to continue. The command prompt will ask you if you want to mark a copy of the mail to any other address, hit Control+D again. Check your mailbox. This command will send out a mail to the email id mentioned with the subject, “Hello world”.

To add content to the body of the mail while running the command you can use the following options. If you want to add text on your own:

# echo “This will go into the body of the mail.” | mail -s “Hello world” you@youremailid.com

And if you want mail to read the content from a file:

# mail -s “Hello world” you@youremailid.com < /home/calvin/application.log

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 “Welcome to the world of Calvin n Hobbes” | mail -s “Hello world” calvin@cnh.com -c hobbes@cnh.com -b susie.derkins@cnh.com

 

Categories: Linux | Tags: command line, Linux, sendmail

Logon failure: unknown username or bad password.” when trying to access Windows XP share from Windows 7

Posted on October 8, 2011 by Muhamamd Zeeshan
9 comments

After a recent Windows Update I could no longer access the folders on my Windows XP file server. A window popped up asking for a username and password even though they are both the same on the two computers. The error message each time was “Logon failure: unknown username or bad password.”

I typed in my username and password five times. It reached the point where I thought I had gone crazy and was typing in the wrong one: it kept on coming back to me with the dreaded “Logon failure: unknown username or bad password.”.

I quickly returned to my senses and guessed something was up with the authentication between XP and Windows 7. A few Google searches later I found out that a Local Security Policy needs changing.

  • Open the Start menu
  • Type “Local Security Policy” in the search box
  • Open Local Security Policy
  • Navigate to “Local Policies” -> “Security Options” and then locate the entry named “Network security: LAN Manager authentication level”. Double click on it.
  • In the dropdown list choose “Send LM & NTLM – use NTLMv2 session security if negotiated
  • Click OK

It seems that a recent Windows Update has changed that policy’s settings to be undefined, which —from what I can tell— forces NTLMv2 session security always. My XP installation mustn’t have NTLMv2 capability and that is why I kept seeing “Logon failure: unknown username or bad password.” errors.

After changing the local policy I was immediately able to connect to my network shares again.

Categories: Windows | Tags: bad username password, windows, windows 7, windows xp

HowTo: Add Jobs To cron Under Linux or UNIX?

Posted on October 8, 2011 by Muhamamd Zeeshan
10 comments

Cron job are used to schedule commands to be executed periodically. You can setup setup commands or scripts, which will repeatedly run at a set time. Cron is one of the most useful tool in Linux or UNIX like operating systems. The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, /etc/cron.*/ directories. It also checks the /var/spool/cron/ directory.

crontab is the command used to install, deinstall or list the tables (cron configuration file) used to drive the cron daemon in Vixie Cron. Each user can have their own crontab file, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. You need to use crontab command for editing or setting up your own cron jobs.

Different Types of cron Configuration

There are two different types of configuration files:

  1. The UNIX / Linux system crontab : Usually, used by system services and critical jobs that requires root like privileges. The sixth field (see below for field description) is the name of a user for the command to run as. This gives the system crontab the ability to run commands as any user.
  2. The user crontabs: User can installer their own jobs using the crontab command. The sixth field is the command to run, and all commands run as the user who created the crontab

How Do I Install / Create / Edit My Own Cronjobs?

To edit your crontab file, type the following command at the UNIX / Linux shell prompt:

$ crontab -e

Syntax of crontab (Field Description)

Your cron job looks as follows for user jobs:

1 2 3 4 5 /path/to/command arg1 arg2

OR
1 2 3 4 5 /root/backup.sh

Where,

  • 1: Minute (0-59)
  • 2: Hours (0-23)
  • 3: Day (0-31)
  • 4: Month (0-12 [12 == December])
  • 5: Day of the week(0-7 [7 or 0 == sunday])
  • /path/to/command – Script or command name to schedule

Easy to remember format:

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

Your cron job looks as follows for system jobs:

1 2 3 4 5 USERNAME /path/to/command arg1 arg2

Example: Install Backup Job Script

If you wished to have a script named /root/backup.sh run every day at 3am, your crontab entry would look like as follows. First, install your cronjob by running the following command:

# crontab -e Append the following entry: 0 3 * * * /root/backup.sh 

Save and close the file.

Categories: Linux | Tags: cron job, cron tab, Linux
  • Recent Posts

    • Samsung Galaxy S7 rumor roundup: price, release date, features, specs
    • How to Root any LG Mobile
    • How To Record Ptcl Smart TV(iPtv) channels on PC
    • How to change the interface metric from GUI?
    • What’s the recommended way to enable / disable services in Ubuntu?
  • Categories

    • Android
    • Android_News
    • Android_Root
    • CCNA urdu
    • Cisco
    • internet
    • iptv
    • ipv6
    • Linux
    • Networking
    • Oracle
    • perl
    • PHP
    • Proxy
    • ptcl smarttv
    • Ubuntu
    • unblock
    • Uncategorized
    • urdu_tutorials
    • Windows
  • Tags

    bad username password ccna centos cisco command line configuration register cpan cron job cron tab dbd facebook get ipv6 free internet iptv ipv6 iso image ithut.net line attenuation Linux Linux Laptop mode mount iso networking oracle perl php proxy ptcl ptcl smart tv rhel sendmail smarttv snr margin squid Tutorials ubuntu unblock facebook unblock youtube urdu Urdu Tutorials utdu windows windows 7 windows xp youtube zee.im
zee.im ithut.net