Create New User Accounts in Linux
Execute the following commands as root (using the sudo command).
Login with ROOT user
1. To find the path of useradd:
whereis useradd
2. To add the user:
sudo useradd -d directory_path username
For example:
sudo useradd -d /scratch/oracle oracle1
Or:
sudo useradd -d /scratch/fmwumbtest/ testUser
(You should create the directory on the local disk. On Linux, that means on /scratch.)
3. Then, change the password:
sudo passwd username
(You get prompted for the password.)
4. Add the user to a group (such as dba and g579):
usermod -G group_name username
5. Test the account by changing user:
su - username
(The dash means run their setup commands in the new account's root dir)
Removing User Accounts
On occasion, you may wish to remove a user's access from your server altogether.
If you are a Red Hat user, the easiest way to remove an unneeded user account is with the ``userdel'' command, which must be typed as ``root''. An example follows:
/usr/sbin/userdel baduser |
The above command will remove the entry matching the username ``baduser from the ``/etc/passwd'', file, and, if you're using the Shadow password format (which you should be; see Section 6.6 for details), the ``/etc/shadow''.
Note: Note: The ``/etc/group'' is not modified, to avoid removing a group that other user(s) may also belong to. This isn't much of a big deal, but if this bothers use, you can edit the group file and remove the entry manually.
Should you wish to remove the user's home directory as well, add the ``-r'' option to the ``userdel'' command. For example:
/usr/sbin/userdel -r baduser |
I recommend not removing an account right away, but first simply disable it, especially if you are working with a corporate server with lots of users. After all, the former user may one day require the use of his or her account again, or may request a file or two which was stored in their home directory. Or perhaps a new user (such as an employee replacement) may require access to the former user's files.
Examples
find -name 'mypage.htm'
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.
find / -name 'mypage.htm'
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.
find -name 'file*'
In the above example the system would search for any file beginning with file in the current directory and any subdirectory.
No comments:
Post a Comment