Saturday, February 23, 2013

How to Create New User Account in Ubuntu Linux from command line?


Use useradd command create a new user or update default new user information from command line.

useradd testuser
passwd testuser

The above command will create a user named testuser and set its password to testuser. 

Some important files that define various properties etc for this user: 


  • /etc/passwd - User account information.
  • /etc/shadow - Secure user account information such as password.
  • /etc/group - Group account information.
  • /etc/default/useradd - Default values for account creation.
  • /etc/skel/ - Directory containing default files.
  • /etc/login.defs - Shadow password suite configuration.


Above command useradd will not create a home directory for this user. To create those try the below command that will create the user as well as home directory for it. 

sudo useradd -m -k /etc/skel -d /home/testuser testuser

This will create a user named test user with a home directory /home/testuser and will have the same files and settings as in /etc/skel.

To delete the user follow command: 

sudo userdel testuser




Thursday, February 21, 2013

"Too many connections" - Error when trying to connect to Mysql


If you get "Too many connections" error when trying to connect to Mysql Server that means all available connections have been allocated and used by other clients.


Actually the number of connections is limited by max_connections variable. To whatever value this variable is set, that many connections can be opened by clients to mysql. In actual it is set to max_connections + 1. The +1 is actually reserved for the Super User so that they can login to mysql and troubleshoot problems even if the usable connections have exhausted. 

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the amount of RAM available, how much RAM is used for each connection, the workload from each connection, and the desired response time.


How to read mysql logs in Amazon RDS


To get access to the MySql logs in RDS all you need to do is query the MySql table named general_log. 

By default the logging is disabled so you will probably see this table as empty if you have not configured your RDS DB Parameter group to enable logging. 

You can enable logging by going to DB Parameter group's "general_log" and enabling it either from RDS console or using RDS command line tool as below: 


rds-modify-db-parameter-group mydbparametergroup --parameters "name=general_log,value=ON,method=immediate"