Wednesday, December 17, 2008

Code signing process

Code signing is a process to digitally sign your product, which verifies the publisher of downloads and check that they have not been infected by a virus since they were created. It is Industry wide professional practice to sign the products which they are selling. Now a days most of the customers restrict downloading an unsigned product. So sign your code to keep up your reputation in delivering genuine software's.

To code sign you need following
1) Digital certificate (along with password)
2) Code signing tools
3) URL of a time stamping server

Digital certificate: You can create your own digital certificate's just for trying out signing process. But to do it professionally, you need to buy certificate's from trusted certification authorities like Comodo, Globalsign, Thawte and Verisign.

Code signing tools: Microsoft provides code signing tools like signcode.exe (comes along with Microsoft .NET Framework Software Development Kit) and signtool.exe ( along with Microsoft Visual Studio 2005).

URL of a time stamping server: s the URL of a time stamping server. This may be one of the following:
- http://timestamp.verisign.com/scripts/timstamp.dll
- http://timestamp.globalsign.com/scripts/timstamp.dll
- http://timestamp.comodoca.com/authenticode

Here is an example of code signing process using signtool.exe.

C:\p4clients\sign\tools> signtool.exe sign /f your-pfx-file /p password /t http://timestamp.verisign.com/scripts/timstamp.dll /v file-to-sign

Here is the Sample Output:
The following certificate was selected:
Issued to: SID Software Inc.
Issued by: Thawte Code Signing CA
Expires: 10/16/2011 2:17:15 AM
SHA1 hash: 4374SD894388B9H456E206124G06D9AV1535G12E

Done Adding Additional Store

Attempting to sign: jservice.exe
Successfully signed and timestamped: jservice.exe

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0


As you can see signtool.exe needs a certificate in the form .pfx. Here is the procedure to create it.
Open a command prompt in the folder containing the code signing tools, and type:
>> makecert.exe -sv mykey.pvk -n "CN=Acme Software Inc." mycert.cer

You can substitute your own business name for "Acme Software Inc." If the file mykey.pvk does not already exist, you will be prompted to enter a password for the private key file. The password may be blank.

On completion of this command you should have two files, mykey.pvk and mycert.cer. Now you need to convert the digital certificate into the Software Publisher Certificate (.spc) format. To do this, type:
 >>  cert2spc.exe mycert.cer mycert.spc

You will be prompted to enter the password for the private key file.
(Hopefully, you haven't forgotten it already!) When the program
finishes you should have a new file, mycert.spc. Only the two files mykey.pvk and mycert.spc will be used when signing your code.

If you are using the signtool.exe from Microsoft Visual Studio 2005 or
later or the Platform SDK, then you must first import your private key
and software publisher certificate into a single PFX file. This is a
one-off process that need only be repeated whenever you renew your code
signing certificate. Open a command prompt and type:
>> pvk2pfx.exe -pvk mykey.pvk -pi -spc mycert.spc -pfx mycert.pfx -po
replacing with your private key password. If you used
a blank password when you created your private key file then you can
omit the -pi


Refer link http://www.tech-pro.net/code-signing-for-developers.html for detail explanation about code signing.



Tuesday, December 16, 2008

RPM usage

Let me show you how to create a simple RPM package.

Let me brief about few important rpm options.

INSTALL OPTIONS
1) How to install a rpm package?
rpm -ivh epm-3.5.1-1.i386.rpm

-i : Insists RPM to install
-v : verbose
-h : print # as install progess

2) How to get more verbose information?
rpm -i
vv epm-3.5.1-1.i386.rpm

3) --test: Perform installation test only
rpm -i --test epm-3.5.1-1.i386.rpm
rpm doesn't install the package, instead performs all the checks that RPM does during an install. RPM will return a non-zero status if the --test option detects problems…

4) --replacepkgs: Install the Package Even If Already Installed
rpm -ivh --replacepkgs epm-3.5.1-1.i386.rpm
This option is used to force RPM to install a package that it believes to be installed already.

5) Force full installation with "--force" option
rpm -ivh
--force epm-3.5.1-1.i386.rpm
Here is one situation where you end up using --force option. Assume a previously installed package is deleted manually by a mischievous person. When you try to install it again by just calling "rpm -i *.rpm". It will end up with the message "package epm-3.5.1-1 is already installed". In this situation you can use either --force option or --replacepkgs option.

