linux

Exclude node modules in tree output

List of latest tools available in the market

Sam
Do you wish to display only the folders excluding the node_modules or bower_components folder ? tree -I "node_modules|bower_components" Now the output should look clean excluding the node_modules or bower_components folder. sam@SamsMacBookPro ~/w/t/t/blog-app (main)> tree -I "node_modules|bower_components" . ├── README.md ├── app │ ├── favicon.ico │ ├── globals.css │ ├── layout.js │ └── page.js ├── jsconfig.json ├── lib │ └── db.js ├── next.config.js ├── package-lock.json ├── package.json ├── pages │ ├── api │ │ └── posts.

Find which process is using your port

Find which process is using your port

Sam
At times, you get address in use error for web servers in development environment. Use lsof to find out the process using the port. # to get all the ports sudo lsof -nP -iTCP -sTCP:LISTEN # to get a particular port sudo lsof -nP -iTCP:3000 -sTCP:LISTEN

Making Raspberry Pi to work with MQTT.

step by step guide on mqtt

Sam
Pre-requisites: Have Raspberry Pi. Raspbian OS installed and WiFi / LAN cable connected to your router and have an IP address to connect it to. If you have not installed Raspbian, head over here and install it on SD Card and boot it. Connect to your Raspberry Pi via Putty Client on Windows or Terminal on Mac / Linux Let us see what is the debian version we have

Important Network Commands in Linux

1. lsof lsof -i To find the process which uses a port 8080, lsof -i :8080 To find the process which uses a TCP port 3005, lsof -i tcp:3005 I often have trouble finding a process which uses a port. I used the lsof command to find the process which uses a port. then I kill the process using the kill command. kill -9 PID

Text processing with awk sed and cut

awk sed and cut - tools to process text data in Linux OS

Sam
awk openstack image list > images.txt +----------------+--------------+-----------+ | ID | Name | Status | +----------------+--------------+-----------+ | 9789-4b3f-95b8 | windows-2012 | active | | 27a3-46c2-b821 | windows-2016 | active | | f45a-4c89-a69f | windows-2019 | active | | 012f-4751-822a | windows-2019 | active | | 68c8-4d4b-a5b5 | windows-2022 | active | +----------------+--------------+-----------+ extract only windows-2016 image id # on a bash or zsh shell ID=`awk '$4=="windows-2016" {print $2}' images.txt` echo $ID 27a3-46c2-b821 # on a fish shell set ID $(awk '$4=="windows-2016" {print $2}' images.

Vim Text editor - tips and tricks

Vim Text editor - tips and tricks in Linux OS

Sam
VIM Tricks # move the current to the above line or swap the current line with previous one ddkP # copy all lines in a file # % - next command to work on all lines # y - yank those lines # + - copy to the system clipboard :%y+ # the other way of copying all lines of code # gg - get the curser to the first line # "*y - to start a yank command to the register * from the first line, until.