<?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: Aditya Shrivastav</title>
    <description>The latest articles on DEV Community by Aditya Shrivastav (@adityashrivastavv).</description>
    <link>https://dev.to/adityashrivastavv</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%2F1116879%2Fa561b8c0-7c69-49d0-acdd-168ab999d791.jpeg</url>
      <title>DEV Community: Aditya Shrivastav</title>
      <link>https://dev.to/adityashrivastavv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adityashrivastavv"/>
    <language>en</language>
    <item>
      <title>Running PostgreSQL and pgAdmin 4 in Docker: A Complete Guide</title>
      <dc:creator>Aditya Shrivastav</dc:creator>
      <pubDate>Sat, 29 Jun 2024 04:51:48 +0000</pubDate>
      <link>https://dev.to/adityashrivastavv/running-postgresql-and-pgadmin-4-in-docker-a-complete-guide-2b6o</link>
      <guid>https://dev.to/adityashrivastavv/running-postgresql-and-pgadmin-4-in-docker-a-complete-guide-2b6o</guid>
      <description>&lt;p&gt;Deploying databases in a containerized environment can simplify development and management processes. Docker is a powerful tool that allows you to package applications and their dependencies into isolated containers. In this blog post, we'll walk through the steps to set up a PostgreSQL database along with PgAdmin 4 using Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, make sure you have the following installed on your system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Docker Desktop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Compose (Optional*)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Run the PostgreSQL Docker Container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--env&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;password123 &lt;span class="nt"&gt;--env&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres &lt;span class="nt"&gt;--env&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres &lt;span class="nt"&gt;-v&lt;/span&gt; postgres-volume:/var/lib/postgresql/data &lt;span class="nt"&gt;-p&lt;/span&gt; 5432:5432 &lt;span class="nt"&gt;--name&lt;/span&gt; postgres &lt;span class="nt"&gt;-d&lt;/span&gt; postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above will create a new PostgreSQL container named &lt;code&gt;postgres&lt;/code&gt; using image &lt;code&gt;postgres&lt;/code&gt; with the following configurations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POSTGRES_PASSWORD&lt;/code&gt;: The password for the &lt;code&gt;postgres&lt;/code&gt; user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POSTGRES_DB&lt;/code&gt;: The name of the default database to be created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POSTGRES_USER&lt;/code&gt;: The name of the default user to be created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a volume named &lt;code&gt;postgres-volume&lt;/code&gt; to persist the database data and mount it to the &lt;code&gt;/var/lib/postgresql/data&lt;/code&gt; directory inside the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bind port &lt;code&gt;5432&lt;/code&gt; of the host machine to port &lt;code&gt;5432&lt;/code&gt; of the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-d&lt;/code&gt; flag to run the container in detached mode. If you want to run the container in the foreground, you can omit this flag.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxk9vv94z05ui3fmnne0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxk9vv94z05ui3fmnne0.png" alt="running the postgres image in docker" width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Docker Compose
&lt;/h4&gt;

&lt;p&gt;The same command can be converted into a &lt;code&gt;docker-compose.yml&lt;/code&gt; file as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_DB=postgres&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_USER=postgres&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_PASSWORD=password123&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5432:5432"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres-volume:/var/lib/postgresql/data&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres-volume&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can start the PostgreSQL container by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;span class="c"&gt;#or&lt;/span&gt;
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker compose will save you from typing long commands and make it easier to manage multiple containers. You can also define multiple services in the same &lt;code&gt;docker-compose.yml&lt;/code&gt; file. It is recommended to use this approach for managing containers in a production environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Installing PgAdmin 4 Docker Extension
&lt;/h3&gt;

&lt;p&gt;You don't need to install PgAdmin 4 separately. You can use the official Docker image provided by the PgAdmin team. Or better you can use the PgAdmin4 Docker extension. Using the extension is more convenient as it allows you to manage your PostgreSQL database directly from the Docker Desktop UI. Internally it also uses the official PgAdmin 4 Docker image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu68qyw9fdn4qk943r9xt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu68qyw9fdn4qk943r9xt.png" alt="docker desktop extension marketplace pgAdmin4" width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install the extension. It will automatically download the official PgAdmin 4 Docker image and run it in a container named &lt;code&gt;pgadmin4\&lt;/code&gt; when you click on the PgAdmin 4 icon in the Docker Desktop UI.&lt;/p&gt;

