Skip to main content

Posts

My MongoDB crash course

MongoDB is a NoSQL database that stores data in flexible JSON like documents. Unlike relational databases, MongoDB does not require a fixed schema. This makes it very convenient for applications where structure may evolve over time. First install MongoDB. On Ubuntu you typically add the official MongoDB repository and then install: sudo apt install mongodb Once installed, check service status: sudo systemctl status mongodb If it is not running, start it: sudo systemctl start mongodb To access MongoDB shell: mongo You should now be inside the MongoDB interactive shell. To show databases: show dbs To create or switch to a database: use mydb MongoDB creates the database automatically when you first store data. To insert a document: db.users.insertOne({ name: "John", email: "[john@example.com](mailto:john@example.com)", age: 30 }) To find documents: db.users.find() To pretty print results: db.users.find().pretty() To update a docum...
Recent posts

My HTOP crash course

Htop is an interactive process viewer. Install: sudo apt install htop Run: htop You will see CPU usage, memory usage, and running processes. Use arrow keys to navigate. Press F9 to kill a process. Press F10 to exit. Htop is easier to read than traditional top command. Monitoring your system regularly helps prevent surprises. 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 clear credit is given to author and this ...

My Rsync crash course

Rsync synchronizes files between systems. To copy directory locally: rsync -av source/ destination/ To copy to remote server: rsync -av source/ user@server:/path/ To delete files at destination that no longer exist in source: rsync -av --delete source/ destination/ To exclude directory: rsync -av --exclude 'node_modules' source/ destination/ Rsync is efficient because it transfers only differences. It is ideal for backups. 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 prohibit...

My Fail2Ban crash course

Fail2Ban protects servers from brute force attacks. Install: sudo apt install fail2ban Check status: sudo systemctl status fail2ban Default configuration is usually sufficient for SSH. To view banned IPs: sudo fail2ban-client status sshd Configuration files are in: /etc/fail2ban/ Fail2Ban adds a layer of automated protection to your server. Security should be proactive. 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 Tcpdump crash course

Tcpdump captures network packets. Install tcpdump: sudo apt install tcpdump Capture packets on interface: sudo tcpdump -i eth0 Capture specific port: sudo tcpdump -i eth0 port 80 Save capture to file: sudo tcpdump -i eth0 -w capture.pcap Read saved file: tcpdump -r capture.pcap Tcpdump helps diagnose network issues quickly. Use with caution on production systems. 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 clear cred...

My Makefile crash course

Make automates build processes. Create a file named Makefile: all: gcc main.c -o app To run: make To clean build artifacts: clean: rm -f app Run: make clean Make uses tabs before commands. Spaces will not work. Make is useful even for small projects. 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 clear credit is given to author and this website with appropriate and specific direction to the original content.

My Curl crash course

Curl is a command line tool for transferring data. To fetch a webpage: curl https://example.com To save output to file: curl -o index.html https://example.com To make a POST request: curl -X POST -d "name=John" https://example.com/api To add header: curl -H "Authorization: Bearer token" https://example.com/api To see headers: curl -I https://example.com Curl is simple and powerful for testing APIs. 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 an...