Welcome To My Blog

Sunday, January 2, 2011

Summary #5 - Network & System Administration (NSA)

root - super user with unrestricted access to all system resources and files
-has user ID, of 0 which is universally identified, belong to a user with supreme privileges.
-log in as root to add new users

Debian Note: 
When installing Ubuntu Linux systems-will be prompted to create
a primary user that is not root.
root user is created but no password is set-cannot log in as this user.
primary user can become the root(sudo su - )

Adding users
1) Arrange list of users into groups by function.
e.g: "parents", "children" and "soho".

Parents    Children     Soho

Paul       Alice        Accounts
Jane       Derek        Sales

Add the Linux groups to your server:

[root@bigboy tmp]# groupadd parents
[root@bigboy tmp]# groupadd children
[root@bigboy tmp]# groupadd soho

Add the Linux users and assign them to their respective groups:

[root@bigboy tmp]# useradd -g parents paul
[root@bigboy tmp]# useradd -g parents jane
[root@bigboy tmp]# useradd -g children derek
[root@bigboy tmp]# useradd -g children alice
[root@bigboy tmp]# useradd -g soho accounts
[root@bigboy tmp]# useradd -g soho sales

group with same name as the user is created without -g
first logs in-will be prompted for new permanent password

Each user's personal directory is placed in the /home directory.
directory name will be the same as their user name.

[root@bigboy tmp]# ll /home
drwxr-xr-x    2 root     root        12288 Jul 24 20:04 lost+found
drwx------    2 accounts soho         1024 Jul 24 20:33 accounts
drwx------    2 alice    children     1024 Jul 24 20:33 alice
drwx------    2 derek    children     1024 Jul 24 20:33 derek
drwx------    2 jane     parents      1024 Jul 24 20:33 jane
drwx------    2 paul     parents      1024 Jul 24 20:33 paul
drwx------    2 sales    soho         1024 Jul 24 20:33 sales

create password
passwd command
will be prompted once for old password and twice for the new one.
 
User root changing the password for user paul.
[root@bigboy root]# passwd paul
Changing password for user paul.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bigboy root]#

unprivileged user paul would change his own password:
[paul@bigboy paul]$ passwd
Changing password for paul
Old password: your current password
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password: your new password
Re-enter new password: your new password
Password changed.

userdel-remove the user's record from /etc/passwd and /etc/shadow used in the login process(single argument:the username).
[root@bigboy tmp]# userdel paul

optional -r ->removes all the contents of the user's home directory.
[root@bigboy tmp]# userdel -r paul

How to Tell the Groups to Which a User Belongs?

Use the groups command with the username as the argument.

[root@bigboy root]# groups paul
paul : parents
[root@bigboy root]#

chown ->change the ownership of a file.
first argument=username and group ownership
separated by a colon (:) followed by the filename.
e.g.change ownership of the file named text.txt
from being owned by user root and group root to being owned by user testuser in the group users:

[root@bigboy tmp]# ll test.txt
-rw-r--r--  1 root root 0 Nov 17 22:14 test.txt
[root@bigboy tmp]# chown testuser:users test.txt
[root@bigboy tmp]# ll test.txt
-rw-r--r--  1 testuser users 0 Nov 17 22:14 test.txt
chown command with -r switch for it to do recursive searches down into directories to change permissions

sudo utility - allows users defined in the /etc/sudoers configuration file to have temporary access to run commands
commands can be run as user "root" /any other user defined in /etc/sudoers
sudo followed by the command's regular syntax.
commands run as sudo are logged in the log file /var/log/messages.

Temporarily Gaining root Privileges
e.g: user bob attempts to view the contents of the /etc/sudoers file,
Without sudo, the command fails:

[bob@bigboy bob]$ more /etc/sudoers
/etc/sudoers: Permission denied
[bob@bigboy bob]$

Bob tries again using sudo and his regular user password and is successful:

[bob@bigboy bob]$ sudo more /etc/sudoers
Password:
...
...
[bob@bigboy bob]$

Becoming root for a Complete Login Session

su command-allows regular user to become the system's root user
if they know the root password.
someuser@u-bigboy:~$ sudo su -
Password:
root@u-bigboy:~#

Downloading and Installing the sudo Package
installed by default
visudo-text editor that mimics vi editor->used to edit the /etc/sudoers configuration file.
uses the same commands as the vi text editor.
run as user root, no arguments:
[root@aqua tmp]# visudo

No comments: