<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Linux on Shafiq Alibhai</title>
    <link>https://www.shafiq.in/zh/tags/linux/</link>
    <description>Recent content in Linux on Shafiq Alibhai</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <copyright>© 2009-2026 All rights reserved.</copyright>
    <lastBuildDate>Tue, 05 Sep 2023 04:30:03 +0000</lastBuildDate>
    <atom:link href="https://www.shafiq.in/zh/tags/linux/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to count number of words in a pdf file from Linux cli</title>
      <link>https://www.shafiq.in/zh/blog/how-to-count-number-of-words-in-a-pdf-file-from-linux-cli/</link>
      <pubDate>Tue, 05 Sep 2023 04:30:03 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/how-to-count-number-of-words-in-a-pdf-file-from-linux-cli/</guid>
      <description>&lt;h3 id=&#34;using-pdftotext&#34;&gt;Using &lt;code&gt;pdftotext&lt;/code&gt;:&lt;a class=&#34;anchor&#34; href=&#34;#using-pdftotext&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If it&amp;rsquo;s not installed, you&amp;rsquo;ll need to install the &lt;code&gt;poppler-utils&lt;/code&gt; package which includes &lt;code&gt;pdftotext&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt install poppler-utils&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;yum install poppler-utils&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;depending on your distribution.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Once installed, you can convert a PDF to text and then count the words as follows:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;pdftotext input.pdf - | wc -w&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, &lt;code&gt;input.pdf&lt;/code&gt; is your source PDF file, and &lt;code&gt;wc -w&lt;/code&gt; counts the number of words. The &lt;code&gt;-&lt;/code&gt; in &lt;code&gt;pdftotext&lt;/code&gt; specifies that the output should be sent to stdout, which is then piped into &lt;code&gt;wc&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Replace all dots in filenames except the extension on Linux</title>
      <link>https://www.shafiq.in/zh/blog/replace-all-dots-in-filenames-except-the-extension-on-linux/</link>
      <pubDate>Thu, 21 Jan 2021 13:00:41 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/replace-all-dots-in-filenames-except-the-extension-on-linux/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; f in .&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;pre&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;%.&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;suf&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;##.&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; mv -i -f -- &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$f&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;pre&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;//./_&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;suf&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Count number of directories in the current directory using Linux cli</title>
      <link>https://www.shafiq.in/zh/blog/count-number-of-directories-in-the-current-directory-using-linux-cli/</link>
      <pubDate>Tue, 14 Jul 2020 09:17:02 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/count-number-of-directories-in-the-current-directory-using-linux-cli/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ls -1 &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; wc -l&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Count number of files in a directory using Linux cli</title>
      <link>https://www.shafiq.in/zh/blog/count-number-of-files-in-a-directory-using-linux-cli/</link>
      <pubDate>Tue, 14 Jul 2020 09:15:31 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/count-number-of-files-in-a-directory-using-linux-cli/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ls -l . &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; egrep -c &lt;span class=&#34;s1&#34;&gt;&amp;#39;^-&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>How to run VLC player as root user</title>
      <link>https://www.shafiq.in/zh/blog/how-to-run-vlc-player-as-root-user/</link>
      <pubDate>Mon, 18 May 2020 09:59:54 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/how-to-run-vlc-player-as-root-user/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sed -i &lt;span class=&#34;s1&#34;&gt;&amp;#39;s/geteuid/getppid/&amp;#39;&lt;/span&gt; /usr/bin/vlc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; The initialization script check if the UID is equals to zero. Zero is reserved for the root user. Using &lt;code&gt;sed&lt;/code&gt; to replace &lt;code&gt;geteuid&lt;/code&gt; for &lt;code&gt;getppid&lt;/code&gt; fools the initialization script because it is always &lt;code&gt;&amp;gt; 0&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;While running the VLC as root is not recommended, it works. Be aware of the risks and obviously do not do it for production environments.&lt;/p&gt;</description>
    </item>
    <item>
      <title>One liner: To get available virtual memory</title>
      <link>https://www.shafiq.in/zh/blog/one-liner-to-get-available-virtual-memory/</link>
      <pubDate>Sat, 10 Dec 2011 12:43:02 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/one-liner-to-get-available-virtual-memory/</guid>
      <description>&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vmstat -s -SM &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep &lt;span class=&#34;s2&#34;&gt;&amp;#34;free memory&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; awk -F&lt;span class=&#34;s2&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;{print$1}&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>A Simple Guide to Installing Both Firefox 4 and Firefox 3 on Ubuntu</title>
      <link>https://www.shafiq.in/zh/blog/a-simple-guide-to-installing-both-firefox-4-and-firefox-3-on-ubuntu/</link>
      <pubDate>Mon, 07 Feb 2011 07:03:39 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/a-simple-guide-to-installing-both-firefox-4-and-firefox-3-on-ubuntu/</guid>
      <description>&lt;h3 id=&#34;step-1-add-the-mozilla-daily-ppa-repository&#34;&gt;Step 1: Add the Mozilla Daily PPA Repository&lt;a class=&#34;anchor&#34; href=&#34;#step-1-add-the-mozilla-daily-ppa-repository&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;First, open up your terminal window. Once it&amp;rsquo;s up, type in the command below to add the Ubuntu Mozilla Daily PPA repository to your system:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll be prompted to enter your password. Go ahead and do that, then hit Enter to confirm the addition of the repository.&lt;/p&gt;&#xA;&lt;h3 id=&#34;step-2-update-your-package-list&#34;&gt;Step 2: Update Your Package List&lt;a class=&#34;anchor&#34; href=&#34;#step-2-update-your-package-list&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;After adding the repository, it&amp;rsquo;s crucial to update the package list to ensure you get the latest software. Type the following command:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Preserve File Permissions While Copying Files in Linux</title>
      <link>https://www.shafiq.in/zh/blog/preserve-file-permissions-while-copying-files-in-linux/</link>
      <pubDate>Mon, 14 Jun 2010 09:35:12 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/preserve-file-permissions-while-copying-files-in-linux/</guid>
      <description>&lt;p&gt;Following is the command :&lt;/p&gt;&#xA;&lt;blockquote class=&#39;book-hint &#39;&gt;&#xA;&lt;p&gt;cp -p /aaa/bbb /ccc/ddd&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>How to Identify Your Linux Distribution and Version with Simple Commands</title>
      <link>https://www.shafiq.in/zh/blog/how-to-identify-your-linux-distribution-and-version-with-simple-commands/</link>
      <pubDate>Tue, 23 Mar 2010 05:10:33 +0000</pubDate>
      <guid>https://www.shafiq.in/zh/blog/how-to-identify-your-linux-distribution-and-version-with-simple-commands/</guid>
      <description>&lt;p&gt;If you are using a Linux-based operating system and you want to know which specific distribution and version you have installed, there is a simple command that can help you with that. Just open a terminal window and type the following:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat /etc/issue&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will display the name and the release number of your Linux distribution. For example, if you are using Debian 4.0, the output will look like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Debian GNU/Linux 4.0 &lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\l&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;\n&lt;/code&gt; and &lt;code&gt;\l&lt;/code&gt; are special characters that represent the current date and the name of the terminal device, respectively. They are not part of the distribution name.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
