Fedora Linux add MP3, Java, DVD Playback and multimedia support

Posted on in Categories Download of the day, Howto, Linux, Linux desktop, Linux distribution, RedHat/Fedora Linux last updated September 3, 2007

Copyright/IP laws prevent shipping multimedia and mp3 software(s) and technologies/plugins with Linux distribution. Fedora is no exception to this rule. All you have to do is add few repos and you are ready to go.

Fellow Linux blogger James has published an excellent shell script hack (Fedora Feather) that adds MP3 and multimedia support to Fedora Linux:

Tired of manually adding support for mp3, dvd and Java to your fresh Fedora installs? This script will automatically do all of that.

=> Download Fedora Feather

Book Review Shell Script Pearls

Posted on in Categories Book Review, Shell scripting last updated September 3, 2007

Shell Script Pearls is designed to provide information about shell scripting. The book is collection with all tips and code sample you need to learn about shell scripting. Author has clearly demonstrated unique tools and script samples that go beyond the level of basic scripting. The book is useful for geeks, hackers, sys admin and advanced users. The book doesn’t explain basic programming structure and syntax. If you are the beginner get some basic book or start with our own tutorial.

You will find lots of useful collection of a shell scripts and practical examples that can be used in day today life.

Chapter 1: Shell script Debugging – You learn about manual and automated shell scripting debug techniques.

Book Review: Shell Script Pearls

Chapter 2: Standard Functions Library – You will learn how to create a library for common task.

Chapter 3: Date and time Manipulation – Many administrative tasks such as backup heavily depends upon date and time. This chapter explains date and time calculations.

Chapter 4: Comparison and tests – Learn how to write and use the comparison and test using conditional statements and loops.

Chapter 5: Accepting Command Line Options and Parameters – Learn how to pass optional parameters to you script to provide more customization.

Chapter 6: Testing Variables and Assigning Defaults – Learn about setting default variables or input parameters for a script. This will help you write customized and configurable shell script.

Chapter 7: Indirect Reference Variables – Learn how create indirect variable names (ability to generate variable names on fly)

Chapter 8: Shell process tree – You will learn about creating a shell process tree script for the currently running or all process.

Chapter 9: Data Redirection – If you get confused with output redirection or I/O redirection, this chapter provides the better understanding about redirection.

Chapter 10: Piping Input to read – Learn about pipes and related gotcha that came across while writing a portable script.

Chapter 11: Math from the shell – Learn how to use expr, bc and other tools to perform mathematical calculations from a shell.

Chapter 12: Cron – Learn how to create complex cron jobs and schedule jobs.
Chapter 13: Self-Linked Scripts – This is one my favorite technique – for example a shell script called backup can be called in several different names to make a backup to ftp server, tape or another server.

Chapter 14: Throttling Parallel Processes – Learn how to run a shell script more efficiently in large multi-user environments.

Chapter 15: Command Line Editing and History – Learn how to set various command line editing mode to save time.

Chapter 16: Scripting from the command line – Learn how to write quick and dirty one liners from a command prompt.

Chapter 17: Automating User Input with expect – Learn how to provide password / username and other parameters using expect tool.

Chapter 18: User Input Timeout – Learn how to write more advanced scripts. If the user doesn’t provide input in a specified time the script should continue running with a default input.

Chapter 19: Instant keyboard Response – Learn how to write a key press detection shell script. For example detect keys pressed by end user and take an action.

Chapter 20: Directory Copying – Learn how to copy all sort of files using various tools.

Chapter 21 and 22: A brief tour of the X Display environment – Learn basic usage of X windows system.

Chapter 23: Command line email attachments – Learn how to send emails from a command line.

Chapter 24: Text processing one – liners: Learn basic usage of common tools such as awk, expr, sed and many others.

Chapter 25: Editing Files in Place – Learn how to use ed to edit text file and perform search and replace operations.

Chapter 26 to 42 provides advanced code examples and techniques such as:

  • Reading variables from a flat text file
  • Automating ftp task
  • Automating email with procmail
  • Automating RCS
  • Writing a process management
  • Running process from inittab file
  • Password aging notification
  • System snapshots
  • Rotating log files etc

Summery

You will find shell man pages difficult to use and w/ examples. Ron has done good job explaining and providing valuable shell script code. You can use samples in your own projects. I recommend this book for every Linux / UNIX geek and System Administrator.

  • Book title: Shell Script Pearls (Paperback)
  • Author: Ron Peters
  • Publisher: 16 Ton Press
  • Pub Date: 11-May-2007
  • ISBN 10:0615141056
  • Pages: 320
  • Level of experience needed: Intermediate Linux / UNIX sys admin
  • Who will find useful: Linux/UNIX sys admin / Geeks
  • Additional goodies included (such as CDROM) …? : No
  • Ratings : 4/5
  • Purchase online @ Amazon

Domain Expiration Check Shell Script

Posted on in Categories Howto, Shell scripting, Tip of the day, Tips last updated August 21, 2007

I’ve already written about a shell script to check / monitor domain renew / expiration date here. Now I have modified matty’s domain-check script to support additional C/TLDs .in, .biz, .org and .info domains. I’ve also added 5 seconds delay to avoid whois server rejecting query. This script checks to see if a domain has expired. It can be run in interactive and batch mode, and provides facilities to alarm if a domain is about to expire in advance.

Sample usage

Display expiration date and registrar for theos.in domain:
$domain-check-2 -d {domain-name}
$ domain-check-2 -d theos.in

Sample outputs:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------
theos.in                            et4India (R7-AFIN Valid    28-Oct-2009   799  

You can also get an email if theos.in going to expire in 30 days
$ domain-check-2 -a -d theos.in -q -x 30 -e [email protected]

However most killer feature is you can read list of domain names from a file such as mydomains.txt (list each domain on a new line):
$ domain-check-2 -a -f mydomains.txt -q -x 30 -e [email protected]
OR
$ domain-check-2 -f mydomains.txt

Output:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------
theos.in                            et4India (R7-AFIN Valid    28-Oct-2009   799
nixcraft.org                        oDaddy.com, Inc.  Valid    13-Aug-2009   723
vivekgite.com                       MONIKER ONLINE SE Valid    18-aug-2010   1093
cyberciti.biz                                         Valid    30-Jun-2009   679
nixcraft.info                       oDaddy.com Inc. ( Valid    26-Jun-2009   675
nixcraft.net                        GODADDY.COM, INC. Valid    11-dec-2009   843  

Download

=> You can download modified domain-check-2 script here and an updated version is here too.

Quick installation

Use wget command to download and install domain-check script:
$ wget http://www.cyberciti.biz/files/scripts/domain-check-2.txt
$ mv domain-check-2.txt domain-check
$ chmod +x domain-check
$ ./domain-check -d vivekgite.com

Make sure your run domain-check script using a cron job.

Howto Use SSH To Run Command On A Remote Machine

Posted on in Categories Automation, CentOS, Debian Linux, FreeBSD, Gentoo Linux, High performance computing, Howto, Linux, Shell scripting, Sys admin, Tuning, Ubuntu Linux, UNIX last updated August 17, 2007

This article examined a simple, but powerful, method to run commands on a remote machine using combination of ssh and a shell script:

Use Secure Shell (SSH) to run commands on remote UNIX systems and, with some simple scripts, put together a system that enables you to manage many systems simultaneously from one machine without having to log in directly to the machines themselves. Also examine the basics of a distributed management system and some scripts and solutions using the technique.

I have already covered how to execute commands on multiple Linux or UNIX servers via a shell script. The disadvantage of shell script is commands do not run in parallel on all servers. However, several tools exist to automate this procedure in parallel. With the help of tool called tentakel (highly recommended) , you run distributed command execution. Also, you can execute commands on multiple Linux or UNIX servers using special tools such as multixterm from expect project.

=> Distributed administration using SSH

Linux display the date when a file was accessed with stat command

Posted on in Categories CentOS, Debian Linux, File system, Linux, RedHat/Fedora Linux, Ubuntu Linux last updated August 6, 2007

A quick question from my mail bag:

How do I display or get the date when a file was last time accessed?

The best and simplest way is to use stat command. It displays file or file system status such as:

=> File size

=> File type

=> Inode number

=> UID/GID

=> File access , modify and creation time etc.

stat command example

$ stat /etc/passwd
Output

  File: `/etc/passwd'
  Size: 2453            Blocks: 8          IO Block: 4096   regular file
Device: 806h/2054d      Inode: 25298826    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2007-08-06 04:45:18.000000000 -0500
Modify: 2007-07-17 16:25:12.000000000 -0500
Change: 2007-07-17 16:25:12.000000000 -0500

Display file system status

You can display file system status instead of file status. For example, display status for / file system:
$ stat -f /
Output:

  File: "/"
    ID: 0        Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 32161831   Free: 30458361   Available: 28798245
Inodes: Total: 33226752   Free: 33135357

stat command and shell scripts

You can use stat in a shell script. It supports -c option. By default it shows all information about file. Use -c option to specify FORMAT instead of the default. For example store access time in a shell variable:

ATIME=$(stat -c "%x" /etc/passwd)
echo $ATIME

See the stat command man page for full details for the valid format sequences for files:
man stat

How to stop a Linux job after a certain time

Posted on in Categories Howto, Linux, Shell scripting last updated August 2, 2007

This article explains – controlling the duration of scheduled jobs (at and cron jobs) under Linux using nice shell script tricks:

Say you need to debug a pesky problem by running some traces for 30 minutes at midnight, or you would just like to use your Linux system as an alarm clock. This tip helps you stop jobs, such as those started with the cron and at capabilities, after the jobs have run for a certain time, or when some other criteria are met.

Linux tip: Controlling the duration of scheduled jobs

nixCraft FAQ Roundup May 14, 2007

Posted on in Categories FAQ last updated May 14, 2007

Recently updated/posted Linux and UNIX FAQ (mostly useful to Linux/UNIX new administrators or users) :

Enjoy!

nixCraft FAQ Roundup May 06, 2007

Posted on in Categories FAQ last updated May 6, 2007

Recently updated/posted Linux and UNIX FAQ (mostly useful to Linux/UNIX new administrators or users) :

Enjoy!

nixCraft FAQ Roundup April 27, 2007

Posted on in Categories FAQ last updated April 27, 2007

Recently updated/posted Linux and UNIX FAQ (mostly useful to Linux/UNIX new administrators or users) :

Enjoy!

March 6, 2007 : nixCraft FAQ Roundup

Posted on in Categories FAQ last updated March 6, 2007

Recently updated/posted Linux and UNIX FAQ: