Archive

Posts Tagged ‘linux’

Install GNOME or KDE desktop environment from the CLI mode

September 21, 2010 2 comments

Install GNOME or KDE desktop environment from the CLI mode

Yesterday I got a request from my user that they need graphical interface to be installed in the server as they require this for their project work. I knew that this is very simple to install using yum groupinstall but the problem I faced was terrific. As this was our internal server it was not connected the internet and it was a VM on VMware. Hence no physical optical drive was present. I am giving below the steps how I got that thing to work.

  1. Mount the ISO image of CD/DVD to your system. If you have a physical system you can insert the CD/DVD and mount or else you have to virtually mount this.

    mount /dev/cdrom /mnt
  2. Create one directory and put all the contents of the Server directory into it.

    mkdir /repository

    cp  -rvf  /mnt/Server/*  /repository/
  3. Unmount the CD/DVD drive.        
    umount /mnt

    If you face any problem in unmounting you can use the command        

    umount   -l /mnt

  4. Go inside the /repositories folder and install all the createrepo packages.

    rpm –ivh createrepo*
  5. Now go inside the folder/etc/yum.repos.d/ and create a file called myrepo and put the following contents to the file
      [base]
           name=Red Hat Enterprise Linux $releasever - $basearch - Debug
           baseurl=file:///repository/
           enabled=1
           gpgcheck=0
    
  6. Now Go inside /repository folder and check for a specific package yum-utils is present there or not.
          cd /repository
            ls –l| grep yum-utils

    This package is responsible for making group of packages.

  7. If it is not there you have to download this, keep inside this folder (/repository) and install it. You can download it from http://rpm.pbone.net/ .This website has the option of advanced search where you can download packages specific to particular OS version.
  8. Use createrepo command to create your repository
    createrepo   /repository/
    
  9. Now after creation of repository and installation of the package yum-utils you can try the command

    yum grouplist

    The output will list you some groups like given below

     Loading "rhnplugin" plugin
     Loading "installonlyn" plugin
     Setting up Group Process
     Setting up repositories
     rhel-debuginfo            100% |=========================| 1.1 kB    00:00
     Installed Groups:
               MySQL Database
               Editors
               System Tools
               FTP Server
               Network Servers
               Printing Support
               Mail Server
               Server Configuration Tools
     Available Groups:
               Administration Tools
               GNOME Software Development
               X Software Development
               GNOME Desktop Environment
               Authoring and Publishing
               Games and Entertainment
               X Window System
               KDE Software Development
               KDE (K Desktop Environment)
               Sound and Video
               Graphical Internet
               Done
  10. If you are not able to see output like given above then you need one xml file called comp.xml to create your own group.Below.If you don’t know how to create the xml file you can use the following link to create the comp.xml file.
  11. http://cooker.wbitt.com/index.php/Example_comps.xml_file

  12. After placing the comp.xml file inside /repository directories you have to recreate the repository.createrepo /repository
  13. Now run the command yum grouplist and you will see the output as below
    yum grouplist

    Sample output:

     Setting up Group Process
     Setting up repositories
     rhel-debuginfo            100% |=========================| 1.1 kB    00:00
     Installed Groups:
              Printing Support
     Available Groups:
              GNOME Desktop Environment
              X Window System
              Graphical Internet
     Done
    
  14. Now you can install the groups listed above. To install GNOME desktop Environment you can use the simple command
yum groupinstall "GNOME Desktop Environment"

Now you can use startx to see your graphical GNOME desktop screen.

Simillarly you can install KDE desktop environment.Just you need to change the xml file and give the command

yum groupinstall "KDE (K Desktop Environment)"

Advertisements
Categories: Linux Tags: , , , , ,

Set ,reset ,change or recover mysql passwords without worry

For system and database admins changing myssql password is a essential and risky task.It is very simple but yet very difficult sometimes. You may have the fear of data loss.Also sometimes you will get error like “ mysqladmin:  connect to server at ‘localhost’ failed error: ‘Access denied for user ‘root’@’localhost’ (using password: YES)’. “ So I will discuss in this topic on how to deal with mysql password problems.

There are 2 types of scenario you may face like

1.Changing Password for Normal user

2.Changing root password

To change password of a normal user:-

1.If you know the current password for a normal user then you can cahnge it by following command

 $mysqladmin -u username -p oldpassword password newpassword

EX:-To change password for a user called “kirti” and having password “parida” execute

$mysqladmin -u kirti -p  parida password ranjan

2.if you dont know the password of the normal user then login as root and follow the steps to reset the password.

Step-1:Login to the MySQL server, type the following command at the shell prompt:

$ mysql -u root -p 

Step-2: Use the mysql database (type commands at the mysql> prompt):

 mysql> use mysql; 

Step-3:Change password for a user:

 mysql> update user set password=PASSWORD("newpass") where User='username';

 EX:- mysql> update user set password=PASSWORD("parida123") where User='kirti';

step-4 Reload privileges:

 mysql> flush privileges;
mysql> quit

Note:So what we have done here is MySQL stores usernames and passwords in the user table inside the MySQL database. So we are updating a password using the above method to update or change passwords.

This method you need to use while using PHP or Perl scripting.

To Change the root password:-

N:B-Here I will discuss how to deal with root user.You have to remember that it is not the root user of your system it is root user of mysql database .Both are completely different.

1.If you know the current password for root user then you can cahnge it by using mysqladmin command from your shell

 $ mysqladmin -u root -p oldpassword newpass 

After changing the new password if you will encounter the following error

 Enter password:

 If you get...

 mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

then you have to follow the instructions below on how to recover your MySQL password.

2.If you know the current password for root user then you can cahnge it by updating the mysql user table(Recommended as it works in all situation and easy )

step-1: Login to the MySQL server, type the following command at the shell prompt:

 $ mysql -u root -p

step-2 :Use the mysql database (type commands at the mysql> prompt):

 mysql> use mysql;

step-3: Change password for a user:

 mysql> update user set password=PASSWORD("newpass") where User='root';

step-4: Reload privileges:

 mysql> flush privileges;
mysql> quit

Recover root user Password

This is the most critical part of your learnin as this deals with the worst possible scenario in your work.So please carefully follow the instructions.

You can recover a MySQL database server password with the following five easy steps:

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for a password.

Step # 3: Connect to the MySQL server as the root user.

Step # 4: Set a new root password.

Step # 5: Exit and restart the MySQL server.

Here are the commands you need to type for each step.As the commands directly affect system services so you need to login as root user(system root user) in your system.

Step # 1 : Stop the MySQL service:

 # /etc/init.d/mysql stop

Output:

 Stopping MySQL database server: mysqld.

Step # 2: Start the MySQL server w/o password:

 # mysqld_safe --skip-grant-tables &

Output:

 [1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to the MySQL server using the MySQL client:

 # mysql -u root

Output:

 Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: -fedora_12-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Step # 4: Set a new MySQL root user password:

 mysql> use mysql;
mysql> update user set password=PASSWORD("newpassword") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop the MySQL server:

 # /etc/init.d/mysql stop

Output:

 Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe --skip-grant-tables

Start the MySQL server and test it:

 # /etc/init.d/mysql start
# mysql -u root -p

Quick way to Reset Forgotten MySQL Root Password

Have you ever forgotten the root password on one of your MySQL servers? If you have forgotten then read below how to reset it quickly..

Log in as root in the system and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.

 $mysqld_safe --skip-grant-tables 

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

 $mysql --user=root mysql

 mysql>update user set password=PASSWORD('password') where user='root';
flush privileges;
exit;

Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.

Changing SSH keygen and SSH port perfectly without mistake

Now I am giong to discuss how to change the ssh keygen and port of your remote server.

It is important as setting of ssh keygen needs expertise and self confidense as it involves lots of risk.If you do it wrongly then you may lost connection to your remote server.Then your headache will start like contacting the hosting service provider or if you have a amazon cloud server you loose alla your data. Ok dont be afraid as now I am going to discuss step by step process on how to change your keygen.

Changing SSH Key:-

  • ssh to your server using good old user name and password
  • do check permissions on your ~/.ssh folder and make sure it is set to 700 or else execute

chmod 700 .ssh

  • do check permissions on your ~/.ssh/authorized_keys file and make sure it is set to 600 or else execute

chmod 600 authorized_keys

  • generate the keys on the server with something like

ssh-keygen -t dsa

(or rsa – read the man pages if your don’t know how to use ssh-keygen )

  • accept the file names it wants to use and give the correct path but make sure you type correct absolute path(/root/.ssh not .ssh)
  • enter a strong passphrase or no paraphrase
  • add the pub key to the authorized_keys file with something like

cat id_dsa.pub >> .ssh/authorized_keys

  • copy the private key (id_dsa) to your local windows machine (use winscp or sftp or some such tool)
  • NOW open puttygen.exe
  • under actions select “load” and load the id_dsa file
  • enter the passphrase you set when you generated the key on the server. Puttygen will now convert the key to something that putty will understand
  • save that file to something like

pivatekey.ppk

  • NOW change your putty settings under “connection > SSH > auth” to use

privatekey.ppk

  • NOW try and connect
  • enter the passphrase when prompted
  • Hurray You’re now connected to the server

Changing SSH server port:-

If you won’t change your production server ssh port then you will find a lot of illegal logins to your server.This can expose your server to high security risk.So you need to change the server SSH key before putting your server online.To change the port please follow the steps as mentioned below.


1. From your terminal session, edit /etc/ssh/sshd_config

            bash-2.05b# vi /etc/ssh/sshd_config

2. Look for the following line:

              #Port 22

3. Change the line so it looks like this:

                Port 2995

4. Save and close the file

5. Load the new configuration by using the RedHat service command

         service sshd reload

Note: you will immediately lose connectivity to your server on the open ssh session you are currently running as the port get changed.

6. Test the connection

              (comp@kirti)(~/Desktop) $ ssh username@myhostnaname.com -p 2995

Take note of the -p 2995 flag used when connecting to the server. If you are using OS X or a Linux desktop system like Mandriva or Ubuntu, you’ll need to specify the port number when connecting. If you’re using PuTTy on Windows, you can specify the port number in the profile for you connection and then re-save the profile using the new port.

7.If you have enabled ssh service at startup then please check this also.

vi /etc/xinetd.d/sshd

              service ssh
                    {
                disable = no
                socket_type  =  stream
                 type               =  UNLISTED
             port                = 22
             protocol         = tcp
             wait                = no
                user                = root
                server             = /usr/sbin/sshd
                server_args   = -i
                   }

Change “port = 22” for the new port 2295 and restart. Now You are safe from hackers those who use port 22 to get illegal entry to your server.

Categories: Linux Tags: , , , ,