extra information/ content related to any topics are collected under this section, you can explore and learn more related and useful information.
1.Find Which Process is Using a Port
netstat -ano | findstr :port_number(5432)
Purpose:
note: here 5432 port is user , you can used any port
This command checks if any process on your Windows machine is listening on port 5532
— which is the port you're trying to use for PostgreSQL.
Breakdown:
Part | Meaning |
---|---|
netstat | Shows network statistics and active connections. |
-a | Displays all connections and listening ports. |
-n | Shows IP addresses and port numbers numerically (not resolved to hostnames or service names). |
-o | Shows the process ID (PID) using each connection. |
` | ` |
findstr :5532 | Filters the output to only show lines with :5532 (i.e., port 5432). |
What You’re Looking For:
If PostgreSQL is listening on port 5432, you’ll see output like:
TCP 127.0.0.1:5532 0.0.0.0:0 LISTENING 1234
The last column (1234
) is the PID (Process ID) of the process using the port.
How to Check What’s Listening (e.g., PostgreSQL)
If a process is listening on port 5432
, note the PID in the last column.
Then run
tasklist /FI "PID eq 1234"
(Replace 1234
with the actual PID.)
This will tell you which program is using that port.
Here are several useful Windows terminal commands and functionalities you can explore:
1. List All Listening Ports
netstat -an | findstr LISTENING
Shows all ports your system is listening on.
2.Kill a Process by PID (Be careful!)
taskkill /PID 1234 /F
Forcefully stops the process using PID 1234
. Useful if something is blocking the port.
3. Check if PostgreSQL is Running (in Services)
sc query | findstr postgre
Shows if PostgreSQL service is installed and its status.
Or Open:
services.msc
5. Find PostgreSQL Configuration Path
If PostgreSQL is installed but you don’t know where the config files are:
where psql
Then go to the bin folder, and check the path above it — typically:
C:\Program Files\PostgreSQL\<version>\data
Files to look for:
postgresql.conf
– contains the port setting.pg_hba.conf
– contains the access control rules.
How to Add a New Remote Origin in Git and Push Code
If you already have a Git project locally and want to add a new remote origin (i.e., a new Git repository, like on GitHub/GitLab/Bitbucket), here’s how you can do it:
1. Check existing remotes
git remote -v
This will show something like:
origin [email protected]:username/old-repo.git (fetch)
origin [email protected]:username/old-repo.git (push)
2. Add a new remote
You can add a new remote with a different name:
git remote add new-origin https://github.com/username/new-repo.git
or if you prefer SSH:
git remote add new-origin [email protected]:username/new-repo.git
3. Verify the new remote
git remote -v
Now you should see both:
4. Push to the new remote
If you want to push your current branch (say main
or master
) to the new repo:
git push new-origin main
- The
main
here is the name of your local branch (the branch you’re currently working on). - Git will push this local
main
branch to the remote repo (new-origin
), creating a branch calledmain
there too (if it doesn’t already exist).
So to clarify:
- If your current branch is
main
, then this command pushes it to the new remote asmain
. - If your current branch is
dev
(for example), then you should run: git push new-origin dev
You want to push your local dev
branch into the master
branch of the new remote (new-origin
).
git push new-origin dev:master
Explanation:
dev
? your local branch (the source).master
? the branch name on the remote (the destination).new-origin
? the remote repository you added.
So this says:
Take my local dev
branch and push it into the master
branch on new-origin
.
If you want to set it as the default upstream:
git push -u new-origin main
Know more about upstream
What does upstream mean?
In Git, the upstream branch is the remote branch that your local branch is “tracking.”
- When you set an upstream, your local branch knows:
- Where to push changes (
git push
without extra arguments). - Where to pull changes from (
git pull
without extra arguments).
- Where to push changes (
Example without upstream
Suppose you’re on main
and you type:
git push
Git might complain:
fatal: The current branch main has no upstream branch.
Because it doesn’t know which remote branch it should push to.
Example with upstream
Now, if you run:
git push -u origin main
origin
: remote repomain
: branch on the remote
This sets origin/main
as the upstream branch for your local main
.
From now on:
git push
: pushes toorigin/main
automatically.git pull
: pulls fromorigin/main
automatically.git status
: shows if your localmain
is ahead/behindorigin/main
.
Think of upstream like setting a default shipping address in an online store:
- Once set, you don’t need to type the address each time.
- Without it, you must enter the address every single order.
Show detailed upstream config
git rev-parse --abbrev-ref --symbolic-full-name @{u}
This prints the full name of the upstream branch your current branch is tracking, e.g.:
origin/main
If no upstream is set
You’ll get an error like:
fatal: no upstream configured for branch 'main'
In that case, you can set it with:
git push -u origin main
After this, whenever you want to push to the new repo, just run:
git push new-origin
You Can Also Change the remote URL
Instead of adding a new remote_name, just update the existing origin
:
git remote set-url origin https://github.com/username/new-repo.git
This will set the remote-url of mention git repo to origin
basically it update teh remote-url
OR with (SSH)
git remote set-url origin [email protected]:username/new-repo.git
How to Install Cisco VPN AnyConnect Client in Linux, Ubuntu
1.Install the dependencies bu running the below commands
sudo apt update
sudo apt-get install libpango-1.0-0 libcanberra-gtk-module
2. visit the site https://vpn.nic.in/ ,
move to
software
menuclick on
VPN client for Linux 64-bit
it will download the
anyconnect-linux-64-5.1.8.122-k9.tar.gz
file
3.Extract the downloaded file
4.Move to the VPN
directory and run the below command
sudo ./vpn_install.sh
wget
wget
is a command-line utility used to download files from the internet in Linux, macOS, or Windows (via WSL or Cygwin). It’s very common for downloading .deb
packages, scripts, or any file over HTTP, HTTPS, or FTP.
1.Basic usage
wget <URL>
Example:
wget http://example.com/file.txt
This will download file.txt
to the current directory.
2.Download and save with a custom name:
wget -O newname.txt http://example.com/file.txt
-O
specifies the filename you want.
3.Resume interrupted downloads:
wget -c http://example.com/largefile.zip
-c
continues downloading if it was stopped.
4.Download in background:
wget -b http://example.com/largefile.zip
This lets the download continue in the background.
5.Recursive downloads (download entire websites):
wget -r http://example.com
Example:
wget http://mirrors.kernel.org/ubuntu/pool/universe/p/pangox-compat/libpangox-1.0-0_0.0.2-2_amd64.deb
This command downloads the old libpangox
package directly to your system so you can install it with dpkg
.
dpkg
dpkg
is the low-level package management tool for Debian-based systems (like Ubuntu). It is used to install, remove, and manage .deb
packages directly. Think of it as the underlying engine behind apt
and apt-get
.
Debian Package
It’s essentially the Debian package management tool used to install, remove, and manage .deb
files on Debian-based systems like Ubuntu.
dpkg
handles the low-level operations on packages.- Tools like
apt
andapt-get
are high-level frontends that usedpkg
under the hood to manage packages and dependencies.
1.Install a package:
sudo dpkg -i package_name.deb
-i
stands for install.
This installs the .deb
file you downloaded with wget
.
2.Remove a package:
sudo dpkg -r package_name
Removes the package but leaves configuration files.
sudo dpkg --purge package_name
Removes package + configuration files completely.
3.List installed packages:
dpkg -l
Shows all packages installed on your system.
4.Check package details:
dpkg -s package_name
- Displays info like version, description, dependencies, and status.
5.List files installed by a package:
dpkg -L package_name
dpkg -l | grep zip
Useful to see where files are installed.
6.Check dependencies:
dpkg -I package_name.deb
- Lists info about a
.deb
file without installing it.
If dpkg
fails due to missing dependencies, run:
sudo apt-get install -f
This fixes missing dependencies automatically.
Difference Between dpkg
and apt
Feature | dpkg | apt / apt-get |
---|---|---|
Scope | Low-level, handles single .deb files | High-level, resolves dependencies from repositories |
Dependencies | Does not automatically install dependencies | Resolves dependencies automatically |
Use case | Installing downloaded .deb files | Installing packages from repos |
Ctrl + Shift + P (for crome browser)
Install zip and download zip file
1.install zip (if not installed)
sudo apt update
sudo apt install zip
2.Zip the folder
Suppose your folder is named my_folder
and you want the zip file to be my_folder.zip
:
zip -r my_folder.zip my_folder
-r
recursively includes all files and subfolders insidemy_folder
.my_folder.zip
? the output zip file.my_folder
? the folder you want to compress.
3. Verify the zip file
ls -lh my_folder.zip
This shows the zip file size and confirms it exists.
4. Downloading (if you’re on a remote server)
If your Linux terminal is on a remote server and you want to download to your local machine:
- Using
scp
(from your local machine): scp username@remote_server:/path/to/my_folder.zip /local/path/
- Using
wget
orcurl
(if served via HTTP) is another option. wget -O my_file.zip http://example.com/path/to/file.zip
curl -O http://example.com/path/to/file.zip
-O
keeps the original file name.- To save with a specific name:
curl -o my_file.zip http://example.com/path/to/file.zip
If the server requires authentication:
wget --user=username --password=password http://example.com/file.zip
curl -u username:password -O http://example.com/file.zip
You can resume interrupted downloads with -c
in wget
:
wget -c http://example.com/file.zip
How to unzip
1.Using unzip
command (you might need to install it first):
sudo apt update
sudo apt install unzip # if not already installed
2.Unzip a file:
unzip filename.zip
This will extract the contents into the current directory.
3.Unzip to a specific folder
unzip filename.zip -d /path/to/destination/
4.List contents without extracting:
unzip -l filename.zip
Isssue while downloading the mysqlclinet in python
pip install mysqlclient
if it shown issues
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
means that the system dependencies for MySQL development are missing. The mysqlclient
Python package needs MySQL headers and client libraries to build.
sudo apt update
sudo apt install python3-dev default-libmysqlclient-dev build-essential pkg-config
python3-dev
? headers for Python (needed to compile C extensions)default-libmysqlclient-dev
? MySQL client libraries and headersbuild-essential
? compiler toolspkg-config
? helps find the libraries
Install web version of pgadmin
Run pgAdmin4 in a browser (web mode)
If you want it lightweight, you can install the web version instead:
sudo apt install pgadmin4-web -y
Then configure and start:
sudo /usr/pgadmin4/bin/setup-web.sh
It will ask you to set an admin email/password.
Then you can open pgAdmin4 in your browser:
http://127.0.0.1:5050
Hit the command to start the pgadmin server
pgadmin4
In pgAdmin4, server connections (not the actual databases, just the saved connection details) are stored in a SQLite DB called pgadmin4.db
.
SSH Key
1. Check if you already have an SSH key
On your local machine, run:
ls -al ~/.ssh
If you see files like id_rsa
& id_rsa.pub
(or id_ed25519
& id_ed25519.pub
), you already have a key pair.
2. Generate an SSH key (if you don’t have one)
ssh-keygen -t ed25519 -C "[email protected]"
ed25519
- Modern, secure, and fast.
- Uses smaller keys but is very strong.
- Default choice for most cases today.
- Not supported on very old systems (rare).
you can used rsa as well like:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Widely supported and compatible with almost every system.
-b 4096
sets the key length (longer = more secure; 4096 is recommended).- Larger key size than
ed25519
, so slightly slower for encryption.
Press Enter for defaults. This will create:
~/.ssh/id_ed25519
(private key – keep it safe!)~/.ssh/id_ed25519.pub
(public key – to share with the server)
3. Copy your public key to the server
ssh-copy-id [email protected]
If ssh-copy-id
is not available, do it manually:
cat ~/.ssh/id_ed25519.pub
Copy the output and then (if you have console/other access to the server), add it to:
/home/dev/.ssh/authorized_keys
4. Retry SSH
ssh username@ip_address
5. If password login is required but disabled
The server might have disabled password login in /etc/ssh/sshd_config
with:
PasswordAuthentication no
In that case, you’ll need server/console access to either:
- Add your key to
authorized_keys
, or - Enable password login temporarily.