Skip to main content

Posts

My Redis crash course

Redis is an in memory data store often used as cache. Install Redis: sudo apt install redis-server Check status: sudo systemctl status redis Launch Redis CLI: redis-cli Set a key: SET mykey "hello" Get a key: GET mykey Set with expiration: SET tempkey "bye" EX 60 Check keys: KEYS * Redis is extremely fast because it stores data in memory. It is perfect for caching sessions or frequently accessed data. Keep in mind memory usage grows with data size. Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this s...

My PostgreSQL crash course

PostgreSQL is a powerful open source relational database. If you have worked with MySQL before, PostgreSQL will feel familiar but with additional enterprise features. First install PostgreSQL using your package manager. On Ubuntu: sudo apt install postgresql Once installed, check service status: sudo systemctl status postgresql Switch to postgres user: sudo -i -u postgres Enter PostgreSQL prompt: psql To list databases: \l To create a new database: CREATE DATABASE mydb; To connect to it: \c mydb To create a table: CREATE TABLE users ( id SERIAL PRIMARY KEY, name TEXT, email TEXT ); To insert data: INSERT INTO users (name, email) VALUES ('John', '[john@example.com](mailto:john@example.com)'); To query data: SELECT * FROM users; To exit: \q PostgreSQL is reliable, standards compliant, and production ready. Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacke...

My Cron crash course

Cron schedules tasks on Linux. To edit cron jobs: crontab -e Basic format: * * * * * command Fields represent minute, hour, day of month, month, day of week. To run script every day at midnight: 0 0 * * * /home/user/script.sh To list cron jobs: crontab -l Cron is simple yet powerful. Automate backups, cleanup jobs, monitoring scripts and more. Set it once and let it run. Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and...

My Ubuntu UFW Firewall crash course

A firewall controls incoming and outgoing traffic. On Ubuntu you can use UFW. To enable: sudo ufw enable To allow SSH: sudo ufw allow ssh To allow specific port: sudo ufw allow 8080 To check status: sudo ufw status To deny a port: sudo ufw deny 23 Always allow SSH before enabling firewall on remote server or you may lock yourself out. Remember, security is not optional. Configure your firewall. Happy firewalling! Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts...

My Kubernetes crash course

Kubernetes orchestrates containers at scale. Install kubectl and configure it for your cluster. To check cluster info: kubectl cluster-info To see nodes: kubectl get nodes To create a deployment: kubectl create deployment myapp --image=nginx To view pods: kubectl get pods To expose deployment: kubectl expose deployment myapp --type=NodePort --port=80 To scale: kubectl scale deployment myapp --replicas=3 To delete deployment: kubectl delete deployment myapp Kubernetes may look complex at first but the core idea is simple. Define desired state. Kubernetes maintains it. Happy K8ing Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com...

My Bash scripting crash course

Bash scripting automates repetitive tasks. Create a file called script.sh: #!/bin/bash echo "Hello World" Make it executable: chmod +x script.sh Run it: ./script.sh Variables: name="Raheel" echo $name Conditionals: if [ -f file.txt ]; then echo "File exists" fi Loops: for i in 1 2 3 do echo $i done Bash scripting saves time and reduces manual errors. Automate once. Run forever. Happy Bash scripting! Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly proh...

My SSH crash course

SSH allows secure remote login to another machine. To connect: ssh user@server-ip If this is your first time connecting, you will be prompted to accept the host key. To generate an SSH key pair: ssh-keygen Press Enter to accept defaults. Copy your public key to remote server: ssh-copy-id user@server-ip Now you can login without password. To specify a private key: ssh -i mykey.pem user@server-ip SSH is secure, fast, and essential for server management. Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk . My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/o...