Efficiently Managing User Accounts with Bash Scripting

Efficiently Managing User Accounts with Bash Scripting

Introduction

As a SysOps engineer, one of your primary responsibilities is to ensure the efficient management of user accounts. This involves creating user accounts, assigning them to appropriate groups, setting up home directories, generating secure passwords, and maintaining comprehensive logs. To streamline these tasks, we can automate the process with a bash script. In this article, we’ll walk through a script designed for this purpose.

Script Overview

The create_users.sh script reads a text file containing usernames and group names, creates the users and their respective groups, sets up home directories, generates random passwords, and logs all actions performed. This script is particularly useful in environments like ours, which uses HNG Internship guidelines.

Script Breakdown

Preparation

The script begins by checking if it is run with root privileges since creating users and groups requires administrative access. It then verifies that an input file is provided.

Setting Up Logging and Secure Directories

Logs are stored in /var/log/user_management.log, and passwords are securely stored in /var/secure/user_passwords.txt.

Creating Users and Groups

For each user, a personal group is created if it doesn’t already exist. Users are created and added to the specified groups. Home directories are set up with appropriate permissions.

Generating and Storing Passwords

A random password is generated for each user using openssl rand -base64 12, and passwords are securely stored in /var/secure/user_passwords.txt.

Error Handling

The script handles scenarios where users or groups already exist and logs these events.

Usage

To use the script, you need to supply a text file with the usernames and groups. The format of the file should be as follows:

light; sudo,dev,www-data
idimma; sudo
mayowa; dev,www-data

Running the Script

Run the script with the following command:

sudo bash create_users.sh <name-of-text-file>

Replace <name-of-text-file> with the actual file name containing the user details.

Conclusion

This script simplifies the process of managing user accounts, ensuring consistency and security. By automating these tasks, SysOps engineers can focus on more critical issues, enhancing overall productivity. For more insights into efficient management practices, consider exploring resources from the HNG Internship.

Script Code

Here is the complete create_users.sh script:

#!/bin/bash

# Check if the script is run as root
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" | tee -a /var/log/user_management.log
    exit 1
fi

# Check if the input file is provided
if [ -z "$1" ]; then
    echo "Usage: $0 " | tee -a /var/log/user_management.log
    exit 1
fi

USER_LIST_FILE=$1

# Ensure the log directory exists
mkdir -p /var/log
LOG_FILE="/var/log/user_management.log"

# Ensure the secure directory exists
SECURE_DIR="/var/secure"
mkdir -p $SECURE_DIR
chmod 700 $SECURE_DIR
PASSWORD_FILE="$SECURE_DIR/user_passwords.txt"

# Function to create a user and set up their home directory
create_user() {
    local username=$1
    local groups=$2

    # Create personal group
    if ! getent group "$username" > /dev/null 2>&1; then
        groupadd "$username"
        echo "Group $username created" | tee -a $LOG_FILE
    fi

    # Create the user
    if ! id "$username" > /dev/null 2>&1; then
        useradd -m -g "$username" -G "$groups" "$username"
        echo "User $username created and added to groups $groups" | tee -a $LOG_FILE

        # Generate a random password
        password=$(openssl rand -base64 12)
        echo "$username:$password" | chpasswd
        echo "$username,$password" >> $PASSWORD_FILE

        # Set appropriate permissions and ownership
        chown -R "$username":"$username" "/home/$username"
        chmod 700 "/home/$username"

        echo "Home directory for $username set up with appropriate permissions" | tee -a $LOG_FILE
    else
        echo "User $username already exists" | tee -a $LOG_FILE
    fi
}

# Read the user list file
while IFS=';' read -r username groups; do
    # Remove leading and trailing whitespace
    username=$(echo "$username" | xargs)
    groups=$(echo "$groups" | xargs | tr -d ' ')

    if [[ -n "$username" && -n "$groups" ]]; then
        create_user "$username" "$groups"
    fi
done < "$USER_LIST_FILE"

# Set permissions on the password file
chmod 600 $PASSWORD_FILE

echo "User creation process completed" | tee -a $LOG_FILE

By following these steps, you will ensure a comprehensive and effective user management process in your organization.

Saturday 6 July 2024
Posted by Gabriel Oyeyemi

Features That Make Microsoft Edge A Better Browser Than Others

With the release of the Windows 10 operating system, the Microsoft Edge browser was released on the market. It's not yet a finished software product as Microsoft still has new features in development for it but it is a working product and it delivers at least the basics required for browsing the web. Some people consider the initial release of Microsoft Edge to be quite promising while others consider it underwhelming. After using it for the last couple of weeks, we would like to share with you the things that we believe make Microsoft Edge a better browser than others. Here they are:

1. The Fastest Browser In Some Benchmarks

In terms of raw performance Microsoft Edge in very impressive. According to the JetStream 1.1 benchmark, Microsoft Edge is the fastest browser on the market. We ran this test on each popular browser on a Windows 10 device and in the chart below you can see the results we obtained:
Tuesday 17 December 2019
Posted by Gabriel Oyeyemi

Install Windows 10/8.1/8/7/Xp On Android Mobile/Tablet Dual Boot Using Change My Software


Hello friends, do you guys know that now we can also install windows Operating System on android mobiles or tablets using a simple software called “change my software”. In this tutorial i will explain how to download this software to Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot Using Change My Software 8.1/8/7/XP Editions with clean pictures of every step in the process.

Generally Android mobiles/tablets work on Jelly Bean, Kitkat or the latest Lollipop Operating systems Even though you can get Window OS if you want on your Android mobile/tablet by just following below very simple instructions.

Follow my instructions carefully those who want’s to change their Android OS to Windows OS.
Hello friends, do you guys know that now we can also install windows Operating System on android mobiles or tablets using a simple software called “change my software”. In this tutorial i will explain how to download this software to Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot Using Change My Software 10/8.1/8/7/XP Editions with clean pictures of every step in the process.

Generally Android mobiles/tablets work on Jelly Bean, Kitkat or the latest Lollipop Operating systems Even though you can get Window OS if you want on your Android mobile/tablet by just following below very simple instructions.

Follow my instructions carefully those who want’s to change their Android OS to Windows OS

Requirements to Install Windows 10/8.1/8/7/XP On Android Mobile/Tablet Dual Boot:

Android Tablet or Phone
Personal Computer/Laptop
USB Cable
Change My Software
High speed Internet Connection
15 Minutes of your time
Also Know About The:

Best file transfer application:- xender file transfer app for pc

Best app to get free recharge:- mcent free recharge app for pc

Above both articles are must read ones because those articles will give you good and new information.

Processes of Installing Windows 10/8.1/8/7 or XP are almost similar so i will explain each and every step clearly in the process of installing windows 8 on your Android mobile/tablet. After knowing how to install windows 8 on your android mobile you can easily install Windows 10/8.1/7/XP on your mobile/tablets.

Follow the below steps carefully to install windows 8 on your Android mobile.

Steps to Install Windows 8 on Android Mobile/Tablet:

To install windows 8 on Android you will need the requirements shown in the below image.
The software you will need is “Change my software 8 edition”, this software will change your Android OS to Windows OS and vice versa and it is very easy to use.
Download the Change my Software 8 edition from the below link.
mediafire

Download Change My Software 8 Edition
Now connect your Android device(mobile/tablet) to your computer using USB cable.
After connecting your devices, launch the change my software 8 edition in your computer.


Now choose Android > Windows 8 to install windows 8 on your android mobile.

Choose android to windows

Click on Continue after Checking your device is connected and working properly.


Now Select your language. Selecting Language is very important so pay attention when you are going to select.


After selecting the language, the process of downloading windows 8 drivers will start.
Downloading will take more time if you don’t have the high-speed internet connection. Wait until you see the “success” on the screen.



After completion of downloading process click on the “Install” button. Do not click on “Remove Android”. If you do you will not get dual-boot(Windows&Android), you get only windows on your android mobile/tablet.


Now the process of installing windows 8 will start on your Android device so be patient until the completion of installing all features and files.


After getting all features and the required files, your android mobile/tablet will automatically reboot.


After rebooting, choose windows 8 or Android to use in your android mobile/tablet.


First login usually takes more time so wait some time to use Windows 8 on your Android mobile/tablet.

That’s all you have to do guys to install windows 8 on your android mobile/tablet. You will get Windows 8 on your Android mobile/Tablet like shown in the below image.

Install Windows 8.1/8/7/Xp On Android Mobile/Tablet Dual Boot Using Change My Software
by rehman sk 123 comments


Hello friends, do you guys know that now we can also install windows Operating System on android mobiles or tablets using a simple software called “change my software”. In this tutorial i will explain how to download this software to Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot Using Change My Software 8.1/8/7/XP Editions with clean pictures of every step in the process.

Generally Android mobiles/tablets work on Jelly Bean, Kitkat or the latest Lollipop Operating systems Even though you can get Window OS if you want on your Android mobile/tablet by just following below very simple instructions.

Follow my instructions carefully those who want’s to change their Android OS to Windows OS

Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot (Steps):
Requirements to Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot:

Android Tablet or Phone
Personal Computer/Laptop
USB Cable
Change My Software
High speed Internet Connection
15 Minutes of your time
Also Know About The:

Best file transfer application:- xender file transfer app for pc

Best app to get free recharge:- mcent free recharge app for pc

Above both articles are must read ones because those articles will give you good and new information.

Processes of Installing Windows 8.1/8/7 or XP are almost similar so i will explain each and every step clearly in the process of installing windows 8 on your Android mobile/tablet. After knowing how to install windows 8 on your android mobile you can easily install Windows 8.1/7/XP on your mobile/tablets.

Follow the below steps carefully to install windows 8 on your Android mobile.

Steps to Install Windows 8 on Android Mobile/Tablet:

To install windows 8 on Android you will need the requirements shown in the below image.
Requirements-to-install-windows-81-8-7-xp-on-Android-Mobile-Tablet
Requirements-to-install-windows-81-8-7-xp-on-Android-Mobile-Tablet
Also Read: Download Whatsapp for PC Windows 8.1/8/7

The software you will need is “Change my software 8 edition”, this software will change your Android OS to Windows OS and vice versa and it is very easy to use.
Download the Change my Software 8 edition from the below link.


Download Chage My Software 8 Edition

Update: We (AllTechFeed Team) worked very hard to find a direct link to all the change my softwares. Use the below link to download the Change My Software 8.1/8/7/XP editions from the below link.

NOTE: Two months back we can download the Change My Software very easily with a single click from the official site but now users should have to submit a survey to download it for free or you have pay to download the software. We are not allowed to share the software, every user should download the software from the official site linked below.

Download Change My Software 8 Edition
Now connect your Android device(mobile/tablet) to your computer using USB cable.
After connecting your devices, launch the change my software 8 edition in your computer.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot run the downloaded file
Run change my software 8 edition in your computer
Flash Flash: Microsoft Revealed Different Versions of Windows 10



Now choose Android > Windows 8 to install windows 8 on your android mobile.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot choose android to windows
Choose android to windows
Click on Continue after Checking your device is connected and working properly.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot click on continue
click on continue after checking
Now Select your language. Selecting Language is very important so pay attention when you are going to select.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot select language
Selecting lanuage
After selecting the language, the process of downloading windows 8 drivers will start.
Downloading will take more time if you don’t have the high-speed internet connection. Wait until you see the “success” on the screen.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot downloading drivers
downloading windows 8 drivers
After completion of downloading process click on the “Install” button. Do not click on “Remove Android”. If you do you will not get dual-boot(Windows&Android), you get only windows on your android mobile/tablet.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot click on install

