{"id":4588,"date":"2018-01-09T07:19:00","date_gmt":"2018-01-09T07:19:00","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4588"},"modified":"2018-09-28T12:00:48","modified_gmt":"2018-09-28T12:00:48","slug":"how-to-setup-p4-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-setup-p4-in-linux-unix\/","title":{"rendered":"How to Setup p4 in Linux \/ Unix"},"content":{"rendered":"<p><strong>How to Setup p4 in Linux \/ Unix<\/strong><br \/>\nWell many people have these questions to me that they are facing issues setting up p4 client in Linux or Unix. The Solution is pretty much straight forwards but sometimes we miss some of things which delay the setup process.<br \/>\nHere I have tried to points out these already available on Perforce Knowledge base site.<br \/>\n<strong>Download and Installations:<\/strong><\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\">1.<\/td>\n<td valign=\"bottom\"><a name=\"1073012\"><\/a>Download the\u00a0p4 executable file from the Perforce web site:<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1073221\"><\/a><a href=\"http:\/\/www.perforce.com\/perforce\/downloads\/index.html\" target=\"_window\" rel=\"noopener\">http:\/\/www.perforce.com\/perforce\/downloads\/index.html\u00a0<\/a><br \/>\n<a name=\"1067827\"><\/a>The Perforce client programs are typically downloaded to\u00a0\/usr\/local\/bin.<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\">2.<\/td>\n<td valign=\"bottom\"><a name=\"1066724\"><\/a>Make the\u00a0p4 file executable (chmod +x p4)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Perforce Configuration and Workspace Setting<\/strong><br \/>\n<strong>Method 1<\/strong><br \/>\n<strong>Using Config Files:<\/strong><br \/>\n<a name=\"1081891\"><\/a>Config files\u00a0are text files containing Perforce settings that are in effect for files in and below the directory where the config file resides. Config files are useful if you have multiple client workspaces on the same machine. By specifying the settings in config files, you avoid the inconvenience of changing system settings every time you want to work with a different work-space.<br \/>\n<a name=\"1081893\"><\/a>To use config files, you define the\u00a0P4CONFIG environment variable, specifying a file name (for example, .p4config). When you issue a command, Perforce searches the current working directory and its parent directories for the specified file and uses the settings it contains (unless the settings are overridden by command-line flags).<br \/>\nP4CONFIG = .p4config<br \/>\n<a name=\"1081894\"><\/a>Each setting in the file must be specified on its own line, using the following format:<br \/>\n<a name=\"1081895\"><\/a>setting=value<\/p>\n<p><a name=\"1081958\"><\/a>The following settings can be specified in a config file.<\/p>\n<table border=\"2\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\"><a name=\"1081898\"><\/a>Setting<\/td>\n<td valign=\"top\"><a name=\"1081900\"><\/a>Description<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081913\"><\/a>P4CLIENT<\/td>\n<td valign=\"top\"><a name=\"1081915\"><\/a>Name of the current client workspace.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081923\"><\/a>P4EDITOR<\/td>\n<td valign=\"top\"><a name=\"1081925\"><\/a>The editor invoked by those Perforce commands that use\u00a0forms.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081928\"><\/a>P4HOST<\/td>\n<td valign=\"top\"><a name=\"1081930\"><\/a>Hostname of the client workstation. Only useful if the\u00a0Host: field of the current client workspace has been set in the p4 client form.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081943\"><\/a>P4PASSWD<\/td>\n<td valign=\"top\"><a name=\"1081945\"><\/a>Supplies the current Perforce user&#8217;s password for any Perforce\u00a0client command.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081948\"><\/a>P4PORT<\/td>\n<td valign=\"top\"><a name=\"1081952\"><\/a>The host and port number of the Perforce server or proxy with\u00a0which to communicate.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1081955\"><\/a>P4USER<\/td>\n<td valign=\"top\"><a name=\"1081957\"><\/a>Current Perforce user name.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>For details about these settings, refer to the Perforce Command Reference.<\/p>\n<p><strong>Example:<\/strong>\u00a0<a name=\"1081960\"><\/a>Using config files to handle switching between two workspaces<br \/>\n<a name=\"1081961\"><\/a>Ona switches between two workspaces on the same machine. The first workspace is\u00a0ona-ash. It has a client root of \/tmp\/user\/ona and connects to the Perforce server at ida:1818. The second workspace is called ona-agave. Its client root is \/home\/ona\/p4-ona, and it uses the Perforce server at warhol:1666.<\/p>\n<p>Rama sets the P4CONFIG environment variable to .p4config. She creates a file called .p4config in \/tmp\/user\/rama containing the following text:<br \/>\n<a name=\"1081963\"><\/a>P4PORT=ida:1818<br \/>\nP4CLIENT=ona-ash<\/p>\n<p>She creates a second .p4config file in\/home\/rama\/p4-ona. It contains the following text:<br \/>\n<a name=\"1081965\"><\/a>P4PORT=warhol:1666<br \/>\nP4CLIENT=ona-agave<\/p>\n<p>Any work she does on files under \/tmp\/user\/rama is managed by the Perforce server at ida:1818 and work she does on files under \/home\/rama\/p4-ona is managed by the Perforce server at warhol:1666.<\/p>\n<p><strong>Method 2: Environment Variable Setting<\/strong><\/p>\n<p><a name=\"1083857\"><\/a>To configure server connection settings using environment variables, set\u00a0P4PORT to host:port, as in the following examples.<\/p>\n<table border=\"2\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\"><a name=\"1083860\"><\/a>If the server is running on<\/td>\n<td valign=\"top\"><a name=\"1083862\"><\/a>and is listening to port<\/td>\n<td valign=\"top\"><a name=\"1083864\"><\/a>set P4PORT to<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1083866\"><\/a>your computer<\/td>\n<td valign=\"top\"><a name=\"1083868\"><\/a>1666<\/td>\n<td valign=\"top\"><a name=\"1083870\"><\/a>localhost:1666<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\"><a name=\"1083872\"><\/a>perforce<\/td>\n<td valign=\"top\"><a name=\"1083874\"><\/a>1666<\/td>\n<td valign=\"top\"><a name=\"1083876\"><\/a>1666<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Example:<\/strong><br \/>\nexport P4PORT=X.X.X.X\\:1667<br \/>\nexport P4PASSWD=pass<br \/>\nexport P4USER=user<br \/>\nexport P4CLIENT=Sonar<br \/>\nexport PATH<\/p>\n<p><a name=\"1071378\"><\/a><strong>Defining client workspaces<\/strong><strong>\u00a0<\/strong><br \/>\n<a name=\"1067226\"><\/a>To define a client workspace:<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\">1.<\/td>\n<td valign=\"bottom\"><a name=\"1067322\"><\/a>Specify the workspace name by setting\u00a0P4CLIENT; for example, on a UNIX system:<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1071430\"><\/a>$ P4CLIENT=bruno_ws ; export P4CLIENT<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\">&nbsp;<\/p>\n<p>2.<\/td>\n<td valign=\"bottom\"><a name=\"1067301\"><\/a>Issue the\u00a0p4 client command.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1071435\"><\/a>Perforce displays the client specification form in your text editor.<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\">3.<\/td>\n<td valign=\"bottom\"><a name=\"1067302\"><\/a>Specify (at least the minimum) settings and save the specification.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1067242\"><\/a>The minimum settings you must specify to configure a client workspace are:<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\"><strong>\u00a0<\/strong><\/p>\n<p><strong>\u2022<\/strong><\/td>\n<td valign=\"bottom\"><a name=\"1067243\"><\/a><strong>Workspace name<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1067252\"><\/a>The workspace name defaults to the client machine&#8217;s hostname, but a client machine\u00a0can contain multiple workspaces. To specify the effective workspace, set P4CLIENT.<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"bottom\"><strong>\u2022<\/strong><\/td>\n<td valign=\"bottom\"><a name=\"1067244\"><\/a><strong>Client root<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"1067380\"><\/a>The client root is the top directory of your client workspace, where Perforce stores your\u00a0working copies of depot files. Be sure to set the client root, or you might inadvertently sync files to your client machine&#8217;s root directory.<\/p>\n<p><strong>Note:<\/strong><br \/>\nTo specify server settings on the command line, use the -p flag. For example:<br \/>\n<a name=\"1071025\"><\/a>p4 -p localhost:1776 sync \/\/depot\/dev\/main\/jam\/Jambase<\/p>\n<p><a name=\"1076616\"><\/a><\/p>\n<p><strong>Reference:<\/strong><br \/>\n<a href=\"http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/02_config.html#1069873\" target=\"_blank\" rel=\"noopener\"><strong>http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/02_config.html#1069873<\/strong><\/a><strong>\u00a0<\/strong><br \/>\n<a href=\"http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/02_config.html#1071378\" target=\"_blank\" rel=\"noopener\"><strong>http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/02_config.html#1071378<\/strong><\/a><strong>\u00a0<\/strong><br \/>\n<a href=\"http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/01_install.html#1070774\" target=\"_blank\" rel=\"noopener\"><strong>http:\/\/www.perforce.com\/perforce\/doc.current\/manuals\/p4guide\/01_install.html#1070774<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Setup p4 in Linux \/ Unix Well many people have these questions to me that they are facing issues setting up p4 client in Linux or Unix. The&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[4503,373,4502,4501],"class_list":["post-4588","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-how-to-setup-p4-in-linux-unix","tag-perforce","tag-perforce-setup-in-linux-unix","tag-setup-p4-in-linux-unix"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=4588"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4588\/revisions"}],"predecessor-version":[{"id":5423,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4588\/revisions\/5423"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=4588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=4588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=4588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}