6) Installing from URL's
rpm -i ftp://ftp.gnomovision.com/pub/rpms/foobar-1.0-1.i386.rpm
Specifying username for FTP site

rpm -i ftp://smith@ftp.gnomovision.com/pub/rpms/apmd-2.4-1.i386.rpm
  Password for smith@ftp.gnomovision.com: ??

7) Installing package even if dependent packages are not available on system
 rpm -i --nodeps blather-7.9-1.i386.rpm
The --nodeps options to an install command directs RPM to ignore any
dependency-related problems and to complete the package installation.


8) Avoiding docs getting installed
rpm -iv --excludedocs cdp-0.33-3.i386.rpm
Also there is an option --includedocs which directs RPM to install any files marked as
being documentation.

9) Installing package on path of our choice
rpm -i --prefix /tmp/test cdplayer-1.0-1.i386.rpm
--prefix gives the person installing the package flexibility in determining where on
their system they should be installed.

10) --noscripts: Do Not Execute Pre- and Post-install
Scripts

11) --percent
RPM displays a series of numbers. Each number is a percentage that indicates how far along the
install is. When the number reaches 100%, the installation is complete.
rpm -i --percent iBCS-1.2-3.i386.rpm

12) --rcfile : Use As An Alternate rpmrc File
The --rcfile option is used to specify a file containing default settings for RPM. By default, RPM uses /etc/rpmrc and a file named .rpmrc located in your login directory.

13) --root : Use As An Alternate Root
Adding --root to an install command forces RPM to assume that the directory specified by is actually the "root" directory. The --root option affects every aspect of the install process, so pre- and post-install scripts are run with as their root directory.

14) --dbpath : Use To Find RPM Database
Normally, RPM database exists in the directory specified by the rpmrc file entry, dbpath. By default, dbpath is set to /var/lib/rpm.

15) --ftpport : Use In FTP-based Installs

16) --ftpproxy : Use As Proxy In FTP-based Installs

17) --ignorearch: Do Not Verify Package Architecture
When a package file is created, RPM specifies the architecture, or type of computer hardware, for which the package was created. This is a good thing, as the architecture is one of the main factors in determining whether a package written for one computer is going to be compatible with another computer.

The --ignorearch option will not perform any architecture-related checking.

18) --ignoreos: Do Not Verify Package Operating System
When a package file is created, RPM specifies the operating system for which the package was created. This is a good thing as the operating system is one of the main factors in determining whether a package written for one computer is going to be compatible with another computer.

The --ignoreos option will not perform any operating system-related checking.

19) --replacefiles: Install the Package Even If It Replaces Another Package’s Files
rpm -iv --replacefiles cdp-0.33-3.i386.rpm

ERASE OPTIONS
1) How to un-install a package?
rpm -ev eject 
 -e: erase
-v: verbose

To get even more verbose information
rpm -evv eject

By adding -vv to the command line, we can often get a better feel for what’s going on inside RPM.

By default RPM wouldn’t erase the package if there are dependencies for this package.


2) --test: Go through the process of erasing the package, but do not erase it
rpm -e --test bother
It will show if any files needed by other packages getting deleted if we erase this package.

3) --nodeps: do not check dependencies before erasing package
rpm -e --nodeps bother
Adding the --nodeps options to an erase command directs RPM to ignore any dependency-related problems, and to erase the package.

4) --noscripts: do not execute Pre- and Post-uninstall scripts 

5) --rcfile : Read for RPM Defaults
The --rcfile option is used to specify a file containing default settings for RPM. By default, RPM uses /etc/rpmrc and a file named .rpmrc located in your login directory.

6) --root : Use as the root
Adding --root to an un-install command forces RPM to assume that the directory specified by is actually the "root" directory. The --root option affects every aspect of the install process, so pre- and post-install scripts are run with as their root directory

7) --dbpath : Use to find RPM Database
Normally, database exists in the directory specified by the rpmrc file entry, dbpath. By default, dbpath is set to /var/lib/rpm.

8) rpm -e and Config files
If you’ve made changes to a configuration file that was originally installed by RPM, your changes won’t be lost if you erase the package. Say, for example, that we’ve made changes to /etc/skel/.bashrc (a config file), which was installed as part of the etcskel package. Later, we remove etcskel, .bashrc.rpmsave a copy of your modified .bashrc file will be created during un-install.

UPGRADE OPTIONS
1) How to upgrade a already installed package?
rpm -U eject-1.2-2.i386.rpm
If a package not installed at all early, then -U option works similar to -i (install) option.

Given the fact that rpm -U can be used as a replacement to rpm -i, it follows that
most of the options available for rpm -U are identical to those used with rpm -i.

URLs can also be used to specify the package file.

2)  --oldpackage: Upgrade to an older version
rpm -Uv --oldpackage cdp-0.33-2.i386.rpm

3) --force: Forceful up-gradation
It adds --replacepkgs, --replacefiles, and --oldpackage to the command. The only thing that will prevent a --force’ed upgrade from proceeding is a dependency conflict.

4) --noscripts: Do not execute Install and Uninstall Scripts

QUERY OPTIONS
Format: rpm -q   <information-selection>
Where Package name can be
  -
7) How to view content of RPM package using RPM command?
rpm -q -filesbypkg -p filename.rpm (or similar)
where --filesbypkg means "List all the files in each selected package."

Sunday, December 7, 2008

sudo configuration

Need to edit /etc/sudoers file.
use visudo command to edit this file.

# User privilege specification
root ALL=(ALL) ALL
build ALL=(ALL) NOPASSWD: ALL

Thursday, December 4, 2008

Perforce - can't edit exclusive file already opened

In perforce, whenever a binary file like doc, xls or ppt files are checked out, it is opened in exclusive lock mode. So no other person can check-out that file until the current person who checked-out submit(check-in) it. But there is a way to check-out binary files in these scenario

Check out your binary file as shown below
p4 edit -t binary //knowledgebase/ctweb/main/releases/AXM/Server/Moneypenny/Dev/moneypenny_code_review.xls

-t binary option will allow you to check-out binary file even it is locked. After your modification, you can check it back in without any issues

How to know a Unix/Linux system is a 32/64 bit architecture?

To know whether given Unix/Linux machine is of type 32/64 bit architecure, use the command

getconf LONG_BIT

It outputs correspondingly 32 or 64 bit.

For AIX machine use "bootinfo -K" command for same purpose

Reference: http://www.unixguide.net/unixguide.shtml

Wednesday, December 3, 2008

How to know architecture of a AIX machine?

We can easily know the architecture type in Linux or Solaris systems with the help of "uname" command. But uname command in AIX don't give relevant information. To know the architecture (PowerPC, rs6000) of your AIX machine, use the following commands.

1) First know the processor characterstics by typing
[root@re-aix02:/] lsdev -Cc processor
proc0 Available 00-00 Processor
From this you know your processor is on "proc0 or proc1"

2) Using the information obtained from 1), know the attribute characteristics for processor
[root@re-aix02:/] lsattr -E -l proc0
state enable Processor state False
type PowerPC_POWER4 Processor type False
frequency 1200000000 Processor Speed False

The second line in output tells about processor architecture.

Tuesday, November 18, 2008

Not able to open C drive on double click

Are you not able to open C drive or any other drive when you double click on Hard disk drives? This is caused due to Virus attack. And possible other problem related to this is unable to display hidden files.
Anyways nothing to worry. This can be corrected, follow these steps
1) Open command prompt i.e start -> run -> and type "cmd"
2) cd\
3) attrib -r -h -s autorun.inf
4) del autorun.inf
5) Repeat this for other drives like d:, e: etc

Reboot your system, your problem will be solved.

Thursday, November 13, 2008

“No licenses available. Contact your program supplier to add additional users. Compilation will proceed shortly.”

In AIX, the IBM c/c++ compiler xlc_r which gives the following licensing warning

“No licenses available. Contact your program supplier to add additional users. Compilation will proceed shortly.”

which considerably slows down the build process. This can be avoided by modifying /etc/vac.cfg file. Since license manager is optional, check out for "options", near the end, in DEFLT for xlc_r. Then add -qnolm option if it is not already exist, which means "no license manager".

Tuesday, November 11, 2008

Splitting columns in Perl

Splitting columns or fields is one of the most common tasks. Among the many ways to split columns in perl, the best and the simplest way is
Suppose if we want to split 4th field, where the field separator is tab
while() {
chomp;
my $var=(split /\t+/)[3];
}

Tuesday, October 7, 2008

SSH password less log-in problem

Machine1: re-solx86 (A Solaris x86 machine)
Machine2: vm-rh21-lager (A RHEL machine)

Requirement: Need to establish a password less login from Machine2 -> machine1

Solution:
Login machine1 -> machine2
1) Created RSA keys by running command "ssh-keygen -t rsa" on Machine1
2) Added content of "id_rsa.pub" file from machine1 to the file "authorized_keys" in machine2
Login from machine1 -> machine2 is success

Login machine2 -> machine1
1) Added
content of "id_rsa.pub" file from machine2 to a file "authorized_keys" in machine1
Login from machine2 -> machine1 still asking for password.

Problem: Permissions of ~/.ssh directory in machine1 is 755. ssh won't work if permission of ~/.ssh is other than 700.
Solution: Changed permission of
~/.ssh to 700, now it is successful






Tuesday, September 2, 2008

ESP package manager

EPM (ESP package manager), is the second package manager, which I used. In my previous organization Synopsys, I used Synopsys Installer, which is an internal package management tool used only in Synopsys. But it is good to know EPM is a free package manager developed by Easy software products.

The design goal of EPM is to solve the problem of software distribution with Unix/Linux OS. The problem is every OS supports it's own packaging tools and each has unique requirements for the software development environment. EPM provides solution to this problem by providing it's own portable distribution format and also vendor specific formats like rpm, depot, dpkg, pkgadd, etc. This allows you to build software distribution files for any OS from the same sources.

You can download EPM from http://www.epmhome.org/ and the EPM book at http://www.epmhome.org/documentation.php teaches you how to use EPM.

EPM requires few pre-installed softwares. They are C compiler, make utility, Bourne (or Korn or bash) shell and gzip. The optional Graphical setup program requires a C++ compiler, FLTK library. End user systems require Bourne shell, df, tar & gzip utilities to install portable distributions.

Basically EPM reads one or more software list files that describe a single software package. These list files needs to be written in specific format, Chapter 3 of EPM book explains it in detail.

To build a software package, epm program is used. For example to build a portable software package for an application called foo, type the following command
epm foo
This expects a list file by name foo.list. If your list file is created with different name, then you can mention the list file name by command line argument as
epm foo base.list

You can install the portable packages by calling an installation script product.install where product is the name of the package.
cd os-release-arch
./product.install
After answering few yes/no questions, product will be installed.

To create vendor specific packages use -f option
epm -f rpm foo base.list

EPM also supports preinstall, postinstall, prepatch, postpatch, preremove & postremove scripts. These scripts are bourne shell scripts, needs to be called from list file
It also supports init scripts and also patch software distributions.

For detailed usage refer EPM book at http://www.epmhome.org/documentation.php

Enjoy building software packages with EPM ..... :)

Sunday, July 27, 2008

HP UX start/stop/restart sshd service

To start/stop sshd service, you must use "root" account"

System startup configuration file

/etc/rc.config.d/sshd

Stop HP UX SSH Service

/sbin/init.d/secsh stop

Start HP UX SSH Service

/sbin/init.d/secsh start


If /sbin/init.d/secsh is not found, you can try the following if found

/sbin/init.d/S91sshd start

Thursday, July 17, 2008

Unix Operating System Name Abbreviations and Processor Architecture Abbreviations

Operating System Name Abbreviations
Operating SystemName
AIXaix
Compaq Tru64 UNIX
Digital UNIX
OSF/1
tru64
FreeBSDfreebsd
HP-UXhpux
IRIXirix
Linuxlinux
MacOS Xmacosx
NetBSDnetbsd
OpenBSDopenbsd
Solarissolaris


Processor Architecture Abbreviations
Processor(s)Abbreviation
Compaq Alphaalpha
HP Precision Architecturehppa
INTEL 80x86intel
INTEL 80x86 w/64bit Extensionsx86_64
MIPS RISCmips
IBM Power PCpowerpc
SPARC
MicroSPARC
UltraSPARC
sparc




Wednesday, July 16, 2008

Software Packaging Formats

Software Packaging Formats (Reference - s/w distribution using ESP)
In Unix there are many open source packaging systems, it is always better to have a list and to compare among them.
FormatOperating Systems1Binaries Cross- PlatformPatches Up- gradesCon- flictsRe- quires Re- placesConfig FilesMap FilesUn- install
installp AIXYes NoNo NoYes YesNo NoNo Yes
pkg_add FreeBSDYes Yes2NoNoNo No NoNo NoYes
pkg_add NetBSD
OpenBSD
Yes Yes2NoNoYes Yes NoNo NoYes
dpkg Corel Linux
Debian GNU/Linux
YesYes2 NoYes YesYes YesYes NoYes
depot HP-UXYes NoYes YesYes YesNo YesYes Yes
inst IRIXYes NoYes YesYes YesYes YesYes Yes
Install.app MacOS XYes NoNo YesNo NoNo NoNo No
pkgadd SolarisYes NoYes NoYes YesNo YesYes Yes
rpm Mandrake
Red Hat
SuSE
TurboLinux
YesYes2 NoYes YesYes NoYes NoYes
setld Tru64 UNIXYes NoNo NoYes YesNo NoNo Yes
slackware Slackware LinuxYesNoNo No YesYes NoNo NoYes

Friday, July 11, 2008

Wednesday, July 9, 2008

How to install Perl modules

For example to install Mail::Mailer module, you can use below
command

perl -MCPAN -e 'install Mail::Mailer'

Also refer http://www.cpan.org/modules/INSTALL.html for another
approach

Offline Installation of Perl module
perl Makefile.PL
make
make test
make install 

How do I find out what modules are already installed on my system?

Each time a module is installed on your system, it appends information like the following to a file called perllocal.pod which can be found in /usr/local/lib/perl5/version number/architecture/ or something akin to that. The path for your specific installation is in your @INC which you can divine with perl -V.
=head2 Wed May 12 13:42:53 1999: C L
=over 4
=item *
C
=item *
C
=item *
C
=item *
C
=back

Each entry includes the Module name, date and time it was installed, where it was installed, linktype [ static or dynamic ], version and executables, if any, included with the module.

Another way to do this is http://vijayk.blogspot.com/2008/06/list-all-installed-perl-modules.html

Monday, July 7, 2008

Perforce commands FAQ

1) How to delete a Perforce client?
p4 client -d

2) How to copy named template's view to current client?
p4 client -t

3) What is the use of P4CONFIG environment variable?
You can define Perforce environment variables in this configuration file. Place this file in your client root or even top-level directory. Perforce will fetch values from this configuration file.
For Ex: setenv P4CONFIG .p4config
cd $P4ROOT
vi .p4config
P4PORT=localhost:1666
P4CLIENT=client1

4) How to retrieve a file revision from Perforce depot?
p4 print -q //depot/source/proj1/test.c#5 > test.c

5) How to add the entire directory to Perforce?
find . -type f|p4 -x- add
find . -type l|p4 -x- add -t symlink

6) How to check who all working(opened) on a given file?
p4 opened -a

7) How to list opened files that are different than the revision in the depot or missing?
p4 diff -sa

8) Listing unopened files that are missing on the client
p4 diff -sd

9) Listing unopened files that are different from the revision in the depot
p4 diff -se

10) Listing opened files that are same as the revision in the depot
p4 diff -sr

11) How to revert all files opened for edit but have unchanged content?
p4 revert -a

12) Locking an opened file against submission
p4 lock file-name
To unlock
p4 unlock file-name

13) How to list the differences between the 2 branches?
p4 diff -q //depot/main/jam/... //depot/rel1/jam/...

14) Deleting and re-adding files
% p4 delete file.txt
//depot/src/file.txt#33 - opened for delete
% p4 submit
Delete //depot/src/file.txt#34
Change 145 submitted
% p4 sync file.txt#33
% p4 add file.txt
%p4 submit
Add //depot/src/file.txt#35
Change 146 submitted

Tuesday, July 1, 2008

Automatic Variables in Makefiles

Automatic variables in Makefiles (make/gmake)
$@: The filename representing the target
$%: The filename element of an archive member specification
$<: The filename of the first prerequisite
$?: The names of all prerequisite that are newer than the target, separated by spaces
$^: The filenames of all the prerequisite's, separated by spaces. (Without duplicates)
$+: Same as $^, except that it includes duplicates
$*: The stem of target filename. A stem is typically a filename without it's suffix.

User defined variables
*) A variable name can contain any characters including spaces except # and =.
*) Case sensitive
*) To get the value of a variable, enclose the variable name in $(). Single-letter variable can omit parenthesis
*) Variables can also be expanded using curly braces as in ${CC}
*) The value of a variable consists of all the words to the right of the assignment symbol with leading space trimmed. Trailing spaces are not trimmed

Perl Hobby Scripts

A. Simple

1. Write a Perl script to find and print the longest word in a text file.

