How to check users group in Linux

After I got back from my trip to Puebla, Mexico to taste and learn about Pulque. My friend called me looking to find out how to check users group in Linux. There are some steps I took to find users and groups in Linux.

Steps to check users on a Linux server

Use the cat /etc/passwd command to view the contents of the /etc/passwd file, which contains information about all the user accounts on the system.

Alternatively, you can use the getent passwd command to query the system’s user database and list all the users.

To get a count of the total number of users, you can pipe the output of the cat /etc/passwd or getent passwd commands to the wc -l command to count the number of lines, which corresponds to the number of users.

If you only want to list the normal user accounts (excluding system accounts), you can use the getent passwd {1000..60000} command to list users with UIDs (User IDs) in the typical range for normal user accounts.

You can also use the awk command to extract just the usernames from the /etc/passwd file, for example: awk -F':' '{ print $1 }' /etc/passwd

How to check a user’s group?

You can use the groups command:


This will list all the groups the current user is a member of.

To check the groups for a different user, use the following syntax:

groups <username>

Use the id command to get more details about a user:

id <username>

This will show the user’s primary group, as well as any secondary groups they belong to.

Another option is to use the getent command to query the system’s user database and list the groups a user belongs to:

getent group | grep <username>

The above will show all groups the user is a member of. Usually will highlight the username.

If you want to see all the users that belong to a specific group, you can use the following command:

getent group <groupname> | cut -d: -f4

To check users group Linux is quite easy, but if you don’t do this on a daily basis is easy to forget. This is my case. You can always contact me if you have any questions or want to collaborate. Thanks!

Connect to Exchange Online using PowerShell

This one was a new experience for me. After brewing a good cup of Caturra variety coffee at home, a friend contacted me wanting to connect to Exchange online using PowerShell. This was due to some strange email activity with one of her users. Connecting to Exchange Online using PowerShell allows administrators to manage Exchange Online settings, mailboxes, and other features remotely.

First you need to check if the Exchange Online module is installed:

Get-Module -ListAvailable -Name ExchangeOnlineManagement

If the module is not installed, open a Windows Powershell and run as Administrator:

Install-Module -Name ExchangeOnlineManagement -Force

Follow the prompts. Yes, you can install from untrusted repositories. Press Y to confirm. If you already have the module installed and want to update it:

Update-Module ExchangeOnlineManagement

Now, connect to Exchange online:


Enter your credentials in the pop up window. Usually using MFA (Multi-factor Authentication).

After you connect you can run the desired command against any inbox. For example we wanted to check all rules on a shared inbox:

get-inboxrule -mailbox  | fl 

After you’re done, you can disconnect:

Disconnect-ExchangeOnline -Confirm:$False

Remember to contact me if you have any questions or like to collaborate. Thanks!

Configure log rotation for Postfix on Linux

A client running a postfix server called me the other day wanting to configure log rotation for Postfix on Linux. This was a Redhat box and I didn’t have much experience configuring log rotation. After my trip to Coyoacan in Mexico City I was very relaxed and started putting things together. Below is what I found.

To configure log rotation for Postfix on a Linux server, you can create a custom logrotate configuration file specifically for Postfix log files. Postfix logs are usually located at /var/log/maillog, /var/log/mail.log or something like that. You can create a logrotate configuration file at /etc/logrotate.d/postfix Here’s a sample file:

rotate 14

Explanation log rotation

  • rotate 14: Keep up to 14 rotated log files.
  • daily: Rotate the log files daily.
  • missingok: Do not generate an error if the log file is missing.
  • notifempty: Do not rotate the log file if it’s empty.
  • delaycompress: Compress the rotated log files one day after rotation.
  • compress: Compress the rotated log files using gzip.
  • postrotate/endscript: Execute a custom command after log rotation. This one is very cool! I didn’t use it on this example. Good for running scripts before or after.

Save the Configuration File: Save the changes to the “postfix” configuration file and exit the text editor.

Test Log Rotation: Test the log rotation configuration using the logrotate command with the -d or --debug option to simulate rotation without actually rotating files:

sudo logrotate -d /etc/logrotate.d/postfix

You can add -v option for verbose output. Use it! Verify that log rotation works as expected and that no errors occur.

Automatic Rotation: Logrotate is typically run as a cron job. It will automatically rotate log files based on the schedule defined in the configuration file.

As usual, you can contact me if you have any questions or like to collaborate. I’m working on fixing my online shop for now. Stay tuned.

Find uptime on Windows

The other day a client wanted to find out if his Windows machines were rebooting over the weekend. They had a scheduled task to apply updates and reboot. He wanted to quickly find uptime on Windows. I found some options:

Command line to find uptime on Windows

  1. Open your command line
  2. Type Systeminfo | find “Boot Time”

You should see something like:

Days: 9 Hours: 11 Minutes: 20 Seconds: 12

You can also query a remote Windows machine, but it seems to take longer to get results:

systemsinfo /S "machineName" | find "Boot Time"

Use the Task Manager to find uptime on Windows

  1. Open your task manager
  2. Expand ‘More Details’
  3. Go to Performance
  4. CPU
  5. See on the bottom ‘Up time’

Another way tricky way

This command is a bit tricky and I still need to find out how to read the results:

C:\Users\Tom> wmic path Win32_OperatingSystem get LastBootUpTime

After putting this brief tutorial together I decided to brew a good cup of Caturra coffee at home and head out for a walk.

As usual, you can contact me if you have questions or like to collaborate.

SEO Ready Website for Maximum Visibility

Making your website SEO ready involves optimizing various aspects of your site to improve its visibility and ranking in search engine results. I have to admit this topic is not my favorite, but is important if you want your website to be found by our good friend Google and other search engines.

After brewing my favorite coffee from Peru I decided to put a brief key steps to make your website SEO ready:

SEO analysis

  1. SEO title width: The SEO title has a viewable limit. Under 48 characters should be OK. Don’t make it too short either. Have at least four words. Include the focus keyphrase at the beginning.
  2. Text length: Write at least 300 words for your blog content. Include the focus keyphrase at least 2 times depending on the length of your text.
  3. Meta description length: The length should be from 120 to 156 characters long. Always include the focus keyphrase here.
  4. Key phrase length: Use the recommended maximum of 4 content words.
  5. Internal links: Have at least one internal link. Point it to a relevant content in your website.
  6. Outbound links: Have at least one external link.
  7. Images: Include at least one image with ALT tag using your focus keyphrase.

By following these steps and staying up-to-date with SEO best practices, you can make your website more SEO friendly and improve its visibility in search engine results.

SEO Website Readability

To enhance the ranking of your content, ensure it’s engaging and enjoyable to read. When your audience appreciates your writing, search engines will also do. Here are some steps to follow and make your website readability optimized:

  1. Passive voice: Use enough active voice. The recommended passive voice is 10%.
  2. Consecutive sentences: Use enough variety for your content. Do not start more than two sentences with the same word.
  3. Subheading distribution: Use subheading to divide your content. Probably use a subheading for every 150 words. Try to use your focus keyphrase in it.
  4. Paragraph length: Should be more than two sentences and less than 200 words.
  5. Sentence length: Do not write sentences longer than 20 words.
  6. Transition words: Use transition words for about. The recommended is 30% of your content should use transition words.

Print the email addresses with status=”bounced” in postfix mail log

To print the email addresses with status “bounced” only from the provided log file, you can use grep to filter lines containing “status=bounced” and then use awk to extract the email addresses. Here’s how you can do it:

grep "status=bounced" /var/log/mail.log | grep -oE 'to=<[^>]+>' | awk -F'<' '{print $2}' | awk -F'>' '{print $1}'


  • grep "status=bounced" /var/log/mail.log: This grep command filters lines from the mail log file containing “status=bounced”.
  • grep -oE 'to=<[^>]+>': This grep command uses a regular expression (-oE) to extract occurrences of “to=<…>” from the filtered lines and only outputs the matching text.
  • awk -F'<' '{print $2}': This awk command uses “<” as the field separator (-F'<') and prints the second field (the part after “<“).
  • awk -F'>' '{print $1}': This awk command uses “>” as the field separator (-F'>') and prints the first field (the part before “>”).

This series of commands will extract and print only the email addresses from lines with status “bounced” in the log file, removing any surrounding characters or additional information.

Continue reading “Print the email addresses with status=”bounced” in postfix mail log”

How to use pflogsumm command to analyze postfix logs

To use the pflogsumm command to find general rejection reasons in your mail logs, you need to ensure that your mail server logs contain the necessary information about rejected or bounced emails. Once you have the logs, you can use pflogsumm to analyze them and generate a summary report that includes rejection reasons. Here’s how you can do it:

Install pflogsumm:

sudo yum install postfix-perl-scripts


sudo apt-get install postfix-pflogsumm

Once installed, you can run pflogsumm with the path to your mail log file(s) as an argument. For example:

pflogsumm /var/log/mail.log

This command will analyze the mail logs and generate a summary report, including various statistics and information about mail delivery, rejection reasons, etc.

I feel pflogsumm give a general idea, but it does not show you specific emails that are deferring and/or reason(said). I need to look deeper into this and wear my favorite soy hat beanie to concentrate better.

AWStats install and configure in RedHat RHEL

After brewing a great Latin America coffee from Peru I received an email from on of my clients. The client recently installed Apache on RedHat RHEL and wanted to install and configure AWStats in order to track their traffic.

Personally, I don’t have much experience dealing with log files other than just using vim or grep to find the info I need. Anyways, I decided to wear my Espresso machine beanie and take a walk in NYC during the first snow day.

First, you need to SSH to your Linux server and install the perl dependencies:

sudo yum install perl-Time-HiRes perl-libwww-perl 

Next, download the latest version of AWStats or use yum to install it. This is what I did to get the latest AWStats version:


Extract the tar.gz

tar xvzf awstats-7.9.tar.gz 

Move the extracted folder to Apache root directory:

mv awstats-7.9 /var/www/html/awstats

Configure AWStats

Make a new directory in:

mkdir /etc/awstats

Then copy the sample config file from the awstats folder you moved above to your /etc/awstats:

sudo cp /var/www/html/awstats/wwwroot/cgi-bin/awstats.model.conf /etc/awstats/ 

Replace the name with your domain name/hostname.

Edit the new config you moved above. Use the text editor of your choice:

sudo vim /etc/awstats/ 

There are 3 main options I configure for my case:

LogFile: Path to your apache log file

SiteDomain: Domain name of your site.

DirData: Location AWStats will store data.

Configure Apache

Create a new host file:

sudo vim /etc/httpd/conf.d/awstats.<your_domain>.conf

You can use this sample conf file:

<VirtualHost *:80>
  DocumentRoot /var/www/html/awstats/wwwroot
  ScriptAlias /awstats/ /var/www/html/awstats/wwwroot/cgi-bin/
  <Directory /var/www/html/awstats/wwwroot/cgi-bin/>
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
  <Directory /var/www/html/awstats/wwwroot/>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all

Save changes. You may need to reload Apache.

Go back to:

cd /var/www/html/awstats/ 

and run the perl script in there:

perl tools/ now-config=<your_domain>.com -awstatsprog=./wwwroot/cgi-bin/ 

Finally, access your stats using this URL:


You should see some data displaying:

Configure AWStats RedHat server
Configure AWStats RedHat server

Hopefully this can help anybody to install and configure AWstats on your server. There are some tasks you should consider. Setup a cronjob to autoupdate AWStats database so it can access new log files. We should place the two commands above into a cronjob:

#maybe run every hour or daily?
0 * * * * cd /var/www/html/awstats/ && perl tools/ now -awstatsprog=./wwwroot/cgi-bin/

Change the cronjob as needed. Thanks!

Clean System Data storage using macOS Terminal

The other day a client contacted me panicking about one his new macOS running out of disk space. He told me his System Data storage shows over 300GB of space. I quickly remembered a related issue on older macs on how to clean system data storage using the terminal.

I quickly put my moka pot beanie, so I can think better. Then I ssh to the client’s mac in their office. After using our friendly commands to find more about disk space:

du -sh - Displays usage info for each file and directories.
df -h - Displays in human readable info on file system disk usage

Check the man pages for more details about the above commands.

To start to clean System Data storage using the Terminal I had to:

sudo su

In order to gain access to other users directories. So, I went to the only user for this mac:


I noticed the user’s Library folder was HUGE. Then I went for it:


Ran the below du -sh * to get all folders and their respective size. Wow! ScreenRecordings was taking a huge amount of space.

sh-3.2# du -sh *
452K	Accounts
1.1M	AppleMediaServices
188K	Application Scripts
5.5G	Application Support
2.6M	Assistant
  0B	Assistants
8.0K	Audio
  0B	Autosave Information
 92M	Biome
475M	Caches
4.5M	Calendars
  0B	CallServices
  0B	ColorPickers
  0B	Colors
  0B	Compositions
4.0K	Contacts
 12K	ContainerManager
415M	Containers
  0B	Cookies
299G	ScreenRecordings

In this case ScreenRecordings solve the issue. Other locations you can check are:

~/Application Support



~/Group Containers




~/Mobile Documents

clean system data storage
macOS storage

Remember to contact me if you have any questions or want to collaborate. Thanks!

Update macOS from Terminal

After another snow day in NYC a customer contacted me about not being able to push macOS updates using his MDM provider. Why is the MDM provider not working? Their support was not that helpful and they blamed Apple for the updates not working. Then I said to myself “update macos from terminal?”

Yes, I assumed to update macOS from Terminal was impossible. But, I wished this can be done without any user interaction.

These are the simple steps. Open your Terminal and run:

softwareupdate --list-full-installers

The above command will give you a list of available macOS full installers updates available. You should see an output like this:

Finding available software
Software Update found the following full installers:
* Title: macOS Sonoma, Version: 14.3, Size: 13073941KiB, Build: 23D56
* Title: macOS Sonoma, Version: 14.2.1, Size: 13066225KiB, Build: 23C71
* Title: macOS Sonoma, Version: 14.2, Size: 13066238KiB, Build: 23C64
* Title: macOS Sonoma, Version: 14.1.2, Size: 12604083KiB, Build: 23B92
* Title: macOS Sonoma, Version: 14.1.1, Size: 12604952KiB, Build: 23B81
* Title: macOS Sonoma, Version: 14.1, Size: 12603757KiB, Build: 23B74
* Title: macOS Ventura, Version: 13.6.4, Size: 11912664KiB, Build: 22G513
* Title: macOS Ventura, Version: 13.6.3, Size: 11915962KiB, Build: 22G436
* Title: macOS Ventura, Version: 13.6.1, Size: 11662168KiB, Build: 22G313
* Title: macOS Monterey, Version: 12.7.3, Size: 12109975KiB, Build: 21H1015
* Title: macOS Monterey, Version: 12.7.2, Size: 12116623KiB, Build: 21G1974
* Title: macOS Monterey, Version: 12.7.1, Size: 12110635KiB, Build: 21G920
* Title: macOS Big Sur, Version: 11.7.10, Size: 12125478KiB, Build: 20G1427

Next, you have some options available to download/install these macOS updates.

Download the latest macOS form Terminal

Run the below command:

softwareupdate --fetch-full-installer

The above command will download the latest macOS to your Applications folder. Once the download is done you can start it by double clicking on it. I’m trying to find a way to run it from the Terminal instead.

Download and install the update

Run the below command:

softwareupdate --fetch-full-installer --launch-installer

The above command will download and start the install windows interface. Follow the prompts.

Download specific update version to install later

Run the command:

softwareupdate --fetch-full-installer --full-installer-version version_number

The version_number is the version you saw from the previous command ‘softwareupdate –list-full-installers’. The text in bold below would be the version number:

Title: macOS Sonoma, Version: 14.3, Size: 13073941KiB, Build: 23D56

If you wanted to install the above macOS Sonoma version 14.3 run:

softwareupdate --fetch-full-installer --full-installer-version 14.3

The above will only download it. You will need to run the installer file from the Applications folder.

Launch the installer right away

softwareupdate --fetch-full-installer --full-installer-version version_number --launch-installer

I need to double check the above since it worked on one mac, but not on another one. More results coming soon. Let me run some more tests. Thanks.