<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2025-09-21T18:57:20+00:00</updated><id>/feed.xml</id><title type="html">MehrdadLinux Weblog</title><subtitle>Technical diaries</subtitle><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><entry><title type="html">In Linux, how do I create or Generate random File or Data or String?[SOLVED]</title><link href="/linux/2023/01/18/1.html" rel="alternate" type="text/html" title="In Linux, how do I create or Generate random File or Data or String?[SOLVED]" /><published>2023-01-18T00:00:00+00:00</published><updated>2023-01-18T00:00:00+00:00</updated><id>/linux/2023/01/18/1</id><content type="html" xml:base="/linux/2023/01/18/1.html"><![CDATA[<p>The process of creating a random file can be done in a number of ways: 
I’m going to create a 10M file using all commands to test this.</p>

<p>It can be done using the following 6 methods.</p>

<p>fallocate: fallocate is used to preallocate or deallocate space to a file.
truncate: truncate is used to shrink or extend the size of a file to the specified size.
dd: Copy a file, converting and formatting according to the operands.
head: head is used to print the first part of files.
xfs_mkfile: xfs_mkfile command allow us to create a specific size of a file in Linux.
perl: Perl is a programming language specially designed for text editing.</p>

<h2 id="use-dd">Use dd</h2>

<p>create a 100M file filled with all 0’s.
        $ dd if=/dev/zero of=100M_filled_with_zeros bs=100M count=1
create a 100M file filled with random data.
        $ dd if=/dev/urandom of=100M_filled_with_random_data bs=1M count=100</p>

<h2 id="use-head">Use head</h2>

<p>create a 100M file filled with all 0’s.
        $ head -c 100M /dev/zero &gt; 100M_filled_with_zeros
create a 100M file filled with random data.
        $ head -c 100M /dev/urandom &gt; 100M_filled_with_random_data</p>

<h2 id="use-openssl">Use openssl</h2>

<p>openssl rand -out $testfile -base64 792917038; truncate -s-1 $testfile
openssl rand -out myfile “$size”
If you need base64:
openssl rand -base64 -out myfile “$size”</p>

<h2 id="use-jot">Use jot</h2>

<p>jot -r -c $FILESIZE &gt; $FILE
truncate –size 1G foo
shred –iterations 1 foo</p>
<h2 id="xfs_mkfile">xfs_mkfile</h2>

<p>xfs_mkfile 10M daygeek5.txt</p>

<h2 id="for-strings">For Strings</h2>

<ol>
  <li>Using the base64 Command
$ base64 /dev/urandom | head –c 10
pIS3VBfRhf</li>
</ol>

<p>$ base64 /dev/urandom | head –c 10 &gt; random_file.txt
$ cat random_file.txt
/8ZtS5IfK+</p>

<ol>
  <li>Using the tr Command</li>
</ol>

<p>$ tr –dc [:graph:] &lt; /dev/urandom | head –c 10
m1#Vs:ABp</p>

<p>$ tr –dc [:alnum:] &lt; /dev/urandom | head –c 10
miB150lFw2</p>

<p>$ tr –dc [:graph:] &lt; /dev/urandom | head –c 10 &gt; random_file.txt
$ cat random_file.txt
TKt4r$#Z7r</p>

<ol>
  <li>
    <h3 id="using-the-strings-command">Using the strings Command</h3>
    <p>$ strings -s “” /dev/urandom | head -c 10
BB2!C5./8
$ strings -s “” /dev/urandom | head -c 10 &gt; random_file.txt
$ cat random_file.txt
7)XM/F%F;^</p>
  </li>
  <li>Using a Dictionary
$ shuf -n 5 /usr/share/dict/words | tr ‘\n’ ‘ ‘ &gt; random_file.txt
$ cat random_file.txt</li>
</ol>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="linux" /><summary type="html"><![CDATA[The process of creating a random file can be done in a number of ways: I’m going to create a 10M file using all commands to test this.]]></summary></entry><entry><title type="html">Open Jupyter Notebook here one click very fast[SOLVED]</title><link href="/linux/2022/08/19/1.html" rel="alternate" type="text/html" title="Open Jupyter Notebook here one click very fast[SOLVED]" /><published>2022-08-19T00:00:00+00:00</published><updated>2022-08-19T00:00:00+00:00</updated><id>/linux/2022/08/19/1</id><content type="html" xml:base="/linux/2022/08/19/1.html"><![CDATA[<p>Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computational environment for creating notebook documents.</p>

<h2 id="running-the-jupyter-notebook">Running the Jupyter Notebook</h2>

<p>To launch Jupyter Notebook App:</p>
<ul>
  <li>Click on spotlight, type terminal to open a terminal window.</li>
  <li>Enter the startup folder by typing cd /some_folder_name .</li>
  <li>Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.</li>
</ul>

<h2 id="how-do-it-faster">How do it faster</h2>

<p>Copy  this script and save it in file</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    #!/bin/bash
    source "/[yourenv if you install it in env ]/bin/activate" # if you use venv
    jupyter-lab --notebook-dir=$PWD  # use $PWD for open here
</code></pre></div></div>

<h2 id="gnome-scripts">Gnome scripts</h2>

<p>GNOME Files, formerly and internally known as Nautilus, is the official file manager for the GNOME desktop
Nautilus script is an executable shell script that is placed in a special scripts directory so that the Nautilus graphical shell can find it. This allows you to extend the functionality of the file browser to do just about anything.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>     ~/.local/share/nautilus/scripts/
</code></pre></div></div>

<h2 id="how-it-works">How it works?</h2>

<p>Copy script in Gnome scripts path and change file permission</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    chmod a+x [yourscript]
</code></pre></div></div>

<p>Righclick on folder and select yourscript 
done</p>

<p>Do you have a question?</p>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="linux" /><summary type="html"><![CDATA[Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computational environment for creating notebook documents.]]></summary></entry><entry><title type="html">vagrant-cachier dnf problem[SOLVED]</title><link href="/virtualization/2022/03/22/1.html" rel="alternate" type="text/html" title="vagrant-cachier dnf problem[SOLVED]" /><published>2022-03-22T00:00:00+00:00</published><updated>2022-03-22T00:00:00+00:00</updated><id>/virtualization/2022/03/22/1</id><content type="html" xml:base="/virtualization/2022/03/22/1.html"><![CDATA[<p>Vagrant-cachier is a vagrant plugin that helps you reduce waiting for boxes to be provisioned by sharing a common package cache among similar VM instances</p>

<h2 id="installation">Installation</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant plugin install vagrant-cachier
</code></pre></div></div>

<h2 id="how-to-use-it">How to use it</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Vagrant.configure("2") do |config|
    config.vm.box = 'your-box'
        if Vagrant.has_plugin?("vagrant-cachier")
            config.cache.scope = :box
            config.cache.synced_folder_opts = {
                type: :nfs,
                mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
            }
        end
end
</code></pre></div></div>

<h2 id="fedora-and-dnf-problem">Fedora and dnf Problem</h2>

<p>When you try to use a Vagrant-cachier with Fedora, you get an error like this</p>

<p>VagrantPlugins::Cachier::Bucket::Dnf</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/install_buckets.rb:43:in `block in configure_cache_buckets'
/root/.vagrant.d/gems/2.6.6/gems/vagrant-cachier-1.2.1/lib/vagrant-cachier/bucket.rb:23:in `install': uninitialized constant VagrantPlugins::Cachier::Bucket::Dnf (NameError)
</code></pre></div></div>

<p>or</p>

<h2 id="yum-not-found">yum not found</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Vagrant assumes that this means the command failed!
sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
Stdout from the command:
Stderr from the command:
sed: can't read /etc/yum.conf: No such file or directory
</code></pre></div></div>

<h2 id="answer--heres-how-you-can-fix-it">Answer  Here’s how you can fix it:</h2>

<p>Using git, you must manually update it</p>

<h2 id="what-caused-this-to-happen-">What caused this to happen ?</h2>

<ul>
  <li>
    <p>vagrant-cachier have 5 Releases  latest one is  v1.2.0 on Jan 14, 2015</p>
  </li>
  <li>
    <p>dnf plugin patch for vagrant-cachier  Merge pull request on Nov 22, 2016</p>
  </li>
  <li>
    <p>This project is looking for maintainers so update is not in repository</p>
  </li>
</ul>

<h2 id="how-to-manually-update-it">How to manually update it</h2>

<p>use git to clone project</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/fgrehm/vagrant-cachier
</code></pre></div></div>

<p>You must go to the location where you installed Vagrant</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/[your_user]/.vagrant.d/gems/2.6.6/gems/vagrant-cachier-1.2.1/lib/vagrant-cachier/
</code></pre></div></div>

<p>Sync to folder</p>

<h2 id="the-latest-experience">The latest experience</h2>

<p>**dont use this plugin for Fedora and dnf **</p>

<p>done
Do you have a question?</p>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="Virtualization" /><summary type="html"><![CDATA[Vagrant-cachier is a vagrant plugin that helps you reduce waiting for boxes to be provisioned by sharing a common package cache among similar VM instances]]></summary></entry><entry><title type="html">Troubleshooting the problem of not setting IP on Esxi by DHCP[SOLVED]</title><link href="/network/2022/03/14/1.html" rel="alternate" type="text/html" title="Troubleshooting the problem of not setting IP on Esxi by DHCP[SOLVED]" /><published>2022-03-14T00:00:00+00:00</published><updated>2022-03-14T00:00:00+00:00</updated><id>/network/2022/03/14/1</id><content type="html" xml:base="/network/2022/03/14/1.html"><![CDATA[<p>When I want to give an IP to a service, I usually use DHCP Reservation and static the IP value by mac if you are in the ESXI system.
In some cases, you will face the following problem.
DHCP answered the IP request, but the ESXI did not set the IP.</p>

<p>Answer :</p>

<p>The reason for this situation is that in this DHCP server, the default gateway value is not set and only gives the IP
That is why ESXI does not accept this IP from DHCP.</p>

<p>So you need to make sure your DHCP sets the default gateway value.</p>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="Network" /><summary type="html"><![CDATA[When I want to give an IP to a service, I usually use DHCP Reservation and static the IP value by mac if you are in the ESXI system. In some cases, you will face the following problem. DHCP answered the IP request, but the ESXI did not set the IP.]]></summary></entry><entry><title type="html">how use socks proxy in linux apt</title><link href="/linux/2021/01/09/1.html" rel="alternate" type="text/html" title="how use socks proxy in linux apt" /><published>2021-01-09T00:00:00+00:00</published><updated>2021-01-09T00:00:00+00:00</updated><id>/linux/2021/01/09/1</id><content type="html" xml:base="/linux/2021/01/09/1.html"><![CDATA[<p>Do you need use socks proxy in apt?</p>

<p>It is very easy  just</p>

<p>open apt.conf in /etc/apt/apt.conf with your favorites editor for example use xed in Linux mint  (If the file in path it is not exist make it :D)</p>

<p>xed /etc/apt/apt.conf</p>

<p>and add this code in it</p>

<p>Acquire::http::Proxy “socks5h://your_proxy_server:port”;</p>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="linux" /><summary type="html"><![CDATA[Do you need use socks proxy in apt?]]></summary></entry><entry><title type="html">Sharp or Number sign, that is the question</title><link href="/programming/2020/10/08/1.html" rel="alternate" type="text/html" title="Sharp or Number sign, that is the question" /><published>2020-10-08T00:00:00+00:00</published><updated>2020-10-08T00:00:00+00:00</updated><id>/programming/2020/10/08/1</id><content type="html" xml:base="/programming/2020/10/08/1.html"><![CDATA[<p>Some people think a symbol in front of C# is Sharp are you agree or disagree?</p>

<p>Years after the introduction of C#, the prevalence of very big mistakes or misunderstand in computer society.
Call # Sharp again of the number sign 
For example when a junior programmer or junior computer scientist saw a # in Twitter some of them call it sharp :O or hashtag
although hash is another name for number sign, you can not call it sharp when you saw it on most of the web.
In this article we are going to discuss, what is different between symbol # we known as the number sign, hash  “#”  and music symbol, sharp, means higher in pitch and we write it “♯” (U+266F in Unicode)</p>

<p>Why the Microsoft call it new programming languages C Sharp? Microsoft wants to introduce a higher-level programming language from C++ with more facilities. They looking for new symbols and they find sharp. The sharp symbol is so perfect because it looks like 4 plus ++++
and it means higher in pitch in music. They had a very big problem.</p>

<p>You can not type sharp directly from the keyboard :(.
so they decide to choose hashtag along sharp</p>

<p>In conclusion, although we write C# (pronounce c sharp), this # a lonely pronounce number sign or hash</p>]]></content><author><name>MehrdadLinux</name><email>MehrdadLinux@Gmail.Com</email></author><category term="programming" /><summary type="html"><![CDATA[Some people think a symbol in front of C# is Sharp are you agree or disagree?]]></summary></entry></feed>