Skip to content.

A Note About Website Navigation

Skip to main menu.

For users of screen readers, depending on the screen resolution, the two checkboxes are for opening and closing the side menus that appear to the left and right side of the screen. This is designed both for large screens and for mobile devices with a touch screen. Checking either the main menu or sidebar checkboxes causes the menu to open from the left or right side of the screen, respectively. Clearing the checkox in either the main menu or sidebar closes the menu. The checkboxes are visible to screen readers such as JAWS and NVDA for Windows, Voiceover for Mac, and Orca screen reader for Linux. When a screen reader says "clickable" for both main menu and sidebar, that is for the respective checkboxes. End of explaination.

Category: Information Technology, subcategory of The World of Computers

Vim: How to Delete Text Enclosed In Quotes

Instructions

Navigate to the first character after the quote/double-quote and type the following in Vim:

di"

This is useful if you have something like the following:

{
    "title": "Vim: How to Delete Text Enclosed In Quotes",
    "permalink": "vim-how-to-delete-text-enclosed-in-quotes",
    "published": "2023-08-12 14:00",
    "categoryIDs": "5,5:0,5:1,5:5",
    "description": "In Vim, 'di\"' is the one to use for deleting text in quotes.",
    "thumbnail": "",
    "smallimage": "",
    "largeimage": ""
}

So, to navigate to the first character that starts with a double-quote, simply type /"e; and the insertion point will highlight the double-quote. To get to the next double-quote, press the n key again until you get to the one you want. After that, press the l key to move to the first character and type the following:

di"

The output will be as follows:

{
    "title": "",
    "permalink": "vim-how-to-delete-text-enclosed-in-quotes",
    "published": "2023-08-12 14:00",
    "categoryIDs": "5,5:0,5:1,5:5",
    "description": "In Vim, 'di\"' is the one to use for deleting text in quotes.",
    "thumbnail": "",
    "smallimage": "",
    "largeimage": ""
}

And now, you can type whatever you want by pressing the i key on your keyboard. Press the ESC (escape) key to get out of INSERT mode and back into normal mode. To save changes and quit the Vim text editor, type :wq.

Bonus: If you have delimiters with quotes while writing the code such as:

"This is some \"quote\"!"

Vim will automatically delete the delimiters with quotes along with them, so performing di" will delete everything that is in between quotes.

""

And you do not need to be inside quotes in order to delete inside the quotes! How cool is that? *grinning face*

Oh, and you can also use the "change inside" sequence as well:

ci"
This puts you into INSERT mode so you can type text inside quotes.

Audience

This is for Linux users experienced in using the Vim text editor. Vim users should already know the basics such as :q! for quitting the text editor without saving changes, :wq for saving changes and quitting the text editor, i for going into INSERT mode and use the ESC (escape) key to get back into normal mode. All keyboard commands are beyond the scope of this short article that I wrote.

Conclusion

Hopefully this keyboard command can be of help to you. If you are a Linux user, please give Vim a try.

Original Source

In Vim, how can I delete everything between quotes including the quotes?

Note that I was searching for information about deleting text inside quotes and not including the quotes.


Article published: 2023-08-12 14:00

Categories: The World of Computers, Computers, Information Technology, Scripting and Programming

How To List All SELinux Contexts

Audience and Prerequisites

This is intended for Linux users who have experience working with the command line. You should be running any Red Hat-based distributions such as Rocky Linux, AlmaLinux, or Oracle Linux. CentOS Stream is not a candidate for taking the RHCSA (Red Hat Certified System Administrator) exam. A lot of people in the Linux community are not happy about Red Hat discontinuing support for CentOS 8 and now Red Hat does not want source code to be available for everyone, including Rocky Linux and AlmaLinux. Enough with wordy paragraphs! We don't want anyone to scroll down too much in order to get to the most important part! Let's get into the command line, shall we?

Oh, please pardon me for boring you with this, but I almost forgot. This article assumes that you are logged in as a root user. This is bad security practice in the production environment, but in the exam, it's okay to be root. If you break it, you fix it and that will count against your time in the exam. But the important thing is that you must come up with solutions as fast as possible. Of course, don't be in a hurry in such a way that you will fail the exam. Okay, enough already! Let's get in with it! *grinning face*

Type: File Contexts

The command for listing all available SELinux type contexts is:

seinfo -t

The command for listing only the type contexts that relate to the web server:

seinfo -t | grep httpd

So, you searched for anything related to httpd and you came across httpd_sys_content_t. You need to specify a directory to host your content other than in /var/www. To add the type context to a directory, the command will be as follows:

semanage fcontext -a -t httpd_sys_content_t "/data/nas/www(/.*)?"
restorecon /data/nas/www

Longer version:

semanage fcontext --add --type httpd_sys_content_t "/data/nas/www(/.*)?"

The seinfo command is the SELinux policy information tool, semanage is a SELinux policy management tool, and restorecon is for restoring default SELinux security contexts to files and directories. The "type" contexts is the only one to be to be concerned about when studying for any Linux exams, such as RHCSA (Red Hat Certified System Administrator).

As for (/.*)?, that's called a regular expression. This is for setting any subdirectories and files with the same context as the main directory. Try to remember this in the RHCSA exam: open parenthesis, forward slash, period, asterisk, close parenthesis, question mark, and that's about it. The only thing to remember is to have the entire path along with the symbols in double quotes. In the RHCSA exam, you have access to the man pages, so take advantage of that whenever possible.

For users of NVDA screen reader (Non-Visual Desktop Access), NVDA does not speak a question mark such as CTRL+? (control plus question mark). I do not know if this is a bug in the screen reader or if this is intentional, but at least it's all I can do to help out if screen readers ignore question marks. That symbol is an important part of a regular expression, so it needs to be translated to words. Hopefully I can be of help.

Type: Contexts for Ports

What about ports? If you modify the port number in SSH configuration file (/etc/ssh/sshd_config) and you restart the service (systemctl restart sshd), even if you configure the firewall to allow a different port number (example: firewall-cmd --add-port 12345 --permanent), you won't be able to SSH into your server because SELinux gets in the way! It's easy to disable SELinux if you do not mind exposing your server to outside security risks, but when studying for the exam, it's important to never disable SELinux. Instead, let's search for port-related contexts.

Let's search for any services that have a phrase "port" for any type contexts:

seinfo -t | grep port

You should get a list of services. Let's narrow it down to SSH:

seinfo -t | grep port | grep ssh

Ah ha! There it is. It's ssh_port_t. Of course, I could also type the following:

seinfo -t | grep ssh_port

And that should give me the same output. So, let's configure SELinux to allow TCP port 12345 so that we can SSH into our Linux server.

semanage port -a -t ssh_port_t -p tcp 12345

And there you have it! You should now login to your server using SSH.

ssh -p 12345 username@servernameoripaddress

Of course, if you want to search for other services, such as Postfix:

seinfo -t | grep postfix

Oh, wow! So many contexts to choose from! But aren't we looking for port-related contexts?

seinfo -t | grep port | grep postfix

Hmm... There are no port-related contexts related to Postfix. Of course, what we do want is SMTP, which is port 25 by default, so let's narrow it down to just "port" and "SMTP" (all lowercase, of course).

seinfo -t | grep port | grep smtp
# or "seinfo -t | grep smtp_port" (without quotes)

And you should get smtp_port_t. However, configuring an SMTP server is beyond the scope of this tutorial about viewing the list of available contexts. Plus, configuring firewalls and enabling/starting services in a Linux server is also beyond the scope as well.

What Packages Provides seinfo and semanage?

dnf whatprovides */seinfo

The asterisk represents a wildcard, so this would assume that we do not know the full path to seinfo command. That dnf command, when executed, reveals a package called setools-console. So, so install setools-console, just use the dnf install command as follows:

dnf install setools-console

The same is for semanage:

dnf whatprovides */semanage
dnf install policycoreutils-python-utils

That package policycoreutils-python-utils is so wordy, isn't it? *smile* Don't stress over trying to remember that package name in the exam and in the real world.

Conclusion

I hope I can be of help to anyone studying for RHCSA exam. Hopefully you should be able to know how to set SELinux type contexts for directories and ports. If you are not taking an exam (you should if you want to further your career in Linux and Information Technology), I hope I can be of help as well! Have fun administrating your Linux servers!

And yes, I could have used emojis, but screen readers come first! *smile*


Article published: 2023-08-12 13:10

Categories: The World of Computers, Computers, Information Technology, Security

Having Trouble Upgrading Nobara Linux? It Could be the Problematic GPG Keys

Prerequisites

This article is for Linux users who have hands-on experience working with the command line.

Instructions

Open the terminal in GNOME (Konsole in KDE) and type in the following commands as root:

sudo dnf update fedora-gpg-keys --nogpgcheck --refresh
sudo dnf update nobara-gpg-keys --nogpgcheck --refresh

Press ENTER, enter the user password (if prompted), and let the updater take care of the rest.

Example Error Messages

