Helpful Linux Commands (Nginx, Pm2, Nano, Docker)
Furkan is a software engineer and frontend developer, whose main purpose is to create best optimal experience for user but also keeping the application or project as performant as possible.
He is deeply interested on web technologies and he is building new projects in this subject. He is especially familiar with React, Vue, Node and Java. You can check out what he built on his GitHub account. There is potential ways to connect with him at the end of this summary 👇
Things he like to do; ✔ Trying to solve other people's struggles ✔ Teaching or telling some subject he know to friends or colleagues ✔ Building different kinds of projects ✔ Meeting & talking with new people ✔ Listening podcasts ✔ Playing Chess ✔ Watching drama | sci-fi movies ✔ Listening music while I travelling or trying to fix problems ✔ Researching next generation technologies like cyptocurrency, IoT, smart devices
If you want to reach out with him, here is how you can do it;
🔼 Blog: https://blog.furkanozbek.com/ 🔼 GitHub: https://github.com/afozbek 🔼 Mail: abdullah.furkan.ozbek@gmail.com 🔼 Twitter: https://twitter.com/afozbek_ 🔼 Instagram: https://instagram.com/furkan.codes/
Thanks for reading ✨
LINUX COMMANDS
- COPY
cp index.js node-server/to the directorycp index.js main.jsto the current directory
- Restart:
sudo reboot - Update-Upgrade
sudo apt-get updatesudo apt-get upgrade - Switch User
su - afozbek - User Add
useradd afozbek-simpleadduser afozbek
- List Users
nano /etc/passwd - Delete User
deluser —remove-home newuser - Add Password to User
passwd afozbek-simple - Add SSH KEY
sudo nano ~/.ssh/authorized_keys - Change SSH Config
sudo nano /etc/ssh/sshd_config - Enable Firewall
sudo ufw enable- List
sudo ufw app list- Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
- Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
- Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
- List
- Look for System is Working Properly
sudo systemctl status sshdsudo systemctl restart ssh
- Look Memory Usage
free -hvmstat -s
NGINX (LIKE APACHE) - Reverse Proxy
What is a Reverse Proxy Server? | NGINX
- Stop
sudo systemctl stop nginx - Restart
service nginx restart - Start
sudo systemctl start nginx- Default HTML location:
/var/www/html
- Default HTML location:
/etc/nginx: The Nginx configuration directory. All of the Nginx configuration files reside here./etc/nginx/nginx.confThe main Nginx configuration file. This can be modified to make changes to the Nginx global configuration.- Access Log:
/var/log/nginx/access.log - Error Log:
/var/log/nginx/error.log
- Access Log:
/etc/nginx/sites-available/: The directory where per-site “server blocks” can be stored. Nginx will not use the configuration files found in this directory unless they are linked to the sites-enabled directory (see below)./etc/nginx/sites-enabled/: The directory where enabled per-site “server blocks” are stored./etc/nginx/snippets: This directory contains configuration fragments that can be included elsewhere in the Nginx configuration.
PM2
pm2 stop app_name_or_idpm2 listpm2 info app- To Start All instance on startup
pm2 startup ubuntu
Nano
CTRL + 6for Mark Set and mark what you want (the end could do some extra help).ALT + 6copy selected lineCTRL + Kfor cutting what you want to copyCTRL + Ufor pasting what you have just cut because you just want to copy.CTRL + Uat the place you want to paste.
DOCKER
How To Install and Use Docker on Ubuntu 18.04 | DigitalOcean
- Add User to Docker Group
sudo usermod -aG docker username - Check User is in the Docker Group
id -nG - To view system-wide information about Docker, use:
docker info - Find and download(if not exist) an image from Docker Hub:
docker run {image}- Ex:
docker run hello-world
- Ex:
- Search and list images :
docker search {image}- Ex:
docker search ubuntu
- Ex:
- Run a Container and switch to the interactive terminal(-it)
docker run -it ubuntu
- Listing containers
- List running containers
docker ps - List stopped containers
docker ps -f “status=exited” - List all containers
docker ps -a - View latest container
docker ps -l
- List running containers
- Start or Stop a container with its containerId
docker start {containerId}docker stop {containerId}
- Remove a container with its containerId or name
docker rm {containerId}docker rm {name}
- Remove an image with its imageId or name
docker rmi {imageId}docker rmi {name}
- Start a container with giving a custom name with —name
docker run --name newName {imageName}
- Manage your changes
- Commit:
docker commit -m "added Node.js" -a "{userName}" {containerId} "{userName}"/{newImageName} - Push
docker push {userName}/{imageName}
- Commit:
- Listing the Docker images - (You can see your new image there 😁)
docker images
- Login to Docker Hub
docker login -u {docker-registry-username}




