CLI Fu: Difference between revisions

From Traxel Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 148: Line 148:


If these methods do not resolve the issue, the problem may lie with the hardware of the drive, USB port, or cable. Consider trying a different port or cable.
If these methods do not resolve the issue, the problem may lie with the hardware of the drive, USB port, or cable. Consider trying a different port or cable.
= Portable Drives =
<pre>
udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1
</pre>

Revision as of 18:14, 9 March 2024

systemctl

systemctl list-units --type=service --all | grep active| grep -v inactive

Image Magick

Convert, noclobber:

ls webp/*webp | sed 's/webp//g' | awk '{print "[ -f png"$1"png ] || convert webp"$1"webp png"$1"png"}'

Convert, noclobber, thumbnail:

ls png/*png | sed 's/png//g' | awk '{print "[ -f jpg"$1"jpg ] || convert -thumbnail 256x256 png"$1"png jpg"$1"jpg"}'

Awk

Using Awk for sums:

ls -l | awk '{print $5}' | awk '{sum += $1} END {print sum}'
ls -l | awk '{sum += $5} END {print sum}'

Backup Audio CDs

Backup Backup

rsync -navz --size-only --delete /media/bob/Seagate\ Backup\ Plus\ Drive/Media/ /media/bob/Seagate\ Portable\ Drive/Media/

remove -n for live fire

Store Image

cdrdao read-cd --read-raw --driver generic-mmc:0x20000 --datafile cdimage.bin cdimage.toc && toc2cue cdimage.toc cdimage.cue
cdrdao read-cd --read-raw --datafile audiocd.bin --device /dev/cdrom --driver generic-mmc-raw audiocd.cue

Convert BIN/CUE to Ogg Format

To convert a `audiocd.bin` and `audiocd.cue` file to Ogg format, you'll need to follow a two-step process:

  1. Split the raw BIN audio file into individual tracks using the CUE sheet.
  2. Convert the individual tracks to Ogg format.

Here's a step-by-step guide:

1. Install Necessary Tools:

Depending on your distribution, you'll need to install some tools. For the purpose of this guide, we'll use `cuetools` and `shntool` for splitting, and `ffmpeg` for conversion.

  • Debian/Ubuntu:
sudo apt-get install cuetools shntool ffmpeg vorbis-tools
  • Fedora:
sudo dnf install cuetools shntool ffmpeg vorbis-tools

2. Split the BIN File into Individual Tracks:

Navigate to the directory containing your `.cue` and `.bin` files and run:

shnsplit -f audiocd.cue -t "%n-%t" -o wav audiocd.bin

This will produce WAV files named like `01-Trackname.wav`, `02-Trackname.wav`, etc.

3. Convert WAV Files to Ogg Format:

for file in *.wav; do
    ffmpeg -i "$file" "${file%.wav}.ogg"
done

This script will iterate over each WAV file and convert it to Ogg using `ffmpeg`. The resulting files will have the same base name as the original WAV files but with an `.ogg` extension.

4. Clean Up (Optional):

If you're satisfied with the Ogg files and no longer need the WAV files, you can delete them:

rm *.wav

You should now have individual Ogg tracks extracted from your audio CD BIN/CUE image.

Summary

shnsplit -f audiocd.cue -t "%n-%t" -o wav audiocd.bin
for file in *.wav; do
    ffmpeg -i "$file" "${file%.wav}.ogg"
done
rm *.wav

DVD Handling

Resetting a USB DVD Drive in Linux

If your USB DVD drive becomes unresponsive in Linux, you can attempt to reset it without rebooting your system by following these steps:

Identify the USB Device

Use the lsusb command to list all USB devices and find your DVD drive:

lsusb
Bus 002 Device 005: ID 152d:0562 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge

Check the Device Status

Use dmesg or look at /var/log/syslog or /var/log/messages for any specific issues.

USB Device Reset

Reset the USB device by echoing a special value to the /sys directory:

echo 0 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized
echo 1 | sudo tee /sys/bus/usb/devices/usb[Bus]/[Bus]-[Device]/authorized

Replace [Bus] and [Device] with the appropriate numbers from the lsusb output.

Unloading and Reloading the Kernel Module

If you know the kernel module for your USB drive, unload it:

sudo rmmod uhci_hcd

And reload it:

sudo modprobe uhci_hcd

Restarting the udev Service

Restart the udev service, which manages device nodes:

sudo service udev restart

Using usbreset

Compile and use the usbreset program for a more convenient reset.

Note: Replace uhci_hcd with the module specific to your system. Always ensure no process is using the device before attempting a reset.

Caution: Resetting kernel modules and USB devices can lead to an unstable system state. Use these commands carefully and ensure you're not affecting other essential USB devices.

If these methods do not resolve the issue, the problem may lie with the hardware of the drive, USB port, or cable. Consider trying a different port or cable.

Portable Drives

udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1