Introduction
Perl is a interpreted language. It is almost available in all popular operating systems today. Perl will be similar to C language and awk.

Basics

  • Perl script file mostly will have the extension .pl
  • In unix and Linux flavours, the perl file should have an execution permission.
  • Start the perl script file with #!/usr/bin/perl
  • Dont forget to terminate perl commands with ; (semicolen). eg., print “Hello world\n”;

program 1

Always the first program I try on any language is hello world, so perl’s hello world program is here for Linux and UNIX flavours,

#!/usr/bin/perl
print "Hello world.\n";

In Windows the same program will look like,

#!D:/perl/perl.exe
print "Hello world.\n";
  • The first line (in both examples) is a comment for perl, but for shell it tells which interpriter in what path to use on the file.
  • The second command print is similar to printf in C language with some difference. Lets learn the difference later.

Output

perl_hello_world

Share
Tagged with:
 



usermod — Modify a user account

Summary

The usermod command modifies the system account files to reflect the
changes that are specified, like Home dir, password, etc. on the
command line

Example

# usermod -d /home2/usr1 usr1 – Create the new home Dir for usr1 in
                          /home2 & Move old Dir contents to this Dir.

# usermod -e 2009-04-30 usr1 – From 30/4/2005 the usr1 acc will be
                                disabled.

# usermod -f 6 usr1 – After passwd expires, system will allow the
        user to login for 6 days with a warning to change his passwd.

# usermod -g prof usr1 – Set usr1′s initial group as prof.

# usermod -p $1$d8 usr1 – Set the new passwd for the usr1

# usermod -s /bin/bash usr1 – Set Bash as the default login shell for
                               the usr1.

# usermod -L usr1 – Lock a user’s password.

# usermod -U usr1 – Unlock a user’s password.

Share
Tagged with:
 



useradd – Create a new user.

Summary

useradd creates a new user with specified options like username, home
dir, group details, password, etc …

Example

# useradd usr1 — Add new user usr1 with default settings.

# useradd usr1 -d /home2/usr1 – Create the new user’s home dir in
                                 /home2

# useradd usr1 -e 2009-04-30 — From 30/4/2009 the user acc will be
                                disabled.

# useradd usr1 -f 6 – After passwd expires, system will allow the
                       user to login for 6 days with a warning to
                       change his passwd.

# useradd usr1 -g staff -G student,lect, prof – Set his initial group
                 as staff and sublimentry group as office, lect, prof.

# useradd usr1 -p $1$d8 — Create the usr1 with the given encrypted
                           password. For No passwd, acc disabled.

# useradd usr1 -s /bin/csh – Set C Shell as the default login
                              shell for the usr1.

Share
Tagged with: