Useful Linux commands and tips:
To set up resolvconf, the name server information handler (that's what the Synaptic package manager calls it):
# need to sudo the following steps # install resolvconf, using Synaptic or apt-get rm /etc/resolv.conf # on my system, was a link to ../run/resolvconf/resolv.conf ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf resolvconf -u # may need to restart networkingNote that with Linux Mint 21, the systemd-resolve command has been renamed to resolvectl.
To restart Cinnamon without logging out (don't know if this works with MATE):
Atl-F2 (brings up dialog) r<return>
To list the hardware that is installed:
sudo inxi -F
To see what version of Linux Mint is installed:
cat /etc/os-release
To reload the /etc/exports file:
sudo exportfs -raTo see what is currently being NFS exported:
sudo exportfs -s
To convert avi files with vorbis video:
ffmpeg -i file.avi -vcodec h264 -an file.h264 ffmpeg -i file.avi -acodec libfaac file.aac mp4box -add file.h264 -add file.aac file.mp4
To get a vob file from a DVD (dvd://1 means title 1):
mplayer dvd://1 -dvd-device /path/to/dvd/folder -v -dumpstream -dumpfile movie.vob
To restore a postgres cluster from a pg_dumpall --clean command:
psql --user postgres -f <dumpfile> postgres
Cron jobs for me and root:
30 01 * * * /home/username/bin/backup.sh (me) 00 01 * * * sh /home/username/bin/sys-backup.sh (root - perhaps just run manually)
I found the following technique on
this page on stackoverflow.com.
To concatenate two (or more) mp4 files that have the same encoding parameters, create
a text file that lists them, one per line, like so:
file 'video1.mp4' file 'video2.mp4'then issue the following command:
ffmpeg -f concat -safe 0 -i listfile -c copy output.mp4
To add metadata (i.e., chapters) to an mp4 file with ffmpeg, do this (the -map 0 is needed to
prevent the subtitles from being removed):
ffmpeg -i input.mp4 -f ffmetadata -i metadata.txt -map_metadata 1 -map 0 -codec copy output.mp4Note: older versions of ffmpeg may not require the -f ffmetadata option.
To show the volume of an audio file:
ffmpeg -hide_banner -i input.mp4 -af volumedetect -f null -
On Amazon,
Lewis Balentine wrote a review of the PNY Quadro P400 graphics card that includes the following
command for doing a hardware encoding of a ts video file ($f is the ts file):
ffmpeg -hwaccel cuvid -i "$f" -vcodec h264_nvenc -profile:v 2 -g 30 -qp 26 -c:a ac3 "${f%.ts}.mp4"This page on Tom's Hardware shows the following command:
ffmpeg -i [source] -c:v [h264/hevc/av1]_nvenc -b:v [bitrate] -y [output]
To have bash insert the contents of a file into the command line, use this syntax:
$(<file)
.
This link
tells how to make the
ls
command revert to traditional behavior, and
not put quotes around file names with spaces, namely by setting the following
environment variable: QUOTING_STYLE=literal
To make Linux Mint boot in non-graphical mode, do the following:
sudo systemctl set-default multi-user.targetTo revert back, use
graphical.target
instead of multi-user.target
. To see
the current value, do:
sudo systemctl get-default
To prevent Linux Mint from repeatedly adding printers, turn off the cups-browsed service.
Note that when I did this and restarted, I no longer had printers, so I had to re-enable and
start the service.
sudo systemctl stop cups-browsed sudo systemctl disable cups-browsed
To get individual tracks from a flac file that has an entire album (assuming there is
a cue file), do
abcde -d x.flac
To force the displays to sleep, do
sleep 3 && xset dpms force offThe sleep is necessary so lifting the key doesn't wake up the monitor.
To use sox to trim an audio file, do
sox inputfile outputfile trim start durationThe start time is either a floating point number representing seconds, or a time of the format hh:mm:ss.sss. The duration can be specified using the same syntax. Prefixing the duration with a plus sign means from the beginning, prefixing with a minus sing means from the end, and prefixing with an equals sign means an absolute point in the file.
To use sox to normalize an audio file, do
sox inputfile outputfile norm -3The -3 is to avoid clipping. To get stats from a file, do
sox inputfile -n stat