Useful Linux commands - zamaniamin/python GitHub Wiki
Ubuntu
check linux version:
lsb_release -a
Update System Packages Index:
sudo apt update && sudo apt upgrade -y
Python
Here's a step-by-step guide to creating a virtual environment using venv
, the standard Python virtual environment module:
- Install python3-venv (if not already installed)
sudo apt update
sudo apt install python3-venv
- Create a Virtual Environment Choose or create a directory for your project, navigate to it in the terminal, and then create a virtual environment:
python3 -m venv .venv
- Activate the Virtual Environment Activate the virtual environment using the following command:
source .venv/bin/activate
PostgreSQL
Install PostgreSQL on Ubuntu:
sudo apt install postgresql postgresql-contrib -y
Start the PostgreSQL service manually using the following command:
sudo service postgresql start
To stop the service:
sudo service postgresql stop
To restart the service:
sudo service postgresql restart
To check if PostgreSQL is running in WSL, you can use the following commands (Verify Installation):
sudo service postgresql status
Access the PostgreSQL Command Line:
sudo -i -u postgres
or:
sudo -u postgres psql
You can exit the PostgreSQL command line by typing:
\q
If you want to perform administrative tasks, you can switch to the "postgres" user and then enter the PostgreSQL command line:
sudo -u postgres psql