Visit Our UNIX and Linux User Community


Script for User Management (Create, Delete, Disable...etc)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for User Management (Create, Delete, Disable...etc)
# 1  
Old 07-26-2017
Script for User Management (Create, Delete, Disable...etc)

Hi Everyone,

Am very new to shell scripting and would need help on a script that needs to be executed on a central server which takes IP, Flavor (AIX, Solaris, RHEL) as inputs and create a new account/user, update the existing users settings, delete or disable the users/accounts in those servers (AIX, Solaris, RHEL).

Please post if any having a working script?
# 2  
Old 07-26-2017
Welcome VenkatPVS,

I have a few to questions pose in response first:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.


Kind regards,
Robin
# 3  
Old 07-27-2017
Quote:
Originally Posted by VenkatPVS
Please post if any having a working script?
Sorry, but this is not how it works: you will write your script! And while we will assist you, explain things to you, correct your code if necessary and help you in any possible way - we will not write it for you.


Quote:
Originally Posted by VenkatPVS
Am very new to shell scripting and would need help on a script that needs to be executed on a central server which takes IP, Flavor (AIX, Solaris, RHEL) as inputs and create a new account/user, update the existing users settings, delete or disable the users/accounts in those servers (AIX, Solaris, RHEL).
OK, two things: first a question. There are generalised user-directory services which could be used for that: LDAP, NIS, DCE, ... Why don't you use one of these? All the mentioned UNIX/Linux flavours could be brought to cooperate with these services and you would not even have to create or maintain local users.

Second, reagrding the script itself: it is possible to do this and in fact i have done so. Notice that - to do it right - this is an effort worth several thousand lines of code. Not even an expert in scripting will be able to do it in some spare minutes to kill. This is a regular software engineering project and you should treat it that way from the start. This means before you can write even one line of code you need a thorough plan, you need to have thought things through and you need to have a detailed and concise idea of what you are going to do - "manage users on many systems" is like "i want to design a car". As long as you do not know how motors, gearboxes, brakes, etc. work this will not succeed.

OK, let us start by planning some basics. Every user is identified by a user name and a (unique) ID. Usually you find both informations in a file called /etc/passwd. You might want to start by not creating a user account but a script (function) that just checks if a user exists already.

Now think about what could come out for such a check. Here are some sample conditions, you might find more:

- the file /etc/password doesn't exist or isn't readable
- the user name exists in an account, but with another UID
- the user ID exists in an account, but with another name
- both user name and ID exist, but in different users
- the user name exists and has the correct ID (-> this is the "success" case)

All these (and probably more, be creative) conditions will have to be checked and reported (to an eventual calling program) by the check-function/-script.

You should have an idea now of what it takes to do what you want and start the design process.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Disable create subdirectory Solaris 8 ftp

Running Solaris 10. For FTP users or groups, I want to prevent them from creating new subdirectories, but I still want to allow them to create, upload, download files from the subdirs. I understand how to set the general file/directory permissions -- read, write, execute. So for a directory,... (0 Replies)
Discussion started by: themonman
0 Replies

2. Shell Programming and Scripting

Create user builder script

Hello this script should get username and password from user and then create. how can i send an arguman to passwd command ? echo "Enter username" read username useradd $username -s /bin/false echo "enter password for $username" read password passwd $username (2 Replies)
Discussion started by: nimafire
2 Replies

3. UNIX for Dummies Questions & Answers

How to create a file even root user also cant delete?

Is there any way to create a file in linux that root user also can't delete? (8 Replies)
Discussion started by: palani13dec
8 Replies

4. HP-UX

Need help to create a script to delete the files

Hi All, I want to delete all core* files in below file system in Unix server. File system: /usr/sap/P01/JC00/j2ee/cluster/server0 I want to setup a cron job every ten minutes to delete the core *files Thanks N Rao (2 Replies)
Discussion started by: YNRao24
2 Replies

5. Shell Programming and Scripting

Need help to create a script to delete the files

Hi All, I want to delete all core* files in below file system in Unix server. File system: /usr/sap/P01/JC00/j2ee/cluster/server0 I want to setup a cron job every ten minutes to delete the core *files Thanks N Rao This thread duplicates another thread with the same title: Need... (1 Reply)
Discussion started by: YNRao24
1 Replies

6. Shell Programming and Scripting

Create user if UID not exist; else, exit the script

Hi, I want to write a script to check whether an user ID is used in my server and then create that user. If the user ID is not used, I will echo something like "OK, continue" and then continue to execute the script. Else, I will echo something like "Used, exit" and then exit the script. As... (4 Replies)
Discussion started by: dirkaulo
4 Replies

7. Solaris

Unable to create or delete a directory in /usr with root user

Hi All, I am trying to uninstall jdk 1.5 from my Solaris 10 64 bit but some how was not successful.so tried to delete the folder of jdk from /usr but its throughing error as: Unable to remove directory jdk: Read-only file system Even I tried to create a dir in /usr but its not allowing me... (4 Replies)
Discussion started by: Pshah
4 Replies

8. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

9. Shell Programming and Scripting

Create a script that executes when a user attempts to delete history logs

Hi, I have a linux redhat 9 server and I am concerned about the security on that server. I would like to be able to write a script that records all the commands that were typed at the command prompt before the user calls the 'history -c' command and deletes all the history. I was thinking about... (4 Replies)
Discussion started by: mishkamima
4 Replies

10. UNIX for Dummies Questions & Answers

disable power management to a PCI card

I have a US Robotics USR5416 wireless networking card and everytime after hours of inactivity the cardseems to shutdown. I read somewhere the it does not support power management. Is there a way to disable power management to that particular PCI card? (0 Replies)
Discussion started by: diesel440
0 Replies

Featured Tech Videos