Helpful linux commands

  • 7 Replies
  • 896 Views
Helpful linux commands
« on: January 04, 2024, 02:14:41 pm »
There's a few Linux commands that I've found very helpful when things go wrong in my desktop environment. I'm putting them here so I don't forget!

Frozen Gnome UI

Sometimes if there's a bug or memory leak in your Gnome extensions it can cause your computer UI to freeze up but the underlying system is still working. If you press Ctrl + Alt + F[4-9] it will bring you to a terminal login where you can login to your user account and run the following command to reload your extensions.

Code: [Select]
killall -HUP gnome-shell
Audio device failure

Occasionally when watching videos in VLC I've gotten this strange error message:

Code: [Select]
Audio output failed:
The audio device "default" could not be used:
Connection refused.

This happens more frequently when watching short videos that loop. It seems like there is a limit to the number of audio channels that can be allocated at any one time. Once the limit is reached, you can't load audio or video files anymore using VLC, Mplayer, Firefox, etc. The video playback freezes and sound stops working across the system. In order to fix this I run the following commands:

Code: [Select]
systemctl --user restart pipewire.service
systemctl --user restart pipewire-pulse.service

Before I learned about these commands I would have to restart my computer whenever I ran into these issues. Now I don't need to restart anymore!

What other Linux commands are useful for your day to day life?
*spork*

Re: Helpful linux commands
« Reply #1 on: February 04, 2024, 11:14:27 am »
Interactively switch between versions of PHP

If you have multiple versions of PHP installed on your system you sometimes need to switch between which version you're using as the default. Normally web servers are configured to work with specific PHP versions but when you run PHP on the command line, the default will be set to whatever version you most recently installed. This command lets you change which version of PHP you use as the default on the command line:

Code: [Select]
sudo update-alternatives --config php
*spork*

Re: Helpful linux commands
« Reply #2 on: February 04, 2024, 11:29:06 am »
DID U KNO bash has tcp sockets built into it?  So you can do very simple request+response things.  Instead of installing and launching ntpdate, in bash you can

Code: [Select]
cat </dev/tcp/time.nist.gov/13
60344 24-02-04 19:21:25 00 0 0 141.2 UTC(NIST) *

(would you believe I wrote an OAuth2 client in bash using this?  I use it to post music scrobbles to last.fm, but I could use it for Twitter.)

Sometimes a program creates a tooltip, marks it with AlwaysOnTop, and forgets to dismiss it.  This is what I use to find which process owns which window (including immortal tooltips).  Type it, then mouse-click on the vagabond

Code: [Select]
xwininfo -stats
Find the oldest file in all the subdirs of current directory

Code: [Select]
find . -type f -printf '%TY%Tm%TdT%TH%TM %p\n' |sort |tail

RACHEL TIPPED 1337 CORAL FOR THIS POST


Re: Helpful linux commands
« Reply #3 on: February 04, 2024, 11:33:50 am »
Code: [Select]
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,3,5,6,7,10,12",a,","); for (i = 0; i < 1; i+= 0.0001) printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | xxd -r -p | aplay -c 2 -f S32_LE -r 24000
honk honk

Re: Helpful linux commands
« Reply #4 on: February 05, 2024, 12:41:34 pm »
Code: [Select]
cat /dev/urandom | hexdump ... | aplay -c 2 -f S32_LE -r 24000

Oh! I have some of those, not just toys but useful for static noise to drown out working in an open-concept office.  Needs the 'sox' software package that's in every linux distro

Single tone, for a tuning-fork emitting an A3 note
Code: [Select]
play -q -n synth sin A3 fade 0 3 .1
Oscillating brown noise, best for me for concentrating in a noisy place
Code: [Select]
play -n synth brownnoise lowpass -2 512 tremolo .06 62
This one is supposed to be just like the constant engine-hum on the ST:TNG starship Enterprise
Code: [Select]
play -c 2 -n -c1 synth whitenoise lowpass -1 120 lowpass -1 120 lowpass -1 120 gain +10

Re: Helpful linux commands
« Reply #5 on: February 05, 2024, 01:43:18 pm »
Code: [Select]
echo b | sudo tee /proc/sysrq-trigger

Re: Helpful linux commands
« Reply #6 on: February 06, 2024, 05:15:22 am »
Code: [Select]
echo b | sudo tee /proc/sysrq-trigger

Reboots the kernel without first unmounting file systems or syncing disks attached to the system.

1. you did not describe how this helps
2. rebooting without safely unmounting can cause data loss; how is this helpful?

Re: Helpful linux commands
« Reply #7 on: February 06, 2024, 08:22:50 am »
Code: [Select]
echo b | sudo tee /proc/sysrq-trigger

Reboots the kernel without first unmounting file systems or syncing disks attached to the system.

1. you did not describe how this helps
2. rebooting without safely unmounting can cause data loss; how is this helpful?

If I accidentally rm -rf / on my computer, I'm rebooting asap without unmounting the filesystem. That will increase the chance that my files can be recovered. If I'm really lucky, then some rm didn't even hit the disk.
I would not let it boot up after the reboot though, of course.