Now the process of installing windows 8 will start on your Android device so be patient until the completion of installing all features and files.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot wait for some time
Wait for some time to get all the features
Helpful Article For You: Know How To Use 2 WhatsApp Accounts In A Single Mobile – Whatsapp Trick 2015

After getting all features and the required files, your android mobile/tablet will automatically reboot.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot

Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot rebooting device
Your mobile/tablet will reboot
After rebooting, choose windows 8 or Android to use in your android mobile/tablet.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot choos the os to boot
Choose the OS to boot
First login usually takes more time so wait some time to use Windows 8 on your Android mobile/tablet.
Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot first login
First login into windows 8 on your android device
That’s all you have to do guys to install windows 8 on your android mobile/tablet. You will get Windows 8 on your Android mobile/Tablet like shown in the below image.

Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot windows 8 android
Windows 8 on Android mobile/tablet
How to Install Windows 10/8.1/8/7/XP On Android Mobile/Tablet Dual Boot:
I already told you that the process of installing Windows 10, 8.1, windows 7 and windows XP are all same as installing Windows 8. Only the Change my software edition is different in the processes.

You have to use “Change my software 8.1 Edition” to install Windows 8.1 on your android mobile/tablet.
Use “Change my software 10 Edition” to install Windows 10 on your android mobile/tablet.
Use “Change my software 7 Edition” to install Windows 7 on your android mobile/tablet.
Use “Change my software XP Edition” to install Windows XP on your android mobile/tablet.
Just change the software edition and follow the above process to Install Windows 10/8.1/8/7/XP On Android Mobile/Tablet Dual Boot.
Enjoy:)
I hope this tutorial helps you to Install Windows 8.1/8/7/XP On Android Mobile/Tablet Dual Boot Using Change My Software 8.1/8/7/XP Editions.
Tuesday 5 January 2016
Posted by Gabriel Oyeyemi

Google Reveals Top 10 Searches In 2015


As at the end of every year Google reveals top searches of the year. So according to Google here is the list of top 10 most searched topics of 2015.

1) Lamar Odem

Lamar Joseph Odem the most searched person on Google is an American professional basketball player, born on 6 November 1979, in Queens New York.

At the age of 12, Lamar Odom lost his mother has cancer. He started his professional career in 1999. He was a Los Angeles Lakers player in NBA from 2004 to 2011, he helped the team winning two NBA championships in 2009 and 2010 and because of wonderful and unique playing style in 2011 he was named NBA sixth man of the year.



2) Charlie Hebdo

Charlie Hebdo is a French word which means “Charlie weekly”. It is a French sarcastic weekly magazine based in Paris, France founded in 1969, presenting reports, cartoons, jokes and polemics.

No wonder why it is second most searched topic on Google in 2015. Yeah, no wonder because of its silly act, an Islamophobic act, an act that hurt the feelings of a billion and a half Muslims around the world. Actually not only Muslims but most of the Non-Muslims also condemn this act and find it guilty. Yeah this was the coward and unjustified act of making cartoon of the beloved Prophet Muhammad (PBUH). Later on they were also feeling ashamed and regretful on this disrespectful and blasphemous act.



3) Agar.io

Agar.io was first just a free multiplayer browser action game. On 8 July 2015 the mobile version for iOS and Android was also released by Miniclip.

In this game you are actually a cell. The aim is to grow the size of your cell by steering it around and swallowing different pellets smaller in size then you and will avoid bigger cells, because if larger cells got you they will consume you then.



4) Jurassic World

Jurassic World is a sci-fi American adventure movie, premiered on 29 May 2015 in Paris. It was the fourth release of the Jurassic Park series.

Directed by Colin Trevorrow

Produced by Patrick Crowley and Frank Marshall