&lt;p&gt;Click on the PgAdmin 4 icon in the Docker Desktop UI to open the PgAdmin 4 web interface.&lt;/p&gt;

&lt;p&gt;After opening the PgAdmin 4 will ask you to set a master password for the PgAdmin 4 web interface. This is because you can store your database credentials in the PgAdmin 4 web interface. So make sure to set a strong password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25tg36lsew9sjdhwvdmo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25tg36lsew9sjdhwvdmo.png" alt="setting master password for pdAdmin4 docker extension" width="704" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;code&gt;Add New Server&lt;/code&gt; button to add a new server connection.&lt;/p&gt;

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

&lt;p&gt;This will open a new window where you can configure the connection details for your PostgreSQL server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3czwcyp8zf4o705sderd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3czwcyp8zf4o705sderd.png" alt="pgAdmin4 add server general register tab" width="699" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter any name for the connection and switch to the &lt;code&gt;Connection&lt;/code&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqld5bgw6nxekoazfn570.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqld5bgw6nxekoazfn570.png" alt="pgAdmin4 server connection tab" width="694" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the following details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Host name/address: &lt;code&gt;host.docker.internal&lt;/code&gt;. This is the hostname that Docker Desktop uses to connect to the host machine. There are some blogs that suggest using &lt;a href="http://localhost"&gt;&lt;code&gt;localhost&lt;/code&gt;&lt;/a&gt; or the IP address of the postgres container. But using &lt;code&gt;host.docker.internal&lt;/code&gt; is the most reliable way to connect to the host machine from a Docker container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Port: &lt;code&gt;5432&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintenance database: &lt;code&gt;postgres&lt;/code&gt;. It is the name of the default database that we created in the PostgreSQL container from environment variable &lt;code&gt;POSTGRES_DB&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Username: &lt;code&gt;postgres&lt;/code&gt;. It is the name of the default user that we created in the PostgreSQL container from environment variable &lt;code&gt;POSTGRES_USER&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Password: &lt;code&gt;password123&lt;/code&gt;. The password we set for the &lt;code&gt;postgres&lt;/code&gt; user in the PostgreSQL container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optionally, you can save the password in the PgAdmin 4 web interface by checking the &lt;code&gt;Save password?&lt;/code&gt; checkbox.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hit the &lt;code&gt;Save&lt;/code&gt; button to save the connection details.&lt;/p&gt;

&lt;p&gt;Now you can see the connection in the left sidebar under the &lt;code&gt;Servers&lt;/code&gt; section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this blog post, we learned how to set up a PostgreSQL database along with PgAdmin 4 using Docker. Docker makes it easy to create isolated environments for your applications and manage dependencies effectively. By following the steps outlined in this post, you can quickly get started with PostgreSQL and PgAdmin 4 in a containerized environment.&lt;/p&gt;

&lt;p&gt;If you have any questions or feedback, feel free to leave a comment below. Happy coding!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>postgres</category>
      <category>pgadmin4</category>
    </item>
    <item>
      <title>How to Set Permanent and Temporary Aliases in PowerShell and Bash: A Step-by-Step Guide</title>
      <dc:creator>Aditya Shrivastav</dc:creator>
      <pubDate>Wed, 19 Jun 2024 10:33:56 +0000</pubDate>
      <link>https://dev.to/adityashrivastavv/how-to-set-permanent-and-temporary-aliases-in-powershell-and-bash-a-step-by-step-guide-1mn9</link>
      <guid>https://dev.to/adityashrivastavv/how-to-set-permanent-and-temporary-aliases-in-powershell-and-bash-a-step-by-step-guide-1mn9</guid>
      <description>&lt;p&gt;Aliases are shortcuts that allow you to create custom commands to save time and improve efficiency when working in the terminal. Both PowerShell and Bash support aliasing, but the methods for setting permanent and temporary aliases differ between these shells. In this guide, we'll walk you through the steps to create and manage aliases in both PowerShell and Bash.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting Aliases in PowerShell
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Temporary Aliases
&lt;/h4&gt;

&lt;p&gt;Temporary aliases in PowerShell exist only for the duration of your current session. Once you close the terminal, these aliases will be lost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Temporary Alias:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open PowerShell.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the &lt;code&gt;Set-Alias&lt;/code&gt; cmdlet to create your alias.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Set-Alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ll&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Get-ChildItem&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;In this example, &lt;code&gt;ll&lt;/code&gt; is an alias for the &lt;code&gt;Get-ChildItem&lt;/code&gt; cmdlet, which is similar to &lt;code&gt;ls&lt;/code&gt; in Unix-based systems.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Viewing Aliases:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see a list of all aliases, use the &lt;code&gt;Get-Alias&lt;/code&gt; cmdlet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Get-Alias&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Permanent Aliases
&lt;/h4&gt;

&lt;p&gt;To make an alias permanent, you need to add it to your PowerShell profile script. This script runs every time a new PowerShell session starts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Permanent Alias:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open PowerShell.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open your PowerShell profile in a text editor. You can do this by running:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;notepad&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$PROFILE&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;If the profile does not exist, this command will create it. You can also use your favorite text editor like VS Code or Sublime text, here I have used &lt;code&gt;notepad&lt;/code&gt; for simplicity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write the same command in the profile script:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Set-Alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ll&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Get-ChildItem&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save and close the text editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To apply the changes immediately without restarting PowerShell, run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$PROFILE&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Setting Aliases in Bash
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Temporary Aliases
&lt;/h4&gt;

&lt;p&gt;Temporary aliases in Bash also exist only for the current session. They will be lost once you close the terminal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Temporary Alias:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open a terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the &lt;code&gt;alias&lt;/code&gt; command to create your alias.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;ll&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ls -la'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;In this example, &lt;code&gt;ll&lt;/code&gt; is an alias for the &lt;code&gt;ls -la&lt;/code&gt; command.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Viewing Aliases:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see a list of all aliases, use the &lt;code&gt;alias&lt;/code&gt; command without any arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Permanent Aliases
&lt;/h4&gt;

&lt;p&gt;To make an alias permanent, you need to add it to your shell's configuration file, such as &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.bash_profile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Permanent Alias:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open a terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open your &lt;code&gt;.bashrc&lt;/code&gt; file in a text editor. You can do this with &lt;code&gt;nano&lt;/code&gt; or &lt;code&gt;vi&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add your alias command in the &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;ll&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ls -la'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save and close the text editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To apply the changes immediately without restarting  the terminal, run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Setting aliases in PowerShell and Bash can greatly enhance your productivity by reducing the amount of typing required for frequently used commands. Whether you need a temporary alias for a quick task or a permanent one for everyday use, the steps outlined above will help you configure your terminal to suit your workflow. Experiment with different aliases to find the ones that best fit your needs. Happy aliasing!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to create a Virtual Environment in Python in 1 Minute?</title>
      <dc:creator>Aditya Shrivastav</dc:creator>
      <pubDate>Mon, 17 Jun 2024 09:58:21 +0000</pubDate>
      <link>https://dev.to/adityashrivastavv/how-to-create-a-virtual-environment-in-python-in-1-minute-5ah9</link>
      <guid>https://dev.to/adityashrivastavv/how-to-create-a-virtual-environment-in-python-in-1-minute-5ah9</guid>
      <description>&lt;p&gt;A virtual environment in Python is a &lt;strong&gt;self-contained&lt;/strong&gt; directory that contains a specific &lt;strong&gt;Python interpreter&lt;/strong&gt; and a set of &lt;strong&gt;installed packages&lt;/strong&gt;. It allows you to &lt;strong&gt;isolate&lt;/strong&gt; your Python project's dependencies from the system-wide Python installation and other projects.&lt;/p&gt;

&lt;p&gt;By creating a virtual environment, you can have different versions of Python and different sets of packages for each project, without worrying about conflicts or dependencies between them. This is particularly useful when working on multiple projects that require different versions of packages or when collaborating with others who may have different setups.&lt;/p&gt;

&lt;p&gt;When you activate a virtual environment, it modifies the system's PATH environment variable to prioritize the Python interpreter and packages within the virtual environment. This ensures that when you run Python commands or install packages, they are specific to that environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a virtual environment in Python?
&lt;/h2&gt;

&lt;p&gt;There are several ways to create a virtual environment in Python, we will learn the most common methods which are using &lt;code&gt;venv&lt;/code&gt; module using CLI and &lt;strong&gt;extention&lt;/strong&gt; in VSCode.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Using &lt;code&gt;venv&lt;/code&gt; module in CLI
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;venv&lt;/code&gt; module is the built-in tool for creating virtual environments in Python. Here's how you can create a virtual environment using &lt;code&gt;venv&lt;/code&gt; in the command line:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your terminal or command prompt.&lt;/li&gt;
&lt;li&gt;Navigate to the directory where you want to create the virtual environment.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the following command to create a virtual environment named &lt;code&gt;myenv&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; venv myenv
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;macOS/Linux&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To activate the virtual environment, run the following command:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;myenv&lt;span class="se"&gt;\S&lt;/span&gt;cripts&lt;span class="se"&gt;\a&lt;/span&gt;ctivate
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;macOS/Linux&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source &lt;/span&gt;myenv/bin/activate
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This will run a script that modifies your shell's PATH to prioritize the Python interpreter and packages within the virtual environment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You should see the name of the virtual environment &lt;code&gt;(myenv)&lt;/code&gt; in your terminal prompt, indicating that the virtual environment is active.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sometimes in VS Code you may not see the &lt;code&gt;(myenv)&lt;/code&gt; in the terminal prompt, butyou can verify the activation by running &lt;code&gt;where.exe python&lt;/code&gt; or &lt;code&gt;which python3&lt;/code&gt; command. It should point to the Python interpreter within the virtual environment.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can now install packages using &lt;code&gt;pip&lt;/code&gt; or run Python scripts within this virtual environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To deactivate the virtual environment, simply run the &lt;code&gt;deactivate&lt;/code&gt; command in the terminal which will be found in the &lt;code&gt;env &amp;gt; Scripts&lt;/code&gt; folder in the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To delete the virtual environment, you can simply delete the directory containing it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;That's it!&lt;/strong&gt; You have successfully created and activated a virtual environment in Python using &lt;code&gt;venv&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2. Using the Python extension in VSCode
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your Python project in Visual Studio Code (VSCode).&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Python interpreter&lt;/strong&gt; in the bottom left corner of the VSCode window.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Create Virtual Environment&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;code&gt;venv&lt;/code&gt; as the virtual environment type.&lt;/li&gt;
&lt;li&gt;Select the base interpreter (Python version) to use for the virtual environment.&lt;/li&gt;
&lt;li&gt;The virtual environment will be created in a &lt;code&gt;.venv&lt;/code&gt; directory within your project.&lt;/li&gt;
&lt;li&gt;Now if you open a new terminal in VSCode, it should automatically activate the virtual environment.
&amp;gt; Sometimes in VS Code you may not see the &lt;code&gt;(myenv)&lt;/code&gt; in the terminal prompt, butyou can verify the activation by running &lt;code&gt;where.exe python&lt;/code&gt; or &lt;code&gt;which python3&lt;/code&gt; command. It should point to the Python interpreter within the virtual environment.
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqyhaas3bkpilttd3n50.png" alt="vs code env active message" width="549" height="158"&gt;
&lt;/li&gt;
&lt;li&gt;If the above did't work for you, use Python extension in VSCode to select the interpreter from the virtual environment.
&lt;a href="https://marketplace.visualstudio.com/items?itemName=donjayamanne.python-environment-manager"&gt;https://marketplace.visualstudio.com/items?itemName=donjayamanne.python-environment-manager&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r4u8ayhoe2adun53asa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2r4u8ayhoe2adun53asa.png" alt="vs code python extension tab" width="390" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Creating a virtual environment in Python is a simple yet powerful way to manage your project's dependencies and ensure that they are isolated from other projects and the system-wide Python installation. By following the steps outlined above, you can quickly set up a virtual environment for your project and start developing with confidence.&lt;/p&gt;

&lt;p&gt;I hope this article has been helpful in understanding how to create a virtual environment in Python. If you have any questions or feedback, please feel free to reach out. Happy coding!&lt;/p&gt;

&lt;p&gt;Do share this article with your friends and colleagues who might find it useful. Thank you for reading!&lt;/p&gt;

</description>
      <category>python</category>
      <category>venv</category>
    </item>
  </channel>
</rss>
