Files
doc-exports/docs/obs/tool-obsutil/obs_11_0049.html
weihongmin1 c4291b1dd5 OBS Util 0309 Verion
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2026-03-27 12:15:19 +00:00

56 lines
12 KiB
HTML

<a name="obs_11_0049"></a><a name="obs_11_0049"></a>
<h1 class="topictitle1">Setting obsutil Commands as Built-in Commands</h1>
<div id="body1547539627819"><div class="section" id="obs_11_0049__section0564832202219"><h4 class="sectiontitle">Scenario</h4><p id="obs_11_0049__p10586101161617">Because obsutil is external software, you need to access the directory where obsutil resides before running obsutil commands, which is not convenient.</p>
<p id="obs_11_0049__p918062321418">An OS provides built-in commands so that the command-dependent directories are loaded to the memory when the system is started. In this way, you can run the commands in any directory, which improves the tool's usability.</p>
<p id="obs_11_0049__p1978510366223">This section introduces how to set obsutil commands as built-in commands in different OSs.</p>
</div>
<div class="section" id="obs_11_0049__section168751940102118"><h4 class="sectiontitle">Setting obsutil Commands as Built-in Commands in Windows</h4><ol id="obs_11_0049__ol5625848155415"><li id="obs_11_0049__li562594814541"><span>In the CLI, run the <strong id="obs_11_0049__b1368184710912">echo %PATH%</strong> command to query all the paths configured in the current system. Then select one as the operation path.</span></li><li id="obs_11_0049__li9628144875416"><span>Run the <strong id="obs_11_0049__b192376593211">mklink </strong><em id="obs_11_0049__i1411714115228">PATH</em><strong id="obs_11_0049__b88749482213">/obsutil.exe </strong><em id="obs_11_0049__i1243565221">OBSUTIL_PATH</em> command to set obsutil commands as built-in commands in the system.</span><p><div class="note" id="obs_11_0049__note76342484544"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0049__p1634748135414"><em id="obs_11_0049__i1899110286297">PATH</em> indicates the operation path selected in step 1. <em id="obs_11_0049__i109921328142916">OBSUTIL_PATH</em> indicates the absolute path of <strong id="obs_11_0049__b14366193133017">obsutil.exe</strong>.</p>
</div></div>
</p></li><li id="obs_11_0049__li166361548165412"><span>Check whether the configuration is successful: Run the <strong id="obs_11_0049__b17983531172311">obsutil help</strong> command in the CLI. If the help information is displayed, the configuration is successful.</span></li></ol>
</div>
<div class="section" id="obs_11_0049__section524910267228"><h4 class="sectiontitle">Setting obsutil Commands as Built-in Commands in Linux or macOS</h4><ol id="obs_11_0049__ol1063811824518"><li id="obs_11_0049__li14357815172114"><span>Run the following command to create a directory for the obsutil tool:</span><p><pre class="screen" id="obs_11_0049__screen11358141514214">mkdir /obsutil</pre>
<div class="note" id="obs_11_0049__note18198123019124"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0049__ul89281952111212"><li id="obs_11_0049__li12928552131217">Skip this step if the directory already exists.</li><li id="obs_11_0049__li399731816134">You must run the command as user <strong id="obs_11_0049__b151903428195">root</strong>.</li></ul>
</div></div>
</p></li><li id="obs_11_0049__li4898334121418"><span>Run the following command to grant the <strong id="obs_11_0049__b18360171894814">755</strong> permission for the tool's directory:</span><p><pre class="screen" id="obs_11_0049__screen17686439171513">chmod 755 /obsutil</pre>
<div class="note" id="obs_11_0049__note13680138169"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="obs_11_0049__ul1264761910164"><li id="obs_11_0049__li3647131981610">Skip this step if the permission for the directory is <strong id="obs_11_0049__b2057611764815">drwxr-xr-x</strong>.</li><li id="obs_11_0049__li5840104017175">You must run the command as user <strong id="obs_11_0049__b15476102214489">root</strong>.</li></ul>
</div></div>
</p></li><li id="obs_11_0049__li57391361817"><span>Copy the obsutil tool to the directory created in step 1 and change its permission to <strong id="obs_11_0049__b96881334165113">711</strong>. Assume that the original path of the tool is <strong id="obs_11_0049__b16451471414">/home/test/obsutil</strong>. Run the following command:</span><p><pre class="screen" id="obs_11_0049__screen43656570210">cp /home/test/obsutil /obsutil
chmod 711 /obsutil/obsutil</pre>
</p></li><li id="obs_11_0049__li1499171422317"><span>Run the <strong id="obs_11_0049__b134594446272">vi /etc/profile</strong> command. Press <strong id="obs_11_0049__b1935783710216">i</strong> to enter the Insert mode and add <strong id="obs_11_0049__b1520019587301">export PATH=$PATH:/obsutil</strong> at the end of the file. Then press <strong id="obs_11_0049__b3361561141">Esc</strong> to exit the editing mode and type <strong id="obs_11_0049__b136181711173110">:wq!</strong> and press <strong id="obs_11_0049__b5949184119233">Enter</strong> to save the changes and exit.</span><p><div class="note" id="obs_11_0049__note1422133312318"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0049__p187991326332">Skip this step if the new line already exists in the <strong id="obs_11_0049__b1923521101215">/etc/profile</strong> file.</p>
</div></div>
</p></li><li id="obs_11_0049__li996033762713"><span>Run the <strong id="obs_11_0049__b4237516164018">echo $PATH</strong> command to query the current environment variables. If the query result includes <strong id="obs_11_0049__b142991144121319">:/obsutil</strong>, indicating that the <strong id="obs_11_0049__b11808140191513">/obsutil</strong> environment variable already exists, go to the next step. Otherwise, run the <strong id="obs_11_0049__b71226529408">source /etc/profile</strong> command.</span></li><li id="obs_11_0049__li186451918154515"><span>Check whether the configuration is successful: Run the <strong id="obs_11_0049__b108431010132110">obsutil help</strong> command in any directory. If the help information is displayed, the configuration is successful.</span></li></ol>
</div>
<div class="section" id="obs_11_0049__section14418131348"><h4 class="sectiontitle">FAQs</h4><ol id="obs_11_0049__ol6575124113619"><li id="obs_11_0049__li357512414366">How do I locate the obsutil configuration file after setting obsutil commands to built-in commands?<p id="obs_11_0049__p11826162512363"><a name="obs_11_0049__li357512414366"></a><a name="li357512414366"></a>The <strong id="obs_11_0049__b209351652105319">.obsutilconfig</strong> file in the same directory where obsutil commands reside is the configuration file of the obsutil tool. You can also run the <strong id="obs_11_0049__b1252813075913">obsutil config</strong> command to obtain the configuration file path. An example is provided as follows:</p>
<pre class="screen" id="obs_11_0049__screen269584345916"><strong id="obs_11_0049__b969712559020">obsutil config</strong>
Config file url:
D:\tools\.obsutilconfig</pre>
</li><li id="obs_11_0049__li43932031161118">How do I delete obsutil commands after setting them as built-in commands?<ul id="obs_11_0049__ul18944114951218"><li id="obs_11_0049__li16945184916126">Windows:<ol type="a" id="obs_11_0049__ol1848713541413"><li id="obs_11_0049__li048733551417">Run the <strong id="obs_11_0049__b18261536142212">where obsutil</strong> command to locate the path of obsutil commands.<pre class="screen" id="obs_11_0049__screen172418559207"><strong id="obs_11_0049__b1191364012216">where obsutil</strong>
E:\tools\bin\obsutil.exe</pre>
</li><li id="obs_11_0049__li1159219505202">Run the <strong id="obs_11_0049__b1728818598462">del </strong><em id="obs_11_0049__i107332224711">PATH</em> command to delete obsutil commands.<pre class="screen" id="obs_11_0049__screen64011134212"><strong id="obs_11_0049__b18636131312414">del E:\tools\bin\obsutil.exe</strong></pre>
<div class="note" id="obs_11_0049__note1072081102110"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0049__p97211182110">Replace <em id="obs_11_0049__i18421324174710">PATH</em> with the path of obsutil commands. <strong id="obs_11_0049__b10979848114718">E:\tools\bin\obsutil.exe</strong> is used in the preceding example.</p>
</div></div>
</li></ol>
</li><li id="obs_11_0049__li468014305133">macOS or Linux<ol type="a" id="obs_11_0049__ol3418141516156"><li id="obs_11_0049__li9418151519155">Run the <strong id="obs_11_0049__b13246144018491">which obsutil</strong> command to locate the path of obsutil commands.<pre class="screen" id="obs_11_0049__screen161578414152"><strong id="obs_11_0049__b7574135751514">which obsutil</strong>
/obsutil/obsutil</pre>
</li><li id="obs_11_0049__li1317745394714">Run the <strong id="obs_11_0049__b15173496497">rm -rf </strong><em id="obs_11_0049__i95190492499">PATH</em> command to delete obsutil commands.<pre class="screen" id="obs_11_0049__screen161779537478"><strong id="obs_11_0049__b16177115312476">rm -rf /obsutil/obsutil</strong></pre>
<div class="note" id="obs_11_0049__note0177553144716"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0049__p1617885324713">Replace <em id="obs_11_0049__i5780144575017">PATH</em> with the path of obsutil commands. <strong id="obs_11_0049__b37809453508">/obsutil/obsutil</strong> is used in the preceding example.</p>
</div></div>
</li><li id="obs_11_0049__li19911132691515">Restore the system environment variable: Delete the path of obsutil that is set in the <strong id="obs_11_0049__b163013400554">/etc/profile</strong> file.<div class="note" id="obs_11_0049__note7617154031919"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0049__p14617134081914">If the <strong id="obs_11_0049__b1443518810568">/etc/profile</strong> file contains line <strong id="obs_11_0049__b173591122175620">export PATH=$PATH:/obsutil</strong>, delete the line. Or if the file contains line <strong id="obs_11_0049__b2010412613018">export PATH=$PATH:/test/bin:/obsutil:/test1</strong>, delete <strong id="obs_11_0049__b12583141201">:/obsutil</strong> from the line.</p>
</div></div>
</li></ol>
</li></ul>
</li><li id="obs_11_0049__li11827325103618">What should I do if the execution of built-in obsutil commands fails in Linux or macOS?<ul id="obs_11_0049__ul397141119406"><li id="obs_11_0049__li109717119406">If the message <strong id="obs_11_0049__b108366381568">Permission denied</strong> is displayed after executing <strong id="obs_11_0049__b21453453619">obsutil help</strong>, run the <strong id="obs_11_0049__b84783013718">chmod 755 </strong><em id="obs_11_0049__i95502013720">OBSUTIL_PATH</em> command (replace <em id="obs_11_0049__i618320441076">OBSUTIL_PATH</em> with the path of obsutil) to add an execute permission for the obsutil tool.</li><li id="obs_11_0049__li6971411164011">If the message <strong id="obs_11_0049__b11950152519913">command not found</strong> is displayed, log in again.</li><li id="obs_11_0049__li39741134017">If the message <strong id="obs_11_0049__b0212109118">Cannot create parent folder for xx/.obsutilconfig, xx Permission denied</strong> is displayed, check whether the home directory of the user exists.<div class="notice" id="obs_11_0049__note3129173604015"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="obs_11_0049__p1912913615403">In the Ubuntu OS, if you run the <strong id="obs_11_0049__b2461150131913">useradd</strong> command to add a user, the home directory of the user is not created by default. You need to create it manually. Therefore, you are advised to run the <strong id="obs_11_0049__b124621650161916">adduser</strong> command to add a user.</p>
</div></div>
</li></ul>
</li><li id="obs_11_0049__li382411413416">What can I do if no log file is generated after running built-in obsutil commands in Linux or macOS?<p id="obs_11_0049__p912011221051"><a name="obs_11_0049__li382411413416"></a><a name="li382411413416"></a>If you have properly configured <strong id="obs_11_0049__b1191118446285">sdkLogPath</strong> and <strong id="obs_11_0049__b765813488280">utilLogPath</strong> in the configuration file, but still no log file is generated after command execution, then check whether the user who runs the command has the read and write permissions on <strong id="obs_11_0049__b1415254016312">sdkLogPath</strong> and <strong id="obs_11_0049__b943394316317">utilLogPath</strong>.</p>
</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0033.html">Best Practices</a></div>
</div>
</div>