Programming, Ubuntu

Ubuntu Linux Basic System Maintenance Commands

P_20230331_212301_1 (1)

I’m fairly new to Ubuntu Linux since I usually use Windows machines. I recently picked up a Dell XPS 13 plus running Ubuntu with the hopes of getting to know more about the Ubuntu operating system and developing apps on it as well as just in general navigating around in it. So far I really like the operating system, especially the ease of use and lack of bloatware that comes shipped with it (unlike most Windows machines that come heavily loaded with various bloatware).

 

Read more: Ubuntu Linux Basic System Maintenance Commands

From Dell, I ordered an XPS 13 running a 12th Gen Core i5 with 16GB RAM and a 1 terrabyte SSD hard drive. I also got the OLED screen option which I’m finding makes a huge difference, it’s great! And as I mentioned before, I picked up the Ubuntu linux version which comes bare-bones without bloatware. Got to love a clean computer without all the junk.

One thing I did notice is that the Ubuntu software updates tool doesn’t always work all that well. It gives errors and stalls sometimes. That’s where I found that the command line works well.

Here are the commands I’ve found that help keep your Ubuntu system current and ship-shape. Note that you’ll have to start a terminal window and then enter your password to get this to run:

sudo apt-get clean
sudo apt-get update && sudo apt-get upgrade
sudo apt dist-upgrade
sudo apt autoremove

So what does this all do? Well, like I mentioned it cleans your system and makes sure that you have the latest updates. Here are the details:

sudo apt-get clean

This command clears out old package files in the cache and archives folders. Obviously useful for keeping your hard drive clean and free of old install files.

sudo apt-get update && sudo apt-get upgrade

This is a chained command as you can see by the &&

The sudo apt-get update command downloads the package lists from the repositories and updates them to the newest versions. Then the sudo apt-get upgrade gets the new versions of packages defined by the update command. Basically the ‘update’ command defines the new versions and then the ‘upgrade’ command downloads and installs them.

sudo apt dist-upgrade

This command will upgrade the most important packages, good stuff.

sudo apt autoremove

Super important to keep your system clean. This command will remove packages that are no longer needed ie: dependencies changed. Good to keep your system clean.

So that’s it, with the help of these system commands you should be able to keep your system clean and up to date. Relying on the Ubuntu software updates is not really a good option since it often fails, but these commands will help you keep your system up to date and clean.

Advertisement
IIS, IIS8, Programming, Web Server

IIS URL Rewrite – How to Remap Shortname to FQDN

Problems can happen if users enter a Shortname for a site URL instead of the FQDN (Fully Qualified Domain Name). For example if a user types the URL as http://abc instead of http://abc.example.com, then the site certificate can come back as invalid, resulting as an error message or login prompt for the end user. Better to compensate for that by redirecting users to the FQDN if they enter the Shortname by accident.

Out of the box IIS has a feature included that is called URL Rewrite. This was not always the case, and in the past it was a separate download. In Windows 2012 and up URL Rewrite has been included with IIS as a key feature.  

One of the key features of URL Rewrite is the ability to redirect a URL from Shortname to FQDN (Fully Qualified Domain Name). This is very useful to make sure that even if the user enters a Shortname instead of a FQDN URL, the user does not see an error message (or login prompt)

Here are the steps to use URL Rewrite. Note that you can set the same code settings at the IIS server level as well as at the individual site levels. In the case of the individual site levels, you will have to apply the code for each and any that you miss will not have the URL Rewrite logic applied, whereas if you apply the URL rewrite logic at the server level, it will apply to all sites by default. Tests using SharePoint sites in IIS are also good and this logic works quite well.

  1. To start, log into the server and open IIS
  2. Then choose either the Server Name to apply the URL Rewrite rule to all sites or click on an individual site to apply the URL Rewrite rule to just that site.
  3. Then once you have selected the server or the site, click the URL Rewrite tool under the main options:
  4. On the left hand Actions bar click the option to Add a Rule and then as an Inboud Rule type choose Blank Rule:
  5. Enter a unique name that you’d like to use to identify your new rule and then in the section called Match URL enter ^(.*)$ as the regular expression pattern. This basically says to match anything in the URL.
  6. Now here’s the important part where we are going to check if the user has entered the shortname instead of the FQDN. Expand the section called Conditions and click to Add a new condition with the following information:
    1. Set Condition Input to {HTTP_HOST}
    2. Set Dropdown Check if input string to: Does Not Match the Pattern
    3. Set the Pattern to: ^.*\.yoursite\.com
    4. Make sure the Ignore Case option is selected
  7. Finally in the section called Action:
    1. Change the Action Type dropdown to Redirect
    2. Enter the Redirect URL as: http://{HTTP_HOST}.yoursite.com/{R:1}
    3. Change the Redirect Type to Temporary (307).
      NOTE: the Permanent (301) redirect type gets cached in user’s browsers so it can’t be changed without the users flushing their cache, so to be cautious it is best to set the redirect type to Temporary (307)
  8. Finally click the Apply button to add the changes. The URL Rewrite rule should now be in place and enforced by IIS.
Software, Technology, Ubuntu

Ubuntu Linux – Debugging the Error: the list of sources could not be read

After installing and quickly uninstalling some software on my Ubuntu machine I saw an error on each boot saying: linux the list of sources could not be read. 

It also included the name that was causing the problem abc.list. In my case it was a file called waydroid.list that was causing the trouble after I had tried installing their software but realizing I didn’t want it.

To see the problem that’s happening you can open a command prompt and type:

sudo apt-get check

This should show some details of the problem.

To debug:

in Ubuntu open a command prompt and write:

ls /etc/apt/sources.list.d/

Now you should see a list returned including the offending .list file. In my case if was waydroid.list

To remove this list you’ll need to type its path. In my case the removal statement was like this:

sudo rm -r /etc/apt/sources.list.d/waydroid.list

Once this is complete you can check that the problem file was removed using this:

ls /etc/apt/sources.list.d/

After this once you reboot, the problem should be gone. At least that was my experience and it worked very well.