Starring Vincent D’Onofrio, Nick Robinson, Chris Pratt, Bryce Dallas Howard, Irrfan Khan and Ty Simpkins

Written by Amanda Silver, Derek Connolly, Rick Jaffa and Collin Trevor row



5) Paris

Paris is on fifth number in the list of the most searches of 2015 on Google. Paris is the capital of France and a global center for fashion, art, culture and gastronomy.

This much search on Google was because of the seven coordinated terrorist attacks on Friday 13 November 2015 occurred in Paris and killed around 130 people. This huge incident made everyone to search about what, where and how this incident took place.



6) Furious 7

Furious 7 is a 2015 American action movie, premiered on 1st April 2015 in Los Angeles. It was the seventh release in the Fast and the Furious franchise.

Directed by James Wan,

Produced by Neal H. Moritz, Michael Fottrell, Vin Diesel

Written by Chris Morgan

Starring Vin Diesel, Paul walker, Tyrese Gibson, Michelle Rodriguez, Dwayne Johnson, Chris ‘Ludacris’ Bridges, Kurt Russell, Jordana Brewster and Jason Statham.



7) Fallout 4

Fallout 4 is a post-apocalyptic role-playing video game developed by Bethesda Game Studios and published by Bethesda Softworks. After the successful installment of Fallout 3 the Bethesda Game Studios released the fifth installment of the series on November 10, 2015.

It is a single player game and could be played on Play Station 4, Xbox one and Microsoft Windows platforms.



Ronda Rousey

Ronda Jeans Rousey is an American UFC Women’s Bantamweight Champion and an actress born on February 1, 1987 in California.

She mostly defeat her opponent in under a minute, in her last fight she defeated her opponent in 14 second. In 2008 at the Summer Olympics in Beijing she became the first US women to earn Bronze.



9) Caitlyn Jenner

Caitlyn Marie Jenner also known as Bruce Jenner was born on October 28, 1949 in New York, USA. She is an actress, producer and an Olympic decathlon champion. In 1976 she set a world record at the Summer Olympics in Montreal. The reason behind that made her on ninth number in the list of most searches on Google is her male-to-female transition, which she reveals in the interview with Diane Sawyer in April 2015.



10) American Sniper

American Sniper is an American biographical war film released on November 11, 2014. It was based on the most lethal sniper in the history of US military.

Directed by Clint Eastwood

Produced by Clint Eastwood, Andrew Lazar, Robert Lorenz, Peter Morgan and Bradley Cooper

Written by Jason Hall, starring Bradley Cooper and Sienna Miller
Friday 1 January 2016
Posted by Gabriel Oyeyemi

Top Sites For TV Show And Movie Downloads/ Site to download movies for free



Nigerians have a large indigenous movie industry referred to as Nollywood; however, this does not stop its citizens from keeping up with films, movies and shows from other parts of the world including America, Europe and other parts of Africa.

Fortunately, they do not always have to go to the cinema or buy the CDs to assuage these film related cravings. Thanks to the worldwide web, these movies and shows can now be downloaded from the internet – most times for free – and you do not have to miss any episode of your favorite show again (as long as you have interent data). Even better, these files are uploaded in different sizes and formats to suit a variety of screens including TV, iPads and Phones.

Fond of watching movies or shows and want to download your favorites? Jovago.com, Africa’s No.1 online hotel booking portal has compiled a list of 3 best websites to make your downloads absolutely free.

Fztvseries.mobi
Now back as MobileTVShows , the free movie download website which was initially closed down by Fact UK offers the best quality TV series, Cartoons/amines, documentaries, Bollywood/Indian movies and other videos for both mobile phones, tablets like iPad and other handheld devices. These free files on the website come in 3GP and MP4 formats, and you can also get the latest apps and games on this website.

