Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Thursday, February 2, 2012

Users and Groups in Linux - 2

Delete user

userdel command used for delete user. We can do it with root user.

Ex.
#userdel -f username
     // -f for delete user home directory.

Delete group

groupdel command used for delete group. We can use it with root user.


Ex.
#groupdel groupname

Files in Linux for User and Group
  • passwd
  • shadow
  • group
  • gshadow

     passwd
          The passwd file is used for store Linux User account information. And it'll be located in /etc/passwd. It contains root and system user accounts information also. So if any wrong changes happened it affect full Linux system. It only have read permission for all user and have edit permission for root.

     shadow
          The shadow file is mainly used for store Linux User's login passwords as encrypted. It located in /etc/shadow. It's encrypted passwords. So we can't use this passwords straightly for login. The root user only can access this file anything view are edit. Other user don't have permission to view this file.

     group
          The group file is as like passwd file. passwd is used to store user account information as like group file is used to store group information. It is located at /etc/group. It mainly used for store group name and their user name. Normal user can view this file. But only the root user can edit this.

     gshadow
          The gshadow is group password file, It is used for encrypted passwords of group. It is also as like shadow file. It is located at /etc/gshadow.The normal user can's view this and root user only can view and edit.


* Use man pages for more help.

Wednesday, February 1, 2012

Users and Groups in Linux - 1

Users :
Linux is Multi user environment. The users are those who can access the operating system resources with proper permissions as defined already.

Types of users :
I.   System Users
II.  Root User
III. Normal Users

I. System Users - They are default user in linux for some system process and service.
II. Root User - Root user is administrator of Linux System. He have all rights in machine. So should be very carefully with root user. Unknown mistakes may crash the system.
III. Normal Users - They are created by us for some reasons. They are limited users.

Groups : 
Groups are Logical experiences for tying users together. Normally groups are used to share files and permissions.

Types of groups :
I.   System Groups
II.  Root Group
III. Normal Groups

I.   System Groups - They are default groups in linux for some system process and services.
II.  Root Group - Root group is administrator group of Linux System.
III. Normal Groups - They are created by us for some reasons. They are limited groups.

Create User :
Normally we won't and can't create System users, It'll be created by system and or applications for services and maintainable. Root user will be created at the time of Linux installation.
for create a normal user we'll use the command "adduser".
We can use adduser command with root user only.

"useradd" command used to create a user. 
"passwd" command used to create password for user.

Ex.
[root@server ~]# useradd user1
[root@server ~]# passwd user1
user1

* Typed password won't be shown at terminal window
** Won't ask for password conformation for second time with root. (re enter password)

Create Group :
It also same as user. But When we create a user, the group for the user will be created with same name. A user must be with in a group. Two basic classifications in groups.

i   Primary Group
ii  Secondary Group

Primary Group - The user should be created with this group. He have all rights with in this group.
Secondary Group - The user may or may not have secondary group. And he may or may not have full rights with in this group.

"groupadd" command used to create a group.
Ex.
[root@server ~]# groupadd group1

User ID & Group ID
UID stored in /etc/passwd
GID stored in /etc/group

UID and GID are unique number for users and groups.
User and Group ID start with 0 and end with 65535.
0 - root user and group
1 - 500 for system users and groups
501 - 60000 for Normal user and groups
60001 - 65535 for duplicate user and group id.
A user can be assigned with multiple ID and these multiple ID numbers are chosen from this range of Duplicate ID range.

* Use man pages for more help.


While searching about it i got following questions :
i      How to create user without group ?
ii     How to create user with already created group ?
iii    How to create user without password ?
iv    How to create user with more groups ?
v     Is possible to change primary group of user ?
vi    How to remove user from the group ?
vii   How to delete a user ?
viii  How to delete a group ?  
ix    How to make a user as root privileged ?
x     Is it possible to edit passwd / group file manually ? And it take affects in user and group ?
xii   Is it possible to create a user without user directory and how ?

Thursday, August 18, 2011

User accounts in Linux

Super User in Linux

Super User is the user with all rights for accessing all files, Like Windows Administrator. Here the super user is "root".

This user have all rights to access all files including system files. Should be careful if you are root. It can delete any files. So it may crash total system.

The root user can be created at the time of installation.


Adding User in Linux

The root user can add user to Linux box. Following command can be used for adding user in Linux.

[root@LocalHost ~]#useradd kumar

For setup password, Following command can be used,

[root@LocalHost ~]#passwd kumar
Changing password for user kumar.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

You'll get a warning message if you give any dictionary word.
"BAD PASSWORD: it is based on a dictionary word"

You can create user without password, also can disable password for a user. Passwordless account.

[root@LocalHost ~]#passwd -d kumar
Removing password for user kumar.
passwd: Success

