Do you want to
tee the output of a command to a file, but see it in your terminal too, without buffering? The
stdbuf command can do this for you:
$ sudo stdbuf --output=L tcpdump -i any -tttt -n 'udp port 5353' | tee -a tcpdump-mdns
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
2023-06-15 11:55:16.637670 eth0 M IP 10.0.0.23.5353 > 184.108.40.206.5353: 0 A (QM)? winnebago.local. (28)
2023-06-15 11:55:16.744660 eth0 M IP 10.0.0.42.5353 > 220.127.116.11.5353: 0*- [0q] 1/0/0 (Cache flush) A 10.0.0.42 (38)
$ apt-file find guestmount
Are you writing a script and some command doesn’t accept hostnames and you don’t want to inline the IP address?
dig +short is your friend!
$ dig +short gbenson.net
$ apt policy wget
*** 1.21.2-2ubuntu1 500
500 http://gb.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
By the way, if you’ve never used Python’s debugger, it really is as simple as adding a call to the built-in function
breakpoint() at the point you want it to stop.
I discovered a new
sed trick today:
“I” stands for “in place”. It edits the files in place! And makes a backup if you want!
What’s in my container?
$ podman ps --ns
CONTAINER ID NAMES PID CGROUPNS IPC MNT NET PIDNS USERNS UTS
fe11359293e8 eloquent_austin 11090 4026532623 4026532621 4026532421 4026532624 4026531837 4026532622
$ sudo ls -l /proc/11090/root/
lrwxrwxrwx. 1 root root 7 Jul 25 2019 bin -> usr/bin
dr-xr-xr-x. 2 root root 6 Jul 25 2019 boot
drwxr-xr-x. 5 root root 360 Jan 24 12:03 dev
drwxr-xr-x. 1 root root 183 Jan 23 16:43 etc
[28 Jan@1135UTC] UPDATE—Actually, this doesn’t seem to work with newer systems, sorry!
Every couple days something on my RHEL 7 box goes into a swapstorm and uses up all the memory. I think it’s Firefox, but I never figured out why, generally I have four different Firefoxes running with four different profiles, so it’s hard to tell which one’s failing (if it even is that). Anyway, sometimes it makes the screen lock crash or something, and I can’t get in, and I can never remember what process you have to kill to get back in, so here it is:
gnome-shell. You have to
killall -9 gnome-shell, and it lets you back in. Also
killall -STOP firefox and
killall -STOP "Web Content" are handy if the swapstorm is still under way.
So you just installed Fedora, RHEL or CentOS and now you want to build GDB from source.
- How do you make sure everything you need to build it is installed?
# dnf builddep gdb
- Did it say,
No such command: builddep? Do this, then try again:
# dnf install dnf-plugins-core
- Did it say,
dnf: command not found…? You’re using yum, try this:
# yum-builddep gdb
- Did it say,
yum-builddep: command not found…? Do this, then try again:
# yum install yum-utils
Thank you, you’re welcome.
Python‘s had this handy logging module since July 2003. A lot of things use it, so if you’re trying to understand or debug some Python code then a handy snippet to insert somewhere is:
Those two lines cause all loggers to log everything to the console. Check out the logging.basicConfig docs to see what else you could do.