2. Implement proactive password checker, means allow a person to enter his password, check for following conditions

- Password should be at least 8 characters in length

- It should contain alphanumeric, upper & lowercase letters

- It should contain any of these special characters @, $ and #.

Solutions


#!/usr/bin/perl -w

#Write a Perl script to find and print the longest word in a text file.

#Importing packages

use strict;

use Getopt::Long;

#Global variables

my ($help, $file);

#Processing command line arguments

GetOptions("h"=>\$help,

"f=s"=>\$file,

);

if($help) {

usage();

}

#Check for -f option

if(!defined($file)){

print "ERROR: -f option is compulsory\n";

usage();

}

open(FH, "$file") || die "Error: Can't open $file: $!";

my ($len,$word,@line,$element);

my $largest=0;

foreach()

{

@line=split(/\s+/,$_);

foreach $element (@line)

{

$len=length($element);

if($len > $largest) {

$largest=$len;

$word=$element;

}

}

}

print "Largest word length is: $largest and the word is $word\n";

sub usage

{

print "USAGE: $0 -f \n";

exit(1);

}

2.

#!/usr/bin/perl -w

## Proactive password checker ##########

use strict;

use Term::ReadKey;

my $user=`whoami`; chomp($user);

print "Hello $user ..\n";

my $try=0;

my $passwd;

accept_password();

sub accept_password

{

$try++;

if($try <= 3)

{

print "Enter your password\n";

ReadMode 'noecho';

$passwd=ReadLine 0;chomp($passwd);

ReadMode 'normal';

check_passwd();

}else

{

print "You exceeded maximum attempts\n";

exit(1);

}

}

sub check_passwd

{

#Check if password length is atleast 8

if(length($passwd) <>

{

print "ERROR: Your password length is less than 8\n";

print "PASSWORD REJECTED\n";

accept_password();

}

#Check for digit

if($passwd =~ /[0-9]/) {

}else{

print "ERROR: No digit in your password\n";

print "PASSWORD REJECTED\n";

accept_password();

}

#Check for lowercase letter

if($passwd =~ /[a-z]/) {

}else{

print "ERROR: No lowercase letter in your password\n";

print "PASSWORD REJECTED\n";

accept_password();

}

#Check for Uppercase letter

if($passwd =~ /[A-Z]/) {

}else{

print "ERROR: No Uppercase letter in your password\n";

print "PASSWORD REJECTED\n";

accept_password();

}

#Check for special characters

#if(($passwd =~ /\@/)|| ($passwd =~ /#/) || ($passwd =~ /\$/)){

if( ($passwd =~ /\@/) || ($passwd =~ /\$/) || ($passwd =~ /\#/) ){

}else{

print "ERROR: No special characters \@ # \$\n";

print "PASSWORD REJECTED\n";

accept_password();

}

}

print "PASSWORD ACCEPTED\n";

Thursday, June 26, 2008

Beginning Perforce

  • What is Perforce?
Perforce means "By necessity; by force of circumstance". Now every software organization necessarily need a Source control tool, perforce is one among them. Perforce provides a force to manage the source code efficiently and effectively.

  • Want to play with Perforce? Download
Download a free 2 user Perforce server from http://www.perforce.com/perforce/loadprog.html. To play around, a Perforce server "p4d" and a Perforce client "p4" is required on Unix platforms or you can download p4win for windows, which is GUI based includes P4, P4D and P4P.
P4P is perforce proxy. P4V is mainly used as GUI client in UNIX machines, but it can also be used in Windows.
  • How to start a Perforce Server?
In Unix:
mkdir $HOME/p4bin. Put P4, P4d and P4V to here and add this directory to your path
mkdir $HOME/p4server
mkdir $HOME/p4workspace
Make the programs in $HOME/p4bin executable

Starting the Perforce server:
p4d -d -p 1666 -r $HOME/p4server
where -d suggests to run server as daemon
-p tells port number
-r set server root directory

In Windows:
Install p4win
Start Perforce server p4d.exe as
./p4d.exe -d -q -p 1777 -r . -L ./log &
where -q suggests quiet (suppress start up messages)
-L sets error Log

  • Terminologies used in Perforce
Depot: Repository for source files and Metadata.
Client: Your private workspace to download files from Depot and to play with it
Sync: Get code from depot to client
Edit: Check out
Submit: Check in

  • Creating a Perforce client
Perforce client is your own private work space to sync the depot code