How To Add Linux User To Group

All Linux users have a user ID and a group ID and a unique numerical identification number called a userid (UID) and a groupid (GID) respectively. Groups can be assigned for a single user or a group or users together for a common security, privilege and access purpose.
/etc/group is an ASCII file which defines the groups to which users belong. There is one entry per line, and each line has the format:

group_name:passwd:GID:user_list

The field descriptions are: group_name – the name of the group. password – the (encrypted) group password. If this field is empty, no password is needed. GID – the numerical group ID. user_list – all the group member’s user names, separated by commas. There are two types of group, first is primary user group and other is supplementary group. How to create Linux ‘Admin’ group? Type:

#groupadd admin

How to add a new Linux user ‘eric’  to primary group ‘admin’? Type:

#useradd -g admin eric

#id eric
uid=1000(eric) gid=1000(admin) groups=1000(admin)

How to add a new Linux user to supplementary group1,group2 and group3? Type:

#useradd -g admin -G group1,group2,group3 user

OR

#id user
uid=1289(user) gid=1000(admin) groups=1000(group1),1001(group2),1002(group3)

Edit /etc/default/useradd file and add

GROUPS=group1,group2,group3

Save

#useradd user -g admin

#id user
uid=1289(user) gid=1000(admin) groups=1001(group1),1002(group2),1003(group3)

Read more

Possibly Related Posts:


How To Check Number of SSH and Telnet session

How to check number of Telnet/SSH session:

Telnet
netstat | grep telnet -c
netstat -n | grep :23 -c

SSH
netstat |grep ssh -c
netstat -n | grep :22 -c

Read more

Possibly Related Posts:


Inactive TELNET session timeout

The previous post about “Why Telnet Not Working From Different Network” solved my stupid mistake and I have discover another interesting regarding telnet.

Normally if anyone ‘telnet’ to server box and inactive(mean without login) for 60 seconds, the system will keep disconnect automatically. Due to certain reasons, I have to extend the inactive telnet session timeout to one hour.

The solution is simple but I have a difficulty before and I would like to share with everyone.

Edit /etc/login.defs, look for LOGIN_TIMEOUT and change from 60 second to 3600 seconds which is 1 hour.

#vi /etc/login.defs
# Max time in seconds for login
LOGIN_TIMEOUT 3600

Read more

Possibly Related Posts:


How to housekeeping OMSA TTY log file on Linux

Previously I wrote about How To Install/Uninstall Dell Open Manage Server Administrator(OMSA) On SLES9 or SLES10 and I found another error which is TTY log that keep increasing without automated housekeeping.

As I understand from Dell malling list, there is no way to turn it off. Too bad, I have a TTY log file that almost go up to 1G.

-rw-rw-r-- 1 root root 962M Jun 11 05:45 /var/log/TTY_00000000.log

So, let me explain how to housekeeping OMSA TTY log file using logrotate.

Edit /etc/logrotate.d/omsa-tty and save it as below:

#vi /etc/logrotate.d/omsa-tty
/var/log/TTY_00000000.log {
daily
dateext
notifempty
rotate 7
compress
postrotate
/etc/init.d/dsm_om_shrsvc restart
endscript
}

Read more

Possibly Related Posts:


SSH known_hosts Cheat Sheet

Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two computers. SSH uses public-key cryptography to authenticate the remote computer and allow the remote computer to authenticate the user.

In order to use public-key secure connection with other Linux hosts (ssh, scp, sftp) there is a special directory, ~/.ssh/, where passphrases and public keys are stored. Normally you wouldn’t need to know the gory details, but from time to time a host will change its public key and then you have difficulty using ssh, sftp or scp with that host, and have to edit a file named known_hosts.

If you try to ssh to another computer, but get an error message that warns about a changed or incorrect public key, then it is probably just a case of that host changing its public key. (It is possible, though usually not the case, that malicious hacking is involved.) Unless you actually suspect hacker involvement, you can edit the file ~/.ssh/known_hosts using your usual text editor (vi, emacs, or pico) and delete any line with the name or IP address of that host. Then when you try to ssh that host again, it will be like the first time ever; ssh will ask you if you want to accept a new public key, you type the whole word yes, and everything will proceed normally from there.

Said for an example, I have a Linux cluster running on 2 machines(active/passive mode) and usually users are connect using a virtual hostname or virtual IP address. Whenever Linux cluster or heartbeat switches over to the second machine and you try to ssh to it, ssh will reply with a WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! Annoying right?

So?

How to ignore SSH known_hosts in these case?
How to make SSH known_hosts work for cluster environments?

SSH known_hosts cheat sheet

Imagine you have the 2 cluster machines node1 and node2 with virtual hostname running as below:

node1 – IP address: 192.168.1.1
node2 – IP address: 192.168.1.2

Read more

Possibly Related Posts:


Next Page →

Planet Malaysia

  • Follow us on Twitter


  • web www.planetmy.com