Originally sourced from stack exchange. modified a bit:
https://unix.stackexchange.com/questions/129599/test-tar-file-integrity-in-bash
Modified from the source link above, the following command will iteratively test each .tgz file within the current directory for errors, and if any are detected, will report an error.
$ for i in *.tgz; do echo "Testing $i..."; if tar xOfz $i &> /dev/null; then echo "Error with tarball $i"; fi; done
Options used:
x - Extract from archive
O - Write output to standard out instead of disk
f - Read input from a file
z - Tarball is compressed with Gzip (Some OSes may automatically detect Gzip and not need this option)
&> /dev/null - Redirect both stdout and stderr to /dev/null
Tuesday, September 17, 2019
Misc. Linux Sysadmin tips
Got around to updating the home office machines, and thought it would be a good idea to keep some recurring tips handy:
Disabling SSH login for root user
Disabling SSH login for root user
- Edit /etc/ssh/sshd_config
- Set PermitRootLogin to no (Remove # if present)
- Add AllowUsers
- Save, then restart sshd:
$ service sshd restart
Setup Passwordless SSH:
- Create SSH keypair with options, such as:
$ ssh-keygen -b 5120 - chmod created keypair:
$ chmod 600 - SCP the public key to target machine.
- On target machine:
$ mkdir ~/.ssh$ chmod 700 ~/.ssh - If ~/.ssh/authorized_keys doesn't exist:
move the public key from home folder to ~/.ssh/authorized_keys then
$ chmod 600 ~/.ssh/authorized_keys - If it does exist, then append the public key to the authorized_keys:
$ cat>> ~/.ssh/authorized_keys , then delete the public key. - Test by SSHing to the target machine
Editing Hostnames
- Edit /etc/sysconfig/network. modify HOSTNAME= to FQDN
- Edit /etc/hosts. Add IP address with FQDN and shortname
- Restart network services:
$ /etc/init.d/network restart
Wednesday, April 4, 2018
com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Grrrrrr.
I've had my Mac Pro 6,1 for a few months and noticed that the display crashes every few weeks, where the symptoms range from 1) screen is "frozen as-is", 2) while mouse cursor can move 3) Cannot click on anything on the screen. 4) System clock on screen is stuck at the time the displays froze, and 5) System is still responsive through SSH.
While there was some discussion on various boards about the issue being due to the AMD FirePro D500 and D700 cards, I have a pair of D300s in this unit, which aren't supposed to be impacted by the known Apple Issue.
This occurred again recently and after getting some time to dig into things further, I looked into /var/log/system.log file to see what was the most recent entries prior to the latest freeze episode.
Found the following:
Output snippet from /var/log/system.log
Apr 4 11:01:18 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 4 11:01:28 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 4 11:01:38 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 4 11:01:58 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 4 11:02:28 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
In digging around the web, found the above link on Stackexchange that talks about this issue being related to a particular issue with out an Apple plugin is behaving badly, and lists instructions on how to temporarily disable it:
Here's the overall steps taken:
Sourced from Stackechange article:
https://apple.stackexchange.com/questions/304745/mirrordisplays-error-every-30-seconds-in-system-log
- Disable System Integrity Protection so you can edit the .plist file. Do this by rebooting into the recovery partition with cmd-R, open Terminal from the Utilities menu, and type:
$ csrutil disable - Reboot, then edit the .plist file with this command:
$ sudo vi /System/Library/LaunchAgents/com.apple.preference.displays.MirrorDisplays.plist - Comment out the line that causes the MirrorDisplays tool to load. Change this line:

- To this:

- Then, reboot and re-enable System Integrity Protection using the recovery partition as described above and type:
$ csrutil enable - Reboot
After implementing the changes, it appears that this has stopped the occurrence:
$ grep "MirrorDisplays): Service only ran" system.log | cut -d ':' -f1 | uniq -c
164 Apr 4 11
172 Apr 4 12
47 Apr 4 13
3 Apr 4 14
It's now almost 4pm and no occurrences since disabling! Keeping fingers crossed that this will fix the freezing scenario, otherwise will continue trudging through the system.log file on the next freeze.
Labels:
crash,
csrutil,
cursor,
freeze,
High Sierra,
mac osx,
Mac Pro,
mirror displays,
mouse,
OSX,
SSH,
system.log,
Trashcan Mac
Tuesday, January 9, 2018
Random sleep time in Bash
Recently, I needed to setup a script that would sleep a certain number of seconds between 1 and 8. Stumbled across this particular item, which was adapted to my need:
$ sleep $[ ( $RANDOM % 8 ) + 1 ]s
This would sleep anywhere from 1 second to 8 seconds before continuing. If the need comes up to set to a different limits, you can change the 8 to the max number and the 1 to the minimum. Note that increasing the minimum value will affect the max number as well if min > 1.
Sourced from: http://blog.buberel.org/2010/07/howto-random-sleep-duration-in-bash.html
$ sleep $[ ( $RANDOM % 8 ) + 1 ]s
This would sleep anywhere from 1 second to 8 seconds before continuing. If the need comes up to set to a different limits, you can change the 8 to the max number and the 1 to the minimum. Note that increasing the minimum value will affect the max number as well if min > 1.
Sourced from: http://blog.buberel.org/2010/07/howto-random-sleep-duration-in-bash.html
Saturday, September 16, 2017
Adding Ctrl-Shift-Tab and Ctrl-Tab to Logitech Mouse buttons in Ubuntu
What was very helpful was setting up Ubuntu 16.10 to allow the "back" and "forward" buttons on my wireless Logitech mouse to map to Ctrl-Shift-Tab and Ctrl-Tab respectively, to more closely mimic a better workflow for navigating through massive web tabs.
1) Install needed libs in Ubuntu 16.10:
$ sudo apt-get install -y xbindkeys xautomation xev
2) Create xbindkeys rc file if not already created:
$ xbindkeys --defaults > ~/.xbindkeysrc
3) Append this to ~/.xbindkeysrc:
4) Re-run xbindkeys
$ kill $(ps aux | grep xbindkeys$ | awk '{print$2}'); xbindkeys
Information originally sourced from these links:
https://linux.die.net/man/1/xte
https://askubuntu.com/questions/152297/how-to-configure-extra-buttons-in-logitech-mouse
1) Install needed libs in Ubuntu 16.10:
$ sudo apt-get install -y xbindkeys xautomation xev
2) Create xbindkeys rc file if not already created:
$ xbindkeys --defaults > ~/.xbindkeysrc
3) Append this to ~/.xbindkeysrc:
4) Re-run xbindkeys
$ kill $(ps aux | grep xbindkeys$ | awk '{print$2}'); xbindkeys
Information originally sourced from these links:
https://linux.die.net/man/1/xte
https://askubuntu.com/questions/152297/how-to-configure-extra-buttons-in-logitech-mouse
Monday, August 14, 2017
Enabling 1080p recording on Techsmith's Camtasia (Mac)
Sourced from: https://feedback.techsmith.com/techsmith/topics/1080p-recording
The webcam recording in Camtasia is factory-limited to 720p for performance reasons, but can be user-modified. There are two preferences needed to implement the change, maxCameraWidthRecordingScreen and maxCameraWidthNotRecordingScreen.
To set the preferences, implement the following in a Mac Terminal:
$ defaults write com.techsmith.camtasia2.plist maxCameraWidthRecordingScreen -int 1920$ defaults write com.techsmith.camtasia2.plist maxCameraWidthNotRecordingScreen -int 1920
This should be done when Camtasia is not running.
NOTE regarding the Camtasia Application:
If you are running the non App Store build, the plist is
~/Library/Preferences/com.techsmith.camtasia2.plist .
If you are running an App Store build, it is ~/Library/Containers/com.techsmith.camtasia2/Data/Library/Preferences/com.techsmith.camtasia2.plist .
The webcam recording in Camtasia is factory-limited to 720p for performance reasons, but can be user-modified. There are two preferences needed to implement the change, maxCameraWidthRecordingScreen and maxCameraWidthNotRecordingScreen.
To set the preferences, implement the following in a Mac Terminal:
$ defaults write com.techsmith.camtasia2.plist maxCameraWidthRecordingScreen -int 1920$ defaults write com.techsmith.camtasia2.plist maxCameraWidthNotRecordingScreen -int 1920
This should be done when Camtasia is not running.
NOTE regarding the Camtasia Application:
If you are running the non App Store build, the plist is
~/Library/Preferences/com.techsmith.camtasia2.plist .
If you are running an App Store build, it is ~/Library/Containers/com.techsmith.camtasia2/Data/Library/Preferences/com.techsmith.camtasia2.plist .
Thursday, June 1, 2017
Allow .mp4 files to be streamable on simple Apache Webserver
Sourced from http://blog.servergrove.com/2012/04/18/configuring-your-apache-web-server-for-html5-video-formats/
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
Subscribe to:
Posts (Atom)