For more details use man pages of useradd and passwd.

Every user have home directory as the user name, location is /home/{user name}.


Delete User

Following command is used to delete user,

[root@LocalHost ~]#userdel kumar

It delete user alone, home directory will be avaliable in /home/

For delete home diectory of the user, we use the option -r.
For delete the user forcely , we use the option -f.


User Groups

We can add groups in Linux, Groups are used for permission to accessing files and security. Group have one or more users.

For add group,

[root@LocalHost ~]#groupadd adminnote

When we create a user it automatically create group in the same user name. Every users must be in group, Every user have one primary group and may or may not secondary group. For Example, kumar is the user and he should be in the group kumar, It's primary group of the user kumar. And the user kumar may or may not in the group adminnote.

For checking group of the user, try following command.

[root@LocalHost ~]#groups kumar
kumar : kumar

For more details about this refere some Books of Linux.

Wednesday, August 3, 2011

Basic in Linux

Linux is one of the operation system. We can tell it as UNIX like operating system. It is open source, It come under GNU public license. We can use it as free. For more and updated details about Linux try Wikipedia.

Now we'll go for learning Linux throw command line, Before go administration these are some basics,

Terminal

The terminal is using for executing commends in Linux box. If we open terminal, it looks as bellow

[kumar@LocalHost ~]$

Here "kumar" is user account in Linux box. "LocalHost" is host name of your system, that means your system name. Normally till (~) symbol mention home directory of the logged user. If you are as root user , it looks as bellow

[root@LocalHost ~]#

Here you can see a difference in both things, that is dollar ($) symbol and Hash (#). There normal user have $ symbol at end and root user have # symbol at the end. This is easily to identify which user we have logged.

Executable commends in Linux are stored in /bin and /sbin directories. The normal user are can access only commends under /bin , They can's use /sbin commends. But the root user can access both /bin and /sbin directory commends.

root is the administrator account. If we made and mistakes while in root account, there is chance to crash hole system.

man:

man is a very basic command in Linux box. We normal know it as man pages. The man pages are manual of commands. most of the commands in Linux have man pages. It describe all about commands. The syntax of the man page is "man {command}"

ex:
[kumar@LocalHost ~]$man ls 

ls:

ls is the basic command in Linux box, ls is used to list files.
ex: 
[kumar@LocalHost ~]$ ls
[kumar@LocalHost ~]$

Here we didn't create any files, so it didn't give any output.

cat:

cat command is used to show the file. And also this is used to create and append the file.

cat {FileName} - Open file
cat > {FileName} - Create file
cat >> {FileName} - Append file
ex:
[kumar@LocalHost ~]$ cat > filename
hi this is my first file

[kumar@LocalHost ~]$ cat filename
hi this is my first file
[kumar@LocalHost ~]$ cat >> filename
this is additional lines

[kumar@LocalHost ~]$ cat filename
hi this is my first file
this is additional lines
[kumar@LocalHost ~]$

"ctrl + c" used to quit file, It'll save and exit from cat.

We can't edit already created file with "cat" command. For this we are going for other editors available in Linux.
ex: vi, vim etc.,

Before we going to editors we'll see the "ls" command, As seen before ls is the command used for list file in Linux,

[kumar@LocalHost ~]$ ls
filename
[kumar@LocalHost ~]$

This is the file we created as before by "cat".
ex:

[kumar@LocalHost ~]$ ls -l
total 4
-rw-rw-r-- 1 kumar kumar 50 Aug  3 11:47 filename

Here -l is the option for ls command, It give some detailed information about the file or directory.

"total 4" is blocks used by the file "filename".

"-rw-rw-r--" is about file permission, we'll see about it later.
"1" is about file count.
"kumar" is owner of file
"kumar" is group under this file
"50"  file size
"Aug 3 11.47" file creation date and time
"filename" name of the file

for more option try man pages and try more,

mkdir:

mkdir is the command used to create folder in Linux box.
ex:
[kumar@LocalHost ~] mkdir myfolder

rm:

rm is the command used to remove folder or file.
ex:
rm {filename}

options:
-f used to force the deletion, it won't ask conformation
-r used for recursive deletion, i meant it used to delete entire folder

[kumar@LocalHost ~] rm -f filename
[kumar@LocalHost ~] rm -fr myfolder

vim:
vim is the editor, It is advance version of the vi editor. vim editor can be used to create, edit and update file.

ex:
[kumar@LocalHost ~] vim newfile

It'll open editor window, Normally it in uneditable mode. By press "i" key we can move to edit mode, to quit from edit mode, press "esc" key.
After finish typing, press "esc" key and type ":wq" for save and quit. Here w for save and q for quid vim. We can use this command separately. For quit without changes, ":q!".

For more options try man pages.