<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Md. Morshadun Nur</title>
    <description>The latest articles on DEV Community by Md. Morshadun Nur (@morshadunnur).</description>
    <link>https://dev.to/morshadunnur</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F322942%2F3c3fe573-4a3f-4d10-8100-89a10f876d77.jpg</url>
      <title>DEV Community: Md. Morshadun Nur</title>
      <link>https://dev.to/morshadunnur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/morshadunnur"/>
    <language>en</language>
    <item>
      <title>Create a new sudo user in ubuntu </title>
      <dc:creator>Md. Morshadun Nur</dc:creator>
      <pubDate>Sun, 13 Jun 2021 07:19:21 +0000</pubDate>
      <link>https://dev.to/morshadunnur/create-a-new-sudo-user-in-ubuntu-1fe3</link>
      <guid>https://dev.to/morshadunnur/create-a-new-sudo-user-in-ubuntu-1fe3</guid>
      <description>&lt;h2&gt;
  
  
  What is '&lt;strong&gt;sudo&lt;/strong&gt;' ?
&lt;/h2&gt;

&lt;p&gt;Actually &lt;strong&gt;'sudo'&lt;/strong&gt; command provides administrator privileges. When we create a new server it has a default 'root' user. So, here I'm going to create a new user with sudo access.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step One
&lt;/h4&gt;

&lt;p&gt;Open your terminal and write the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root@localhost:~$ adduser [username] 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fckeqnlmfdzzy5nfzavz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fckeqnlmfdzzy5nfzavz2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step two
&lt;/h4&gt;

&lt;p&gt;Set the password and confirm the password again.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvbws8bacnv5nyomezwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvbws8bacnv5nyomezwr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step three
&lt;/h4&gt;

&lt;p&gt;Now you need to give 'sudo' permission to the newly created user. So, use the usermod command in the terminal. Command is given bellow -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root@localhost:~$ usermod -aG [username] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the new user added to the sudo group. you can check by this command -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root@localhost:~$ su - [username] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And run any command with 'sudo' in the terminal -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; username@localhost:~$ sudo apt-get update 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to add sudo to the existing user then just follow the step three. &lt;/p&gt;

&lt;p&gt;Thanks for reading &amp;lt;3&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>bash</category>
      <category>devops</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>Create Laravel artisan commands and test database</title>
      <dc:creator>Md. Morshadun Nur</dc:creator>
      <pubDate>Tue, 08 Jun 2021 08:47:17 +0000</pubDate>
      <link>https://dev.to/morshadunnur/create-laravel-artisan-commands-and-test-database-17pk</link>
      <guid>https://dev.to/morshadunnur/create-laravel-artisan-commands-and-test-database-17pk</guid>
      <description>&lt;p&gt;I'm going to use Artisan command line interface to create custom command. For this you can can run&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan make:test CreateTestDatabase&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now, you go to this directory &lt;strong&gt;app/console/commands&lt;/strong&gt; and open the &lt;strong&gt;CreateDatabase.php&lt;/strong&gt; file. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Initialise the $fileSystem variable and define the command name.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protected $signature = 'testdb:create';

protected $description = 'Create test database sqlite';

private $fileSystem;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Set the Storage factory in constructor &lt;strong&gt;Illuminate\Contracts\Filesystem\Factory&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;parent::__construct();
$this-&amp;gt;fileSystem = $storage-&amp;gt;disk('public'); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now create the &lt;strong&gt;database.sqlite&lt;/strong&gt; file in the &lt;strong&gt;database&lt;/strong&gt; directory and run the migration command.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function handle()
    {
        if (!file_exists(base_path('database/database.sqlite'))){
            $handle = fopen(base_path('database/database.sqlite'), 'c');
            fclose($handle);
        }

        $this-&amp;gt;fileSystem-&amp;gt;put('database.sqlite', '');
        $this-&amp;gt;call('migrate', [
            '--database' =&amp;gt; 'sqlite'
        ]);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, now I can run the command &lt;strong&gt;php artisan testdb:create&lt;/strong&gt; in the terminal and it will create the sqlite file and run the database migrations automatically. &lt;/p&gt;

&lt;h2&gt;
  
  
  Full code is given bellow -
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Factory;

class CreateTestDatabase extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'testdb:create';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create test database sqlite';

    private $fileSystem;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(Factory $storage)
    {
        parent::__construct();
        $this-&amp;gt;fileSystem = $storage-&amp;gt;disk('public');
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        if (!file_exists(base_path('database/database.sqlite'))){
            $handle = fopen(base_path('database/database.sqlite'), 'c');
            fclose($handle);
        }

        $this-&amp;gt;fileSystem-&amp;gt;put('database.sqlite', '');
        $this-&amp;gt;call('migrate', [
            '--database' =&amp;gt; 'sqlite'
        ]);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you so much for the reading. &amp;lt;3&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>artisancommands</category>
      <category>console</category>
    </item>
  </channel>
</rss>
