
Building Your Portfolio Experience
Loading Tariqul Islam's projects...
Loading Tariqul Islam's projects...
A comprehensive all-in-one command guide for managing MongoDB, PostgreSQL, Linux, and Git efficiently on Ubuntu VPS for development and production use.
# Connect to MongoDB shell
mongosh
# Switch or create a database
use your_db_name
# Show all databases
show dbs
# Show collections in current DB
show collections
// Insert one document
db.users.insertOne({ name: 'John', age: 30 });
// Insert many
db.users.insertMany([{ name: 'A' }, { name: 'B' }]);
// Read all documents
db.users.find();
// Filtered query
db.users.find({ name: 'John' });
// Update document
db.users.updateOne({ name: 'John' }, { $set: { age: 31 } });
// Delete one document
db.users.deleteOne({ name: 'John' });
// Delete many documents
db.users.deleteMany({});
// Create index
db.users.createIndex({ name: 1 });
// Create new user
db.createUser({
user: 'admin',
pwd: 'securepassword',
roles: [{ role: 'readWrite', db: 'your_db_name' }],
});
# Login to postgres
psql -U postgres
# List all databases
\l
# Connect to a database
\c your_db
# List tables
\dt
-- Create table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT,
age INT
);
-- Insert
INSERT INTO users (name, age) VALUES ('John', 30);
-- Select
SELECT * FROM users;
-- Update
UPDATE users SET age = 31 WHERE name = 'John';
-- Delete
DELETE FROM users WHERE name = 'John';
-- Create user
CREATE USER myuser WITH PASSWORD 'mypassword';
-- Grant privileges
GRANT ALL PRIVILEGES ON DATABASE your_db TO myuser;
pwd # Show current directory
ls # List files/folders
cd folder_name # Change directory
cd .. # Go back one directory
touch file.txt # Create empty file
mkdir my_folder # Create folder
cp file.txt copy.txt # Copy file
mv file.txt folder/ # Move file
rm file.txt # Remove file
rm -r folder_name # Delete folder
whoami # Current user
uname -a # System info
df -h # Disk usage
free -m # RAM usage
uptime # System uptime
ip a # Show IP addresses
ping google.com # Ping test
netstat -tulpn # Listening ports
curl ifconfig.me # Public IP
sudo apt update # Update package list
sudo apt upgrade # Upgrade packages
sudo apt install nginx # Install a package
sudo apt remove nginx # Remove a package
chmod +x file.sh # Make script executable
chown user:user file # Change ownership
sudo -i # Switch to root
git init # Initialize git repo
git clone https://url.com/project # Clone repo
git remote add origin URL # Add remote
git status # Show changes
git add . # Stage all changes
git commit -m "Message" # Commit
git branch # List branches
git checkout -b new-branch # Create and switch
git checkout main # Switch branch
git merge branch-name # Merge branch
git push -u origin main # Push to main
git pull origin main # Pull latest
sudo systemctl start nginx # Start service
sudo systemctl stop nginx # Stop service
sudo systemctl restart nginx # Restart service
sudo systemctl status nginx # Service status
crontab -e # Edit cron jobs
* * * * * /path/to/script.sh # Every minute
sudo apt install git
sudo apt install curl
sudo apt install build-essential
sudo apt install nodejs npm
sudo apt install mongodb
sudo apt install postgresql
history # Show all previous commands
alias gs="git status" # Create alias
reboot # Reboot server
shutdown now # Power off server
Bookmark this guide for your day-to-day DevOps, Server, and Backend needs!