www.o2tvseries.com
One of the most powerful platforms to download just TV shows and series either in 3GP or MP4 movies, o2tvseries has an easy-to-use interface. Find the latest uploads under the ‘Recently Added’ category and other shows in their alphabetical order. All the files available here are of very decent quality and you do not need to install any software even.

frendz4m.com
Frendz is a discussion forum where registered users can upload and download all sorts of videos, ranging from films, music videos, audio files, e-books and apps to TV shows and movies ( documentaries, Hollywood movies, Bollywood movies etc.). Video quality of the movies is very high, almost all title are on HD and You can stream and watch or you can just download movies for offline viewing.
Posted by Gabriel Oyeyemi

5 Easy Ways To Clean Up Your Messy Gmail Inbox


5 Easy Ways to Clean Up Your Messy Gmail Inbox

Tips and tricks for getting your inbox down to zero — and keeping it that way

It’s alarmingly easy to let your Gmail inbox spiral out of control. Going too long without deleting messages could make it nearly impossible to sift through your overflowing email account.

There are, however, a few steps you can take to keep your inbox from becoming unmanageable. Here are a few tips:

Use Labels. If you have one primary Gmail account that includes all of your personal messages and work-related content, you’ll want to take advantage of Gmail’s labels feature. This allows you to organize emails into categories the same way you would put files on your computer into folders. To create a label in Gmail, click the “More” button on the lefthand side on your inbox and select “Create new label.”

Turn on Send & Archive. When you’re done with a conversation, there’s no need to give it precious real estate in your inbox. Gmail has a feature called Send & Archive, which automatically archives an email thread as soon as you reply to an email. Just click the small gear icon that appears in the upper right hand corner of the Gmail interface, press the “Settings” button, and look for the “Send and Archive” subsection. Click the bubble that says “Show Send & Archive button in reply.”

Add the “Mark as Read” Button. If you’ve got tons of emails coming in from friends and coworkers, you may not want to archive or delete them right away. If you want to quickly mark a batch of emails as read, you’ll probably want to add the “Mark as Read” button to your toolbar. To do this, navigate to “Settings” and click on the “Labs” tab. Then scroll down to the “Mark as Read Button” and click “Enable.”

Try a Third-Party App. Using features built into Gmail can only help so much when it comes to making your inbox as manageable as possible. Some third party apps take care of other pain points and inconveniences. Mailstrom, for instance, can identify bundles of related emails so that it becomes easier to delete unwanted messages in bulk. Unroll.Me consolidates newsletters, promotions, and other subscription emails into a single message to prevent your inbox from becoming too cluttered.

Purge Your Inbox in Your Spare Time. These tools and apps certainly make the process easier, but maintaining a clean inbox still requires some amount of effort. The best way to keep emails from piling up is to make the conscious effort to delete or mark emails as read as often as possible in your spare time. For instance, getting into the habit of sorting through emails when you’ve got 10 minutes to kill before a meeting can really make a difference.
Posted by Gabriel Oyeyemi

Apple To Pay $5million Over Ios 9 Sluggish Performance


According to Apple Insider, Apple was hit with a lawsuit seeking over $5 Million, The complaint was iOS 9 bugged down their iPhone 4s performance, As You know the Apple Security Protocols which prevent users from Downgrading their iOS version, The iPhone 4s owners were forced to choose either the Sluggish iPhone 4s or get a new mobile phone, Because the Phone can’t be use for daily use.
And the issue was that Apple failed to warn their Customers that if they Upgraded to the new iOS 9, the new iOS would interfere with their device performance, The Plaintiffs argue that Apple must have known about the iPhone 4s ‘Slower Performance On iOS9 by Internal Testing before releasing the Update to the Public’ but didn’t warn their Customers. So it means if the lawsuit continues, Much People could be invited to benefit from the settlement.

BE INFORMED
#HAPPY_NEW_YEAR
Posted by Gabriel Oyeyemi

Popular Post

Blogger templates

- Copyright © GoldeNaija -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -