Linux Tips¶
while loop¶
Heredoc¶
Send a block of text to a command via standard input
Using cat¶
Note, this write to file.txt. Use >> file.txt to append
But this doesn't work well with sudo - so better use tee
Using tee¶
xarg with awk¶
J'suis une flemme:
tmux¶
How to enable logging in tmux?
To log tmux pane output to a file, use the pipe-pane command with a shell command that redirects to a file. i
Start logging current pane¶
Stop logging¶
Log with timestamp in filename¶
USB to Serial Adapter on MacOS¶
On macOS you basically need to (1) find the serial device file under /dev, then (2) attach with screen.
1. Plug in the USB–serial adapter and identify the device¶
Open Terminal and run:
Then unplug the adapter, run the same command again, and compare. The new entries that disappear/appear when you plug/unplug are your adapter, typically named like:
- /dev/tty.usbserial-XXXX
- /dev/tty.usbmodemXXXX
- /dev/tty.SLAB_USBtoUART
- /dev/tty.wchusbserialXXXX
The /dev/tty. or /dev/cu. version both work; I usually use /dev/tty.*.
If nothing new appears, you likely need a driver for the adapter chipset (FTDI, Prolific, Silicon Labs, etc.) from the vendor, then repeat the check above.
2. Connect with screen¶
Once you know the device, connect to the router console like this:
Replace:
/dev/tty.usbserial-XXXXwith your actual device path- 9600 with the router’s serial speed (common values: 9600, 19200, 38400, 57600, 115200; many routers use 9600 or 115200)
3. Exiting screen¶
To quit screen cleanly:
- Press
Ctrl + A - Then press
\(backslash) - Confirm with
yif prompted