Create Symbolic Links in Linux

Symbolic links in Linux is the same as creating a shortcut in Windows.

Use the ln command to create symbolic links. I was a little confusing to me when I was learning about it. But, then I got it. After a walk in the new Long Island RR station at the Grand Central Terminal in New York City. I decided to put together some examples:

To create a symbolic link to a file using the ln command.

ln -s source_file optional_symbolic_link

Always remember to use the switch -s. If not, you will create a hard link instead. Remember, the ln command will only give and output when it fails, otherwise nothing will be return nothing if successful.

Now check that a symbolic link was created by running ls -l

lrwxr-xr-x   1 rgm  staff  6 Mar 16 14:29 link_file -> source_file

If you see the ‘l’ at the beginning of the output it means ‘this is a symbolic link’ Also, the part link_file -> source_file showing that arrow means a symbolic link was created.

Same process work for creating symbolic links to directories.

To remove symbolic links there are two options:

rm created_link

or:

unlink created_link

The ‘link_file’ does NOT need to be created first. I was confused by this. As you can see creating symbolic Links in Linux is quite simple.

Contact me if you have any questions. You can also leave a comment below.

Disable SELinux RedHat/Centos Server

To disable SELinux on RedHat/Centos server is an easy process. All we need is to edit a config file located here:

/etc/selinux/config

Use your favorite text editor (I like vim) and edit the above file:

vim /etc/selinux/config

Change the value to SELINUX=disabled

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted

Then, you must reboot your RedHat/Centos server in order for changes take effect:

sudo reboot

That’s all! Go now and brew your favorite coffee. You can always contact me if you have any questions or write a comment below.

Changes in Flask Don’t Show in Docker Compose

When working on my blood pressure readings app I noticed changes in Flask Don’t Show in Docker Compose automatically. I had to do a docker compose down and then up to see a simple change to one of my HTML template files.

This got me very frustrated and I had to run to the kitchen a brew a nice cup of specialty coffee from Peru.

After brewing my coffee I noticed I change a value in my docker compose file. It was under the environment. I changed the value FLASK_DEBUG: to ‘0’ which turns OFF debug mode. When running you Flask app in debug mode using docker compose you can see instantaneous changes in your browser.

This is my service ‘www’ defined in my docker-compose.yml:

www:
    restart: always
    build: www/.
    depends_on:
        db:
          condition: service_started
    volumes:
      - ./www:/opt/www
      #- ./www/mbp/templates:/opt/www/templates
    env_file:
      - ./www/.env
    environment:
      #have the app run in debug mode. Change to 0 to turn OFF. if you change to 0 you won't see 
      #instant changes. You will need to restart docker compose down/up
      FLASK_DEBUG: 1

I will be posting more details about this app I’m developing in Flask using Docker in the near future. For now, you can contact me and also check my ITPro Helper shop for cool coffee mugs and T-Shirts I design.

The pg_trgm PostgreSQL extension is not present. The extension is required by Drupal 10

I got this pg_trgm PostgreSQL error after trying to run Drupal and Postgres using Docker compose for testing purposes. After taking the NYC subway to my home office I decided to look into this.

The solution for this error was to install the missing extension in Postgres. Not sure why this is not installed by default. Maybe that’s a topic for a different post.

To quickly install the missing postgres extension and fix this pg_trgm PostgreSQL error I logged into my docker container by running the below command:

docker exec -it <nameOfContainer> bash

I then logged into postgres using:

psql -U <DB_USERNAME>

then switch to the database you want to install the extension:

\c <DB_NAME>

Run the below command to install the extension:

CREATE EXTENSION pg_trgm;

Logout and if you get further errors try installing the module for your Linux OS:

Ubuntu/Debian:

sudo apt install postgresql-contrib

Fedora:

sudo dnf install postgresql-contrib

Research your OS documentation for installing this postgres extension.

Clean Install macOS Without a USB

Performing a clean install macOS without a USB is fairly easy compared to other operating systems. I know traditionally most IT admins (IT Handy men) think about using a USB to quickly wipe and re-install a OS. But, some times there is NO USB available or the laptop does NOT have a USB port anymore or you might not have an adapter handy(This sucks!)

After brewing my own coffee at home and taking a walk around NYC and noticing so many red fire police call boxes I decided to put this brief tutorial together.

This is easy to do.

Before you start to Clean install macOS

Always! Always! backup, backup and backup your DATA. This process will erase all data. There’s NO going back.

Start the process

  1. Restart your mac or turn it OFF and the ON. While the mac is starting hold down Command + R keys.
  2. Release the keys when you see the Apple logo.
  3. You will see a “macOS Utilities” window. Select Disk Utility and Erase you main mac hard disk.
  4. Once the disk has been erased close Disk Utility window. You will be taken back to the “macOS Utilities” window.
  5. Now, connect your mac to the internet via Wifi or Ethernet cable(if possible).
  6. Select Reinstall macOS in the “macOS Utilities” window.
  7. Follow the instructions and make sure you select the HD you erased previously. This is the target drive macOS will boot from.
  8. The re-install process will begin. This may take some time due to your internet speed.

When done you will setup macOS as you normally do. Enjoy!

Manage WiFi using macOS Terminal

A customer called asking if I could disable WiFi for some of his new iMacs at the office. He wanted his users to connect via Ethernet cable. After digging around I found a way to manage WiFi using macos Terminal.

There are a few simple steps you can take. First, a great cup of coffee!

Then, open your macOS Terminal.

First you need to find the network interface name by running the following command:

networksetup -listallhardwareports
Manage WiFi using macOS Terminal
Manage WiFi using macOS Terminal

This Terminal command gives you a nice layout of all your network interfaces.

After you find the network interface for your WiFi you can turn it off by running:

networksetup - setairportpower en0 off

Let’s say you changed your mind and you want to turn back ON your WiFi using the Terminal you run:

networksetup - setairportpower en0 on

For example, if you like to join a different WiFi network you can run the following command in the Terminal to view available networks:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan

To join one of those WiFi networks you found:

networksetup -setairportnetwork en0 SSID_YOU_WANT_TO_JOIN WIFI_PASS

There’s a space between SSID_YOU_WANT_TO_JOIN and WIFI_PASS.

I’m not sure why Apple doesn’t like to publish much documentation about running these task to make IT handy man lives easier. Anyways, hope this post helps someone out there.

Remember to check my IT coffee mugs and T-Shirt shop. I make my own designs. You can also contact me if you have any questions.

Clear Other Storage in macOS

A macOS customer contacted me the other day asking how to clear other storage in macos. Some of the customer’s laptops were taking significant disk space in this ‘other’ mysterious storage.

While riding the New York City Subway I started researching how to clear other storage in macos.

There are some cleaning tools out there, but as usual I prefer to do things myself and learn while at it. I found out that Cache files, documents not needed, DMG files, Application logs and Support files, browser’s plugins and extensions form part of this ‘other storage in macOS’.

Delete cached files using the Terminal

  1. Open your Terminal
  2. Type ~/Library/Caches (this is the user’s path)
  3. Remove the cache files you want to delete by using the rm command
  4. You can also try /Library/Caches(system caches)


I highly recommend that you have a backup before running the above.

Remove unneeded files including DMG one

  1. Open Finder and search using the upper right corner icon
  2. Type .dmg in the box and select Disk Image for Kind
  3. Delete any DMG files and remember to empty your Trash
  4. You can do the same process for other files such as .pdf, .doc, .psd and more..
  5. Always select ‘This Mac’ when searching for large files.
  6. You can always sort by File size.

Remove Application Logs and Support Files

  1. Open your Terminal or use Finder if you like
  2. Browse to these locations:
    • ~/Library/Application support
    • ~/Library/Logs
    • ~/Library/Containers
    • /Library/Application support
    • /Library/Logs
    • /Library/Containers
  3. Now delete what you don’t need.

Delete your browser’s plugin and extensions

  1. Go to each browser and locate plugins/extensions
  2. Delete the ones you don’t need.

Hopefully this can help someone having this issue. You can always contact me if you have any questions. Also, remember to see my T-Shirt and coffee mugs shop. I make my own designs. Enjoy!

How to Install pkg Using Terminal macOS

A client wanted to install some new Multi-factor Authentication software on the background while users where working. After brewing a great cup of Catuai coffee at home I found how to install a .pkg using the Terminal macOS.

This is a simple command. Open your Terminal and ssh to the desired macOS you need to install the .pkg. Run the following command:

sudo installer -pkg /path/to/package.pkg -target /

I usually run the above installer command from the location the .pkg lives. Enter your admin password and it should install without an issue. You should see an output as below:

Install pkg Using Terminal macOS
macOS Terminal installer pkg output

Find macOS Serial Number using Terminal

  1. You need to open your Terminal. Either by going to your Applications>Utilities>Terminal or by simply using Spotlight Search (type Command + Space on your keyboard) then type Terminal and press enter.
  2. Type the below command into your Terminal and press enter:
system_profiler SPHardwareDataType

The Terminal will display your serial number as shown below:

Find macOS Serial Number using Terminal
Find macOS Serial Number using Terminal

This command in macOS will also show you more details about your machine. These include Model, Chip, Memory, Total number of cores and more.

Contact me if you have any questions. You can also check out my ITPro Helper shop. I make my own T-shirts and mugs designs in New York City.

Start Tomcat at boot time in Red Hat 8

The other day I installed a Tomcat server in Red Hat 8 for a client. The client had to reboot the server and couldn’t find a way to start it. I found a way to start Tomcat at boot time in Red Hat 8.

As usual, I needed to go for a walk around New York City in Brooklyn before taking on this one.

First, we need to create a startup script file for Tomcat in:

/etc/init.d

You can name this file tomcat and enter the below:

#!/bin/sh
export CATALINA_HOME="/usr/local/tomcat"
ERROR=0
case "$1" in
 start)
            echo $"Starting Tomcat"
            sh $CATALINA_HOME/bin/startup.sh
            ;;
 stop)
           echo $"Stopping Tomcat"
           sh $CATALINA_HOME/bin/shutdown.sh
           ;;
 restart)
           sh $CATALINA_HOME/bin/shutdown.sh
           sh $CATALINA_HOME/bin/startup.sh
            ;;
 *)
         echo $"Usage: $0 {start|stop|restart}"
 exit 1
 ;;
esac
exit $ERROR

Assigned the permissions below:

chomod 755 tomcat

Next, create a symbolic link of the tomcat script inside the rc.d directory:

ln -s /etc/init.d/tomcat /etc/rc.d/rc6.d/K24tomcat 
ln -s /etc/init.d/tomcat /etc/rc.d/rc0.d/K28tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc3.d/S80tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc2.d/S81tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc5.d/S81tomcat

Go ahead and reboot your server and see if Tomcat starts automatically.

You can always contact me if you have any questions. Also, remember to visit my ITPro Helper shop where I created unique T-Shirts and coffee mugs designs.