Linux/Kubuntu – Disable Network Printer Auto Discovery

I don’t know when Kubuntu started automatically discovering printers on networks and then adding them to my list of printers, but it is a problematic feature in certain environments – like universities (where I work).

I set up my home printer on my laptop easy enough. But, whenever I open my laptop and connect to my work network, this feature searches for printers on the network and then adds them to my list of printers. I now have hundreds of printers that show up in my printers dialogue:

I didn’t manually add any of those printers. They were added automatically and are causing problems. First, it’s a pain in the ass to find the printer I want. Second, when I shutdown my computer, the OS has to run through all of those printers and make sure they are disconnected, which makes the OS hang for a couple of minutes every time I want to close down.

This is obviously a great idea in principle, but problematic in this environment.

So, how to turn this off. I found a solution. In a terminal, edit the following file:

sudo nano /etc/cups/cups-browsed.conf

In that file, you should just have to uncomment the following line (remove the hashtag ‘#’):

BrowseProtocols none

So, from this:

To this:

Afterward, try running the commands:

service cups-browsed restart
service cups restart

After making this change, my computer no longer automatically adds shared printers on my network. Hooray!

Unfortunately, making this edit did not remove all the shared printers it had already installed. I still had to remove them all manually, which was annoying. But at least they won’t be reinstalled automatically.

Linux – Failing to Read Encrypted DVDs

Thanks to the fine folks at VLC and Ubuntu, watching DVDs on Linux is generally pretty straightforward. Install “libdvd-pkg” and follow the prompts and you’re generally good to go. That works for me almost all of the time.

However, I recently tried to watch a DVD and had no luck. I would insert the DVD and then wait. With most other DVDs, after about 30 seconds, I’d get a prompt that my Kubuntu 19.04 system had read the DVD and I had several options to proceed (view the files, watch it in VLC, etc.). But with this one, my OS couldn’t even detect that there was a disk in the drive. I tried multiple approaches.

Here’s what K3b indicated:

When I tried loading it in VLC:

And from the command line in VLC:

The problem is not my drive. I regularly load disks in the drive and they work fine, including many disks that have CSS encryption that the libdvd-pkg addresses. But, try as I might, I could not get my computer to even recognize that there was a disk in the drive.

I have a blu-ray player connected to my home entertainment center. Worried that the disk may just be bad, I put it in the blu-ray player and it opened fine. That convinced me that the disk was using some form of encryption that is still not addressed in the libdvd-pkg. I did one final check. I inserted the disk into an old laptop I keep around that has Windows installed on it just to see if this really is a Windows vs. Linux thing. Sure enough, Windows immediately detected it and opened it right up.

After spending a good 5 hours or so trying to find a solution (including installing lots of packages and reading through dozens of threads in Linux forums), I didn’t find a solution. I wrote this post basically just to inform other Linux users that there are some DVDs out there that have encryption that prevent them from being opened in Linux. I’m running the latest version of Kubuntu as of this writing (19.04 beta) with all the suggested packages installed to examine a DVD. But, regardless of what I tried, my OS could not read this disk.

Plex – Syncing Media to Devices

I love my Plex server. It works pretty flawlessly with devices like my Roku or allowing me to listen or view my media collection online. However, there are occasionally instances when I know I either won’t have internet access (e.g., on a plane or on a hike) and I want to have access to my media. Plex still has me covered with the option of “syncing” media to my phone. However, the process isn’t all that intuitive. So, here’s my guide to syncing audio and video to a phone/tablet.

First, choosing what to sync is done, from what I can tell, almost exclusively from the device (with some minor exceptions). Basically, you have to install the Plex app on your device, open the Plex app, log into your account on your device, then find the media you want to sync. (I’m not going to cover install, opening, or logging in with this tutorial, just synching.)

Let’s say I want to synchronize my Simon & Garfunkel albums to my phone so I can play their music when I don’t have internet access. I first have to open the Plex app:

This is how the app looks once it’s open and connected to your Plex server.

Make sure it has detected my Plex server (which is called NewPlex):

I circled my server in this image.

Then I have to find my collection of Simon & Garfunkel music in the Music tab (at the bottom of the screen):

To move between different collections, you click the buttons at the bottom of the app. In this screenshot, I was looking at my Music collection.
I have now selected my Simon & Garfunkel songs.

Once I have done that, syncing is pretty easy. Look for the “down arrow” and touch it:

When you do, you’ll get this screen:

You set your synching options on this screen.

You’ll have the option of adjusting the audio quality (this makes a lot of sense if you’ve got your files stored in FLAC on your file server but want to save space on your phone; if so, convert them). You can also dictate how many songs you want to synchronize. If you put a limit, I’m assuming Plex will just randomly select which ones will syncronize (you can also just download specific songs or albums). When you’ve made your decisions, you click on Save and the transfer process will start.

Here’s where things get kind of interesting. You can now open your Plex dashboard and look for your sync progress. To illustrate, I picked an album I have stored in FLAC on my server and started the conversion process:

Your “Conversions” page in the Plex server settings shows you the files that are being prepared to be transferred to your device.

Once your server has converted everything, it will be sent to your device and you’ll see a little arrow in the corner of synchronized albums, like this:

All the white arrows in circles indicate that these albums have been synchronized with my device – so they are stored on my device.

The process is similar for movies. Click on the “Movies” tab at the bottom of the screen to look through your movies. Once you find the one you want to syncronize, click on it. That same “down arrow” will show up:

Click on the down arrow to synchronize the movie to your device.

Click on it and you’ll get one of the same options as before to choose the quality of the synchronized file.

Once you click Save, the conversion process will start on your Plex server:

Here’s the Conversion screen showing my movie converting before transfer to my phone.

Once the conversion is complete, the file will be sent to your device and you’ll see, similarly, an arrow on the movie indicating it is synchronized with your device.

Finally, there are a few secrets to accessing your synchronized content quickly and easily. If/When you find yourself without internet access, or if you just want to see what you have synchronized with your device, you can click on your icon at the top left of the app and select “Offline Browsing”:

Once you do that, only synchronized content will show up in your tabs, like you see below:

You can also click on the “Downloads & Sync” option in that same menu and see the content that is currently synchronized with your device:

And you can check in the settings dashboard in your Plex server to see what content is synchronized with which device (you can synchronize with multiple devices):

This makes it easy to see what content is synchronized to which device

One last bit of advice. If you want to remove content from a device, you can do so on your phone/tablet or on your Plex server. On your phone, go to your Downloads & Sync list, then select the sync you want to delete. When you do, in the upper right corner there will be a trashcan. Click on it and you can delete the sync.

On the Plex server, in the “Sync” tab, hover over the sync and you’ll see a red X. Click on it, and the synchronized files will be deleted from that device

And if you want to remove a device from your account altogether and get rid of all the synchronizations tied to that device, that is done on the Plex server web interface as well. In the Settings menu, click on Authorized Devices, find the device you want to remove and click on the red X.

That will remove all the synchronizations and prevent it from being able to access your Plex server.

This website was helpful in figuring all of this out.

Linux – Setting Up FTP/SFTP Restricted Access for User

I run a server (Ubuntu 18.04) that hosts about a dozen websites using Linode. Most of the sites are run using WordPress and are my own or sites I manage for friends or family. I do, however, host one for a colleague who actively develops online content for that site.

As WordPress has developed, the ability to upload various file types has slowly been removed for security reasons. As a result, for certain types of files, it is now required to upload them using a different approach. I can do so using SSH, but GUI FTP/SFTP software was going to be easier in this situation as the person responsible for managing that site doesn’t have a lot of knowledge managing a website. I explained to this person, we’ll call her Sharon, that it would be possible for her to upload these files herself using FTP/SFTP. She was worried as she doesn’t know what that is or how to use it. But I explained it and, hopefully, she’ll grow more comfortable with it.

However, I don’t want a novice to gain access to all the files on my server. So, I was faced with the question of how to set up an FTP/SFTP account for someone that is restricted to just one folder – a folder where she can upload stuff and delete files, but with no access to anything else.

Here’s how I did it.

First, you should create a new user group on your server. This can be done with the following command:

sudo addgroup --system GROUPNAME

This will add a new user group called GROUPNAME (I called mine “ftpusers”). If this individual isn’t currently a user on your server, add them as a user as well:

sudo adduser --shell /bin/false USER

Replace “USER” with whatever name you’re using for this individual, for me it was “sharon.” You’ll need to create a password for your USER and fill in some additional information. Then add your USER to your GROUPNAME with the following command:

sudo usermod -a -G GROUPNAME USER

Or my command:

sudo usermod -a -G ftpusers sharon

So, you have now created a new group and a new user and added the new user to the new group. Of course, the next step is to restrict what your new USER can do. In particular, we want the user to have access to just a single directory. Here’s how that is done.

You can create a directory the user can use:

sudo mkdir -p /var/sftp/NEWFOLDER

This folder can be anywhere on your server. I put mine in a subfolder on their wordpress installation:

sudo mkdir -p /var/web/DOMAIN/public/wp-content/uploads/NEWFOLDER

Now, we need to tell the server to restrict USER to this NEWFOLDER when they login. First, let’s give ownership of that folder to the user with the chown command:

sudo chown USER:GROUPNAME /var/sftp/NEWFOLDER

We should also make sure the permissions for the new folder are what we want them to be – read/write for the user and group:

sudo chmod 755 /var/sftp/NEWFOLDER

If you navigate to that folder and check the settings, you should see that the owner is now the USER and the GROUPNAME (you can check with “ls -l”). It’s not a bad idea to also check to make sure that the folder above it is owned by “root” or your primary user, which will prevent your new USER from being able to make changes to that folder.

So far, we have a new USER and GROUPNAME and the user has a folder they can access. However, we need to tell the server that the user needs SFTP access and then need to force them to go to just that one folder when they login with SFTP.

To grant them SFTP access, you need to change the SSH settings:

sudo nano /etc/ssh/sshd_config

This will open the file “sshd_config” with a text editor (nano) so you can make changes. At the end of the file, you want to add the following text:

Match User GROUPNAME
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /var/sftp/NEWFOLDER
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

This allows users in the group GROUPNAME SFTP access to the folder you created for them.

Before you close the nano session with “sshd_config”, you may have to change one other setting. Look for a line that says:

Subsystem sftp /usr/lib/openssh/sftp-server

Mine was not commented out, so that setting was active. However, given the settings we just added to the file, we need to change that. Comment out that line:

#Subsystem sftp /usr/lib/openssh/sftp-server

Below that line, add the following line:

Subsystem sftp internal-sftp

I’m guessing that the original line specified a location for the sftp-server to be used by the server but we want the server to determine the best location for the sftp-server it is going to use and that’s what the second line does. (Alternatively, in the text added to “sshd_config” the line “ForceCommand internal-sftp” could probably be left off, meaning you wouldn’t have to do the step I just described. I haven’t tried that, but it may work.)

Anyway, when you’re done editing the “sshd_config” file, save it and exit from nano.

Finally, to make sure that the new USER is forced into the specified folder when they login, you have to make one more change. This changes the home directory for the user so they are forced into that directory when they login. Here’s the command.

usermod -d /var/sftp/NEWFOLDER USER

This makes the folder you created (NEWFOLDER) the home directory for the USER so, when they log in using SFTP, they will be forced directly into that folder.

There you have it. You have a new user in a group with restricted SFTP access and the user will be forced directly into the folder you created where they can upload, modify, and delete content. They will not have access to anything else on the server, so the rest of your content will be safe.

Acknowledgments: I figured all of the above out with help from these sites: here, here, here, and here.

Plex – How To Create Smart (auto updating) Music Playlists

I love my Plex server. I stream my music basically around the world (I travel regularly). But it took me a while to figure out how to create playlists that automatically update (i.e., “smart playlists”) based on search filters. At home, I use a native music client (e.g., Strawberry or Clementine) to play my music. Clementine, in particular, has excellent smart playlist functionality, allowing me to create a playlist with all of my music in the “Folk” genre or published between 1970 and 1980. With how amazing Plex is, I figured the same functionality had to be possible. I knew I could simply add songs to a playlist manually, but that seemed cumbersome. I’d rather let the software do it for me. Once I figured it out, I thought I’d make the steps clear for others.

Counter-intuitively, the place to start is not in the “Playlists” option on the Plex dashboard, but in the Music panel.

Click on the Music pane, not the Playlists pane.

You’d think that you would create Playlists in the Playlists area, but you don’t. You create all the Playlists in the Music area.

Once you’re viewing your music, you need to look for a drop-down menu. It’s all the way to the left and says “All” with a little arrow next to it.

Click on the little arrow next to “All” to drop down the menu.

What you want to do is click on “Custom Filter.” That will open this option:

Here’s where you create custom filters.

Using that filter option, you can search for, say, all the music in the Genre “Alternative” or “Classic Rock.” Once you’ve entered your search criteria, click the “APPLY” button on the far right and it will apply your search criteria to your music:

Once you apply the search criteria, Plex will show you the music that fits the criteria.

Now, creating a “Smart Playlist” is just one more step. Look to the right of the window for an icon with four little lines and a plus sign. That is the icon for creating a playlist:

This is the icon you want for creating a playlist.

Clicking that button will open a prompt for you to name the new playlist. I typically name mine based on the search criteria, but you can call them whatever you want:

Now, with your Smart Playlist created, you’ll be able to see it in the Playlist area. Click on “Playlists” in the left menu and, assuming you’ve done everything correctly, you’ll see your newly created playlist there:

All of your playlists are in the Playlists area.

The little gear icon that appears in the top left corner of the playlist indicates that it is a “smart playlist” that will automatically update if you add new music to your library that meet your search criteria. Playing the playlist is as easy as hovering over it and then clicking on the play arrow that appears:

Hover over the playlist, then click on the play arrow to play it.

There you go. You can now create as many playlists as you’d like using filtering/search criteria. (This guide helped me figure this out.)

Restarting KDE’s Plasma Shell via Konsole (command line)

As much as I love KDE as my desktop environment (on top of Ubuntu, so Kubuntu), it does occasionally happen that the Plasma Shell freezes up (usually when I’ve been running my computer for quite a while then boot up a game and begin to push the graphics a bit. Often, I just shut down when I’m done and that resets everything. However, there is a quick way to shutdown and restart the Plasma Shell that will bring everything back up.

In KDE Plasma Shell 5.10+, the command to kill the Plasma Shell is:

kquitapp5 plasmashell

In KDE Plasma Shell 5.10+, the command to restart the Plasma Shell is:

kstart5 plasmashell

In earlier versions of KDE 5, the commands were:

killall plasmashell
kstart plasmashell

Linux – Music File Naming Conventions

I have been collecting music files for decades, like a lot of people. My total collection includes over 10,000 tracks. When I built my own NAS recently, I decided it was time to do a careful audit of my music as I hadn’t organized my music in a very long time. In the process, I realized that I had to decide on a clear naming convention system for my music.

Music File and Folder Naming

There are some tricky components to this. Assuming you want all of your music in one main folder (not everyone does), the next question is what level of folder comes next. I’ve typically used the Artist as the next folder, so the folder structure looks like this:

MUSIC -> ARTIST
Written slightly differently:
[MUSIC]/[ARTIST]

I typically use software to manage the renaming and also add the information to the tags at the same time to make this easier. In the process, I realized that the structure above should really be:

MUSIC -> ALBUM ARTIST
Written slightly differently:
[MUSIC]/[ALBUM ARTIST]

The reason it should be “ALBUM ARTIST” rather than just “ARTIST” is for albums that have multiple artists. Albums with multiple artists can get really messy if they aren’t organized by the ALBUM ARTIST, which I usually tag as “VARIOUS ARTISTS,” which means the multi-artist albums all end up in a folder called “VARIOUS ARTISTS.”

However, using “ALBUM ARTIST” can also be advantageous when the album is primarily by one person but they have a guest artist on one or two tracks. Using the primary artist as the “ALBUM ARTIST” solves the problem of the separate tracks being organized in a different folder.

The next level below ALBUM ARTIST is the ALBUM TITLE, like this:

MUSIC -> ALBUM ARTIST -> ALBUM TITLE
Written slightly differently:
[MUSIC]/[ALBUM ARTIST]/[ALBUM TITLE]

This structure generally works for most artists and albums to keep things relatively organized. The next issue is the naming convention for the song files themselves. I don’t think this part matters as much, but I have seen different approaches. Some seem to think that including the name of the artist and the album in the name of the file along with the track number and title of the track is necessary, like this:

[TRACK #] – [ARTIST] – [ALBUM TITLE] – [TRACK TITLE].[file extension]

Alternatively, since the file itself is organized within folders that indicate the artist and album, others use the following convention:

[TRACK #] – [TRACK TITLE].[file extension]

This results in shorter names for the files themselves. I’m not sure that there is a better or worse approach. However, including the artist and album title does run a higher risk of running into a character limit for a track (on most operating systems, files can only have a 255 character name).

In light of the file name length concern, I have opted to go with the second, shorter naming convention. Here’s an actual example from a recent album purchase:

[Music]/[The Head and the Heart]/[Living Mirage]/01 – See You Through My Eyes.flac

Finally, there is also the issue of multi-disc albums. I used to put the different discs into separate folders. Now, I add the disc number at the beginning of the file name, like so:

[DISC#]-[TRACK #] – [TRACK TITLE].[file extension]

Organizing and Naming Software

The software I have used for quite some time for playing my music, Clementine, has had some issues with recent releases, leading me to switch to a forked version called Strawberry. However, as I’ve worked with both of these, I’ve come to realize that their ability to manage ID3 tags and lookup up metadata and tag information is problematic. As a result, I’ve switched to using Picard, that relies on MusicBrainz directly (the other two have implementations of this that are buggy in the latest versions of the software).

Picard also does the best job of actually filling out all of the information in the ID3 container, pulling in as much information as possible. As I result, I’ve switched to using Picard for tagging my music.

As for organizing the files, I switch back and forth between having Clementine/Strawberry organize the files (when I import them, I do this), but when I complete the tag information in Picard, I often have Picard redo this just to make sure everything is organized correctly.

Linux – Fixing “apt-get” failed installation

Occasionally, when I try to install an update or install software via the console using apt-get, something goes wrong. To date, I have never had the failure of a package to install ruin my system. However, it isn’t uncommon after such an incident to get an error the next time I run apt-get. The easiest way to fix apt-get is to run the following command:

sudo dpkg --configure -a

The above command is the replacement for the old command in Debian-based distributions:

sudo dpkg-reconfigure --all

Almost every time I have run into an apt-get error, the above command has been able to solve the problem. It’s a useful command to have on hand if you’re running a Debian-based Linux distribution (like Kubuntu, my distribution of choice).

Linux – Downloading YouTube Videos with VLC

I occasionally need to download a video from YouTube (e.g., my son’s school posts a video of him and I want a copy). There used to be browser extensions to do this. Most of those don’t work anymore. But I did find a new approach that is pretty slick and uses software I already have installed in Kubuntu – VLC. Here’s how to download a video from YouTube using VLC.

First, find the URL of the video. Here’s one of my videos you can download if you’d like: https://www.youtube.com/watch?v=XNvxYB4GUtw.

Second, open VLC. (I’m not going to go over installation of VLC. If you can’t do that, you’ve got bigger issues. 😉 ) On Linux, click on the “Media” menu option and look for “Convert/Save.”

In the window that opens up, click on the “Network” tab, then enter the URL for the YouTube video.

At the bottom of the window, click on “Convert/Save.”

You’ll get a new window. In the new window, choose the format you want to convert the video to in the “Profile” box. Then type in the “Destination” location.

When you’re ready, hit “Start.”

VLC will then play the video. When it’s done, your converted file should be where you told it to be.

(NOTE: Occasionally, the output will be empty. If that happens, when the video finishes playing, VLC will show the playlist view. Right-click on the video in the playlist and select “Save.” You’ll get the same pop up window as above. Over-write the same file and it should work.)

LibreOffice Calc – Creating Charts with Conditional Formatting

I was working on creating a chart in LibreOffice Calc that was kind of weird. Basically, I wanted to show change over time in a dichotomous variable (e.g., political party affiliation in the US – Democrat or Republican). I could, theoretically, make a chart where presence is indicated by “1” and absence is indicated by “0” or “2,” but I didn’t want the chart to suggest that one value was better than the other, which is what such a chart would indicate:

This chart format seems to suggest that Democrats are something and Republicans are not.

I realized, then, that what I needed was a way to tell the software which color to code each bar in the bar chart. Of course, that is possible by clicking on every single bar and customizing the color. But, with my data already indicating whether it should be one color or another and with over 100 cases to code, I was hoping to find a better approach.

I ended up finding a couple of websites (here, here, and here) that discussed a feature in LibreOffice Calc that was introduced in version 4.5 called “property mapping.” That seemed to hold the answer. However, as of LibreOffice 6.0.3 (the version I happened to be using), the “Property Mapping” option in the Data Range window of a chart was gone. Even so, the general process still works. So, here’s how to create the kind of chart I wanted.

First, make sure you’ve got your data entered (obviously). Second, select the data you want to chart:

Select “Insert -> Chart” and then choose “Column” chart:

On the Next page of the Chart Wizard, make sure you’ve got your data selected correctly (I had to select “First column as label”):

The problem with this, of course, is that I have coded everyone in the dataset with a “1” even though, in reality, some of the Governors in this dataset were Republicans and some were Democrats. Right now, it looks like everyone was a Democrat, but this is where the conditional formatting comes on.

In your spreadsheet, you need to set up your conditional coding. This is done with “IF” statements. Here’s the code I used:

=IF(D2="Republican",COLOR(255,0,0),IF(D2="Democrat",COLOR(0,0,255),COLOR(255,255,0)))

Basically, what this code does is checks to see whether a cell has “Republican” in it or “Democrat.” If it is Republican, color 255,0,0 is selected (RED, which is reported in the cell as 16711680). If it is Democrat, color 0,0,255 is selected (BLUE, which is reported in the cell as 255). The last part of the formula indicates that everyone else should have a different color (YELLOW = 255,255,0). Dragging that down, I get a color code for every one of the values in my chart. Once I have this in place (which should really be done before you start the chart wizard, but can be done after the fact), now I can use this to adjust the bar fill color in my chart.

Adding this to the chart is done in the “Data Series” step in the Chart Wizard. Alternatively, if you’ve already created your chart, select it, and right-click. Then click on “Data Ranges” and you can adjust this there. In the Data Series window, under “Data ranges:”, select “Fill Color”:

You’ll note that the “Range for Fill Color” box is empty. We’re going to fill that with the values we just generated using our conditional code. You can do this by clicking on the button next to that empty box, then select the corresponding values:

Once you have selected your fill color, your chart will now have the corresponding conditional fill colors:

Of course, this chart still looks pretty crappy. The y-axis needs to be adjusted, the columns shouldn’t have any space between them, and it needs a title. Here’s my finished chart:

The chart provides a graphical representation of a dichotomous variable using color to illustrate shifts between political parties without suggesting that one party is better than the other. Et voila – conditional color formatting in LibreOffice charts.