How Do You Troubleshoot “jdoe is not authorized to run that command as root”?

Problem scenario
You failed to use visudo on a Red Hat or Debian distribution of Linux. You try to elevate your user to sudo and run a command but you get: "jdoe is not authorized to run that command as root."

You forgot the root password. You cannot boot into rescue/recovery mode. How do you correct the /etc/sudoers file?

Solution
Run "pkexec" without quotes. If the user has sudoer privileges, it should work to gain access as root.

What Is The Space Complexity when There Are Two Variables in a Program?

Question
You have a program with two (or three) variables, but no other data structures. What is the space complexity?

Answer
O(1). An algorithm, as long as the number of variables is fixed, can have 1,000 variables and be said to have O(1) space complexity. The source is here:

https://stackoverflow.com/questions/43260889/what-is-o1-space-complexity

How Do You Get a USB-to-Ethernet Cable to Work with Linux?

Problem
You connect a USB convertor (for a wired ethernet cable) to your Linux laptop. It isn't working as a plug-and-play device. What could be wrong?

Solution
1. In the GUI on the Linux desktop, go to "Settings" or "Control Settings". 2. Then go to "Network".
3. Click a plus sign "+" (to add a new profile).
4. On the Identity tab, of the pop-up, there should be one or two MAC addresses in the drop down option.
5. Choose one and click "Add." Give it a few minutes.
6. If step #5 doesn't work, try again, but try a new "MAC Address" in the drop down. Give it a few minutes and see if the network is showing up.

How Do You Troubleshoot “…quota: Cannot open quotafile //aquota.user: Permission denied”?

Problem scenario
You run a quota command. But you get "quota: Cannot open quotafile…" //aquota.group or //aquota.user … "Permission denied."

What should you do?

Possible Solution #1
Maybe you do not have permissions. Can you run it with "sudo "?

If you run it with sudo and just see the quota governing the root user, then try running a command like this:

sudo quota -u jdoe
# Replace "jdoe" with the non-root user

You may want to find the relevant files with commands like this:

sudo find / -name aquota.group
sudo find / -name aquota.user

Possible Solution #2
This assumes you have the chattr utility installed; if you need assistance, see How Do You Install chattr on Ubuntu?

Change the immutable bit with this:

cd /path/to/aquota.user # change directories to the one with the file
sudo chattr -ia aquota.user

This was adapted from https://www.thecpaneladmin.com/aquota-user-permission-denied/.

Possible solution #3
You could try running a quotacheck command (e.g., sudo quotacheck -vug). This solution was adapted from https://sourceforge.net/p/linuxquota/bugs/94/.
This command can clear the immutable bit. If you want to read about the immutable bit, see What Is the Immutable Bit vs the Sticky Bit?

How Do You Fix Apache Kafka when It Hangs?

Problem scenario
You try to start the Apache Kafka service. You get this:

[2021-07-25 12:15:36,687] INFO [Group Metadata Manager on Broker 1]: Finished loading offsets from [__consumer_offsets,24] in 123456789 milliseconds.

GroupMetadataManager…Finished loading offsets and group metadata from __consumer_offsets…seconds spent in the scheduler. (kafka.coordinator.group.GroupMetadataManager)

It just hangs and will not progress. What do you do?

Solution
Whenever a command hangs that is supposed to start a service, there could be one, ignorable errors. The problem could be obviated by a service that runs the command in the background. How did you start the Kafka service? Did you use the flag "-daemon"?

Try this:

kafka-server-start.sh -daemon /root/kafka/config/server.properties

Taken from http://tecmint.com/install-apache-kafka-in-centos-rhel/

Why Are Ubuntu Versions (the Corresponding Integer Number Values) Usually Even?

Problem scenario
You are curious why the odd versions of Ubuntu get so little attention. Why is this?

Answer
Even versions get long term support. If you are uncertain which version of Ubuntu to install, we recommend the highest even number release. As of February 2022, this is Ubuntu 22.x.

See this for more information: https://ubuntu.com/about/release-cycle

Be advised that odd versions will have an end of life that is sooner than the end of life for the previous even version. If your server will last more than one year it is important to use an even version (in most situations).

How Do You Fix “Cannot find any quota file…” or “Cannot guess” after Running a Quota-Related Command?

Problem scenario
You run a command like edquota, but you get an error about not finding a quota file to work on or no file systems with a quota have been detected. Or maybe you ran a quotacheck command and got an error about not being able to guess a format from a filename.

What should you do?

Solution

  1. Can you move the aquota.group or aquota.user file at the root of the file system to a backed up version (e.g., in your home directory)? Move it to a backed up name that you won't forget. (This way if you make a mistake, you still have the quota file.)
  2. Run this command (but use "vfsv0" if you are using a 32 bit OS):
    sudo quotacheck -F vfsv1 -avum
  3. Run a command like this: quotacheck -cug /path/to/filesystem

(but replace "/path/to/filesystem" with the path to the file system)

Another solution for this problem that was written in 2012 is here: https://talk.plesk.com/threads/hard-diskquota-install-error.258095/

(The above plesk.com link helped explain what to do for these directions too.)

How Do You Troubleshoot a VirtualBox VM saying “failed unmounting /cdrom”?

Problem scenario
In VirtualBox you are trying to boot a VM, but you get "failed unmounting /cdrom". You see no option to unmount or remove the CD ROM. What should you do?

Possible Solution #1
Restart VirtualBox. Close it. Reopen it.

Possible Solution #2
Reboot the computer hosting/running VirtualBox.

How Do You Make Changes to an /etc/fstab File when It Is Read Only?

Problem scenario
You cannot make changes to an /etc/fstab file. It is read only. What should you do?

Possible Solution #1
If your /etc/fstab file is messed up (through manual changes to it), and your system boots it as read only, can you run a command like this?

sudo mount -o remount,rw /dev/mapper/foobar /directory/to/be/mounted

If you run "sudo cat /etc/fstab" you will see lines like this:

/dev/mapper/foobar / ext4 defaults 1 1

(If you saw the above, and that was the line that was corrupt, replace "/directory/to/be/mounted" with "/".)

If it doesn't work, with modern Linux OSes and modern hardware, you can boot to rescue mode without installation media (e.g., a CD, DVD or USB stick).

Possible Solution #2
Use "sudo". Sometimes when you are frantic, you forget that normal users cannot make changes to sensitive files. Can you assume the root user?

Possible Solution #3

See one of these three links:
https://www.unix.com/linux/54874-how-edit-etc-fstab-when-root-mounted-read-only.html
https://linuxtect.com/read-only-file-system-error-and-solutions/
https://forums.fedoraforum.org/archive/index.php/t-144176.html

There was a good stackexchange.com (e.g., unix.stackexchange.com) posting and answer for something similar that involved booting up, then moving the file system temporarily to RAM and/or /tmp/. If you know which one this was, please post it in the comments below.