This is when I tried to see if there are any packages available and I came across the messages:

...
GPG key at file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nobara-appstream-pubkey.gpg (0x0FE970A2) is already installed
The GPG keys listed for the "nobara-appstream" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.. Failing package is: dkms-nvidia-3:535.86.05-1.fc38.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nobara-appstream-pubkey.gpg
Public key for mesa-dri-drivers-23.1.3-2.fc38.i686.rpm is not installed. Failing package is: mesa-dri-drivers-23.1.3-2.fc38.i686
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nobara-appstream-pubkey.gpg
Public key for mesa-dri-drivers-23.1.3-2.fc38.x86_64.rpm is not installed. Failing package is: mesa-dri-drivers-23.1.3-2.fc38.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nobara-appstream-pubkey.gpg
...

Frankly, I'm not too sure how I am getting this error messages.

Frequently Asked Questions

What is Nobara Linux?

Nobara Linux is an operating system that is suited for gamers and content creators. Nobara makes it easy for point-and-click users to install software such as Blender and OBS as well as installing proprietary drivers for hardware such as NVIDIA GeForce GPUs or any wireless adapters that do not work with Linux out of the box.

What is GPG?

GPG (or GNU Privacy Guard) is used by various Linux distributions for verifying packages such as Steam, Blender, OBS, the Linux kernel, and so many other packages. Without a signature of any kind, any threat actors can push a package to a repository that can load any malicious software (malware) into your computer (even if the name of the package is Blender). GPG is also used for encrypting files and directories. The three letters (GNU) for GNU Privacy Guard is a recursive acronym for GNU is Not Unix.

How did you find out the commands?

While getting these error messages when I do a dnf update, a search led me to a thread in Reddit where someone had a different problem than mine. I tried the commands that bypasses the GPG checks and it worked! By "different," I meant that poorly-formatted error message with <br /> (line break) tags that have a completely different error message than mine. For web accessibility enthusiasts, this fails WCAG 2.0 Success Criteron 1.3.1 (info and relationship) and 4.1.1 (parsing). It seems Reddit did not parse the text as HTML. The error message in Reddit is as follows (not mine):

Invalid package file:

package mesa-vulkan-drivers-23.2.0-git.20230714.27d30fe.fc38.i686 cannot be verified and repo nobara-appstream is GPG enabled: /var/cache/PackageKit/38/metadata/nobara-appstream-38-x86_64/packages/mesa-vulkan-drivers-23.2.0-git.20230714.27d30fe.fc38.i686.rpm could not be verified.

Conclusion

The issue is resolved in my end and I can go about my day. Hopefully yours should be fixed as well if you are currently running Nobara Linux. Happy gaming and content creating!


Article published: 2023-07-24 16:27

Categories: The World of Computers, Computers, Information Technology

Use $HOME, not /home/$USER in BASH scripts

Audience

This article is for experienced Linux users who are familar with environment variables such as $HOME and $USER. These are the Linux users who are familiar with the command line.

Problem and Solution

Here is an example not to use /home/$USER:

[gpeddie-games@epcotcenter ~]$ su - gpadmin
Password: 
mkdir: cannot create directory ‘/home/gpadmin’: Permission denied
touch: cannot touch '/home/gpadmin/Templates/Text file': No such file or directory
mkdir: cannot create directory ‘/home/gpadmin’: Permission denied
-bash: /home/gpadmin/.local/share/DaVinciResolve/configs/.version: No such file or directory
Welcome. All activities monitored at all times.
Unauthorized access is strictly prohibited.
gpadmin@epcotcenter 
  ~
$

And here's the script (/etc/profile) that illustrates an example:

# fix gnome missing 'New file' option
if [ ! -f /home/$USER/Templates/"Text file" ]
then
    mkdir -p /home/$USER/Templates
    touch /home/$USER/Templates/"Text file"
fi

# ...

# this is a hack to bypass the Davinci Resolve new install Welcome/Onboarding screen since it does not render properly and is not required.
if [ ! -f /home/$USER/.local/share/DaVinciResolve/configs/.version ];then
    mkdir -p /home/$USER/.local/share/DaVinciResolve/configs/
    echo "Onboarding.Version=10" > /home/$USER/.local/share/DaVinciResolve/configs/.version
fi

To fix this issue, simply replace all instances of /home/$USER with $HOME. I am familiar with a text editor called Vim. It's a program that runs inside a terminal, similar to the Command Prompt or PowerShell in Windows.

Before we proceed any further, let's create a backup copy of /etc/profile:

sudo cp /etc/profile /etc/profile.bak

