<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>/Proc on myshell.co.uk</title><link>https://myshell.co.uk/tags//proc/</link><description>Recent content in /Proc on myshell.co.uk</description><generator>Hugo</generator><language>en-gb</language><copyright>© 2012 &lt;a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank"&gt;Some rights reserved&lt;/a&gt;</copyright><lastBuildDate>Mon, 04 Mar 2019 15:21:11 +0000</lastBuildDate><atom:link href="https://myshell.co.uk/tags//proc/index.xml" rel="self" type="application/rss+xml"/><item><title>Reading command line password argument with "ps" in Linux</title><link>https://myshell.co.uk/blog/reading-command-line-password-argument-with-ps-in-linux/</link><pubDate>Mon, 04 Mar 2019 15:21:11 +0000</pubDate><guid>https://myshell.co.uk/blog/reading-command-line-password-argument-with-ps-in-linux/</guid><description>&lt;h4 id="introduction"&gt;Introduction:&lt;/h4&gt;
&lt;p&gt;I was recently reading an article online about some methods to hide password argument from system status programs like &amp;ldquo;ps&amp;rdquo; or &amp;ldquo;top&amp;rdquo; in Linux and I decided to take a closer look.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve created a simple &lt;a href="#programpy" title="program.py"&gt;Python script&lt;/a&gt;
 that accepts a single argument for password, let&amp;rsquo;s run it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ./program.py -p secret123 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;[1] 18200
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Sleeping for 600s. PID: 18200
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we check the output from &amp;ldquo;ps&amp;rdquo;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ps -lfp &lt;span class="m"&gt;18200&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;0 S root 18200 16045 0 80 0 - 32500 poll_s 12:26 pts/2 00:00:00 python3 ./program.py -p secret123
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Hmm, that&amp;rsquo;s not good, any user on the system can ready our password now but if we check the help menu for our program, it looks like it can accept password either from the argument or environment variable:&lt;/p&gt;</description></item><item><title>How to determine the number of physical CPUs on Linux</title><link>https://myshell.co.uk/blog/how-to-determine-the-number-of-physical-cpus-on-linux/</link><pubDate>Tue, 17 Jul 2012 15:51:00 +0100</pubDate><guid>https://myshell.co.uk/blog/how-to-determine-the-number-of-physical-cpus-on-linux/</guid><description>&lt;p&gt;The &lt;strong&gt;/proc/cpuinfo&lt;/strong&gt; file contains information about the CPUs installed on your computer however it’s quite confusing when you have to deal with multi-core processors.&lt;/p&gt;
&lt;h4 id="--list-number-of-physical-cpus"&gt;- list number of physical CPUs:&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; cat /proc/cpuinfo &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;&amp;#34;physical id&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sort &lt;span class="p"&gt;|&lt;/span&gt; uniq &lt;span class="p"&gt;|&lt;/span&gt; wc -l
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="--number-of-cores"&gt;- number of cores:&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; cat /proc/cpuinfo &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;&amp;#34;cpu cores&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; uniq
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;cpu cores : 2
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="--how-many-virtual-processors"&gt;- how many virtual processors:&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; cat /proc/cpuinfo &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s2"&gt;&amp;#34;^processor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;processor : 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;processor : 1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the number of virtual processors is greater than the number of physical processors, the CPUs are using hyper-threading. Hyper-threading will only work with the SMP kernel.&lt;/p&gt;</description></item></channel></rss>