If anything goes wrong, you now have a backup. You can simply use the cp (copy) command to restore from the backup. Now let's begin.

  1. First, open the Terminal (Konsole in KDE).

  2. As root (or with sudo privileges), type the following command:

    sudo vim /etc/profile
  3. Type in the following command, starting with a colon:

    :%s/\/home\/$USER/$HOME/g

    The syntax for search and replace in Vim is as follows:

    :%s/search/replace/g

    Let's not concern ourselves with g at the end for now. Basically this command replaces "search" with the next text "replace." In other words, we want to replace /home/$USER with $HOME.

    Let's have a look at the script again:

    # fix gnome missing 'New file' option
    if [ ! -f $HOME/Templates/"Text file" ]
    then
        mkdir -p $HOME/Templates
        touch $HOME/Templates/"Text file"
    fi
    
    # ...
    
    # this is a hack to bypass the Davinci Resolve new install Welcome/Onboarding screen since it does not render properly and is not required.
    if [ ! -f $HOME/.local/share/DaVinciResolve/configs/.version ];then
        mkdir -p $HOME/.local/share/DaVinciResolve/configs/
        echo "Onboarding.Version=10" > $HOME/.local/share/DaVinciResolve/configs/.version
    fi

    So why would we want to replace /home/$USER with $HOME? That /home/$USER should still work!

    Let's look at the output again after we save the changes.

  4. Save the changes to the /etc/profile file.

    :wq

    A : begins a command. w writes changes to the file and q quits Vim

    If you don't want to make changes to the file, then all you have to do is type :q! to exit without saving any changes.

As I mentioned, let's look at the output again when I log into my administrator account from a user account.

[gpeddie-games@epcotcenter ~]$ su - gpadmin
Password:
mkdir: cannot create directory ‘/home/gpadmin’: Permission denied
touch: cannot touch '/home/gpadmin/Templates/Text file': No such file or directory
mkdir: cannot create directory ‘/home/gpadmin’: Permission denied
-bash: /home/gpadmin/.local/share/DaVinciResolve/configs/.version: No such file or directory
Welcome. All activities monitored at all times.
Unauthorized access is strictly prohibited.
gpadmin@epcotcenter
  ~
$

Now, let's see the new output when I log back in as an administrator.

[gpeddie-games@epcotcenter ~]$ su - gpadmin
Password: 
Last login: Sat Mar 18 11:13:52 EDT 2023 on pts/0
Welcome. All activities monitored at all times.
Unauthorized access is strictly prohibited.
gpadmin@epcotcenter 
  ~
$

I have covered more explanation regarding how this works and I have discussed a scenario in my article.


Article published: 2023-03-18 15:37

Categories: The World of Computers, Computers, Information Technology, Scripting and Programming

Backup Your WordPress or ClassicPress Files, Configuration, and Database with a Single Script

Audience and Prerequisites

Skip to scenario if you want to jump into the main article.

This is for anyone who currently host their WordPress or ClassicPress in a virtual private server such as DigitalOcean, Linode, or any other VPS providers. Any Linux user with knowledge of command line can perform backups and restoration tasks. You must be familiar with Linux and you know how to connect to your production server via SSH.

Plus, this article assumes that you have installed and configured WordPress in your VPS server. In addition, this article assumes you can perform basic database administration tasks such as adding a new database along with creating a new user for WordPress or ClassicPress. If your hosting provider provides managed WordPress or ClassicPress hosting, then this article may not apply to you. And because this article is for those who currently run a VPS server, I am going to have to assume that you have some hands-on experience with the Linux command line. This article need not apply to non-technical Linux, Mac, and Windows users. When I say non-technical Linux users, I'm talking about those who wanted to get away from Windows or Mac and simply wanted to use Linux just to browse the Internet and not deal with the command line.

Last, but not least, I am also going to assume that you know how to configure your Apache server as well. Both Apache and NGINX (pronounced Engine-X) configurations won't be covered here, including backing up and copying certificates that you get from your hosting provider.

If you are interested in learning Linux, a tutorial from Guru99 will help get you started on learning Linux.

Are you ready? Then let's get started!

Scenario

You have your own VPS server that is running ClassicPress. Your domain name is exmaple.com and your SSH port number is (insert your TCP port number here). You have a development server for developing your own custom ClassicPress theme and you want to use your development server to backup everything from your production server.


Article published: 2022-11-17 08:47

Categories: The World of Computers, Information Technology, Internet, Networking, Scripting and Programming

Need to Change Hostname for Windows Server Domain Controller?

If you promoted your server to a domain controller, you won't be able to change the hostname for Windows Server Domain Controller without inputting commands in the command prompt. Basically, you need to open the command prompt, add a new alternate hostname, make the domain controller your primary hostname, reboot your server, and then remove the old hostname. This is useful if the server's hostname was not changed before the server gets promoted as a domain controller. The order of commands along with the syntax is as follows:

netdom computername oldcomputername.yourlocaldomain.lan /add:newcomputername.yourlocaldomain.lan
netdom computername oldcomputername.yourlocaldomain.lan /makeprimary:newcomputername.yourlocaldomain.lan
shutdown /r /t 0
netdom computername newcomputername.yourlocaldomain.lan /remove:oldcomputername.yourlocaldomain.lan
netdom computername
The command to execute.
oldcomputername
Old hostname (example: WIN-R61PT45).
yourlocaldomain.lan
Local domain name (example: graysonpeddie.lan)
newcomputername
New hostname (example: grayson-dc1)
/add
Adds a new hostname to the domain controller as an alternate hostname. For this example, newcomputername will be added as an alternate hostname for the domain controller.
/makeprimary
Makes a hostname a primary name for the domain controller. newcomputername will be the primary name for the domain controller and the oldcomputername will be the alternate hostname for the domain controller.
/remove
Deletes the hostname from the domain controller. In this case, the /remove flag removes the oldcomputername from the domain controller.
/enumerate
Although not shown in the order of commands above this list of commands, parameters, and flags, this will enumerate the list of hostnames assigned to the domain controller. This flag does not require a parameter, so the colon after the enumerate flag is not needed.
shutdown /r /t 0
This command reboots the server (hence, /r) immediately (/t 0. The /t 0 flag and parameter is a timer.
dcdiag
Not shown in the list of commands above. This command runs a diagnostic for the domain controller to make sure everything in the domain controller is working fine. There might be some errors and warnings, but if computers can login to the domain controller, it should be fine.

Because I did not know the commands myself, I must give credit to "The ICT Guy" (Twitter profile) for writing an article titled Correctly renaming a Domain Controller for a seamless easy migration. That article has been of great help to me since I am testing Windows Server 2016 Essentials edition as part of my virtual homelab setup. For example, I wanted to test the domain joining functionality in macOS and test an Active Directory integration in Nextcloud using an LDAP/AD integration app. LDAP stands for Lightweight Directory Access Protocol and is used for managing users and groups.

I hope I can be of help to Windows administrators.


Article published: 2022-09-25 01:15

Categories: The World of Computers, Information Technology

Pro Tip for Proxmox Users: Using Linux Containers (LXC) For Testing The Ability To Join Linux to an Active Directory?

When creating Linux containers for the purpos of joining them to an Active Directory Domain Controller, make sure the checkbox after the "Unprivileged Container" is unchecked. The "unprivileged container" checkbox is after the "Hostname" edit box. Unprivileged Linux containers won't be able to join to an Active Directory. Essentially, I forgot to uncheck the "Unprivileged Container" and wasted hours of my time, but I consider time well spent when learning the hard way.

Bear in mind that privileged containers are not safe for businesses when it comes to attackers exploiting privileged Linux containers. And yes, it's all about vulnerabilities and exploits when it comes to escaping Linux containers and causing damage to the host; however, for homelab purposes, a privileged Linux container is fine for my needs. If you are concerned about the security of Linux containers, spin up virtual machines instead of Linux containers in Proxmox. Of course, depending on your security hygiene, virtual machines can be as unsafe as privileged and unprivileged Linux containers if you do not have security precautions in place. For more details, learn more about privileged and unprivileged containers.


Article published: 2022-09-22 06:27

Categories: The World of Computers, Computers, Information Technology

How To Change Your Uber Email Address and Password?

Instructions

  1. From your smartphone (not your desktop or laptop computer), open the Uber application.
  2. Tap Account. The Account button is located at the bottom right of your smartphone's screen.
  3. Tap your avatar to the right of your name.
  4. Tap your email address to change your email address. Skip to step 6 if you do not make use of unique email addresses for every account that you signed up for.
  5. Once you change your email address, tap Update. Go into your email account and look for an email from Uber. Enter the verification code that Uber gave you.
  6. Tap your password. You will need to verify your password first before you generate your new password from a password manager.

And you are done! Congratulations! You have successfully changed your unique email address and password! Stay safe!

Here's a link to the full article about why I changed my email address for Uber.


Article published: 2022-09-17 12:16

Categories: The World of Computers, Information Technology, Security