Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, August 27, 2012

How to solve "sudo: unable to resolve host " problem ??

     Remember the previous post in which i wrote about changing your system's hostname from terminal. While many of you would have encountered a error message "sudo : unable to resolve host yourhostname" while you install or perform any task that requires root privileges. But wait, don't jump to the conclusion that you won't be able to continue your task, you can still continue with your task. There is a simple thing you have to do to get rid of this error.

  • When you edited the hostname file in /etc/hostname, the hostname file just contains the machine name.
  • You have to make the same change to the hosts file in /etc/hosts.
Viewing contents of both files in terminal:
  • Both the contents of the file can be viewed directly from the terminal using the commands,
      • cat /etc/hostname (or) hostname
      • cat /etc/hosts
      •  
  • From the above image you can see that, the hostname is aldo while the name in hosts is vms20591.
Viewing contents of both files in text editor: 
  • To view the contents of the file in text editor type the following commands,
      • sudo gedit /etc/hostname
      • sudo gedit /etc/hosts
  • Note:
    • Remember that still you will get the error "sudo : unable to resolve host yourhostname", but just ignore it and type your password.
    • Also don't forget to run the command using sudo without that you can't make any changes in the hosts.




    • You can see the hostname varies in both files.
Making changes to the files:
  • In order to get rid of the error, the name in the files /etc/hostname and /etc/hosts should be the same.
  • Use the command previously mentioned,
      • sudo gedit /etc/hostname
      • sudo gedit /etc/hosts 



  • After making the changes reboot the system and see if the error has been cleared.


     So, the error which occurred was eliminated just by making sure the hostname in both files were the same. Hope this information was useful.



















Saturday, August 25, 2012

Obtaining GNOME and Unity version in Ubuntu via terminal

     Many of the users are so puzzled when they hear news about the latest release of GNOME and the features of Unity in the coming version of Ubuntu. But wait, what is the current version of these in my system of now? The answers for your questions comes with two simple commands from terminal.

GNOME version in Ubuntu:
  • Type the following command in terminal,
      • gnome-session --version

Unity version in Ubuntu:
  • Type the following command in terminal,
      • unity --version

 Additional information:
  •  To find out what option we selected (ubuntu or ubuntu 2d) during the login screen provided by display manager type the command,
      • echo $GDMSESSION
      • echo $DESKTOP_SESSION

    •  If you selected ubuntu at the login screen then it will be displayed as ubuntu.
    • The login screen options when you click ubuntu circle next to your profile name,

  •  To display the current desktop type the following command,
      • echo $XDG_CURRENT_DESKTOP
  •  All these weird names up here are the environmental variables. To have a detailed view about these type the following command,
      • env
 

     Hope you got benefited by the information provided. Hoping to provide more tips and tricks for the users.








 

Friday, August 24, 2012

How to Install Ubuntu Tweak via PPA?


     Ubuntu Tweak is an all in one configuration tool which is exclusively designed for the Ubuntu GNOME desktop. Ubuntu Tweak is so special when its comes to functionality because with this tool you can configure your system and desktop settings which the default desktop environment provide. Ubuntu Tweak is an open source project and so it is free to download. 
     Ubuntu Tweak can be either downloaded from the website or installed via terminal. Since, working with terminal is fun, efficient and time saving let me guide on installing Ubuntu Tweak via PPA.

Step 1:
    • Launch terminal and type the following command,
        • sudo add-apt-repository ppa:tualatrix/ppa
    • Press Enter.
    • After you press Enter you will be prompted to enter your administrator password so type your password and press Enter.
    • Then you will prompted with a message in the terminal which says
      • You are about to add the following PPA to your system: The official Ubuntu Tweak stable repository More info: https://launchpad.net/~tualatrix/+archive/ppa Press [ENTER] to continue or ctrl-c to cancel adding it
    • Press Enter to continue.
    • Wait for the PPA to verify the source.
    • The PPA will be successfully added to the system.

Step 2:
    • Now you need to update the package manager with the  command,
        • sudo apt-get update
    • Wait for the update to be completed.

Step 3:
    • The final step is installing Ubuntu Tweak.
        • sudo apt-get install gnome-tweak
    • After pressing Enter type your administrator password and press Enter.
    • You will be prompted to download certain amount of data from the web so type y and press Enter.
    • Wait for the installation to complete. 
  
Step 4:
    •  Launch the application from the terminal using the command,
        • nohup ubuntu-tweak &

     Now, you can work your way through the tool to configure your desktop based on your needs. Ubuntu Tweak is an efficient and faster tool for the users. Hope the information would help you get started with this application.

Wednesday, August 22, 2012

Preventing termination of an application launched from terminal

     The traditional way of launching applications was to search for the application icon either from the start menu or through the desktop icon or through any other means.

     Since, Ubuntu users do anything and everything through terminal opening a GUI application too will be their concern. When a user launches an application from terminal and close the terminal because they feel so, results in the termination of the application that was just launched.

How to execute a C/C++ program from terminal?

     Software developers and programmers  will get excited when it comes to programming especially linux users who always mess around with open source software they use. Several IDE's are available where code developers and programmers can test their programs in GUI based environment. Since, terminal users will always rely on it for any kind of task, compiling and executing programs is not going to be an exception. With some simple steps in terminal this can be achieved.

Step 1: Creating a directory for programs
    • Open Terminal available under application menu in dash home.
    • Create a folder of your wish say "sampleprograms" to store your programs,
        • mkdir sampleprograms
    • Switch to the sampleprograms directory,
        • cd sampleprograms


Step 2: Writing the c/c++ program
    • Next, we shall try a sample "hello world!!" program.
    • To write the c/c++ program gedit or any text editor can be used.
    • gedit can be invoked from using the command,
        • sudo gedit helloworld.c (for c program)
        • sudo gedit helloworld.cpp (for c++ program) 
    • Press Enter.
    • After typing the program, save it and the close the editor.
    • Now you have finished writing your c/c++ code.




Step 3: 
  • Compiling C program
    • To compile the C program type the following command,
        • gcc -Wall -Werror -W helloworld.c -o helloworld
    • Here,
        •  gcc refers to the C compiler.
        • -Wall,-Werror,-W used to display the errors which may occur. 
        • helloworld.c is the C program.
        • -o helloworld implies that the exe output will be created under the name helloworld.
    • Press Enter.
    • Run the program using the command,
        • ./helloworld
    • Press Enter.

  • Compiling C++ program
    • To compile the C program type the following command,
      • g++ -Wall -Werror -W helloworld.cpp -o helloworldcpp
    • Here,
      •  g++ refers to the C++ compiler.
      • -Wall,-Werror,-W used to display the errors which may occur. 
      • helloworld.cpp is the C++ program.
      • -o helloworldcpp implies that the exe output will be created under the name helloworldcpp.
    • Press Enter.
    • Run the program using the command,
      • ./helloworldcpp
    • Press Enter.

   So, with the help of these simple steps programmers can compile and execute their programs right from the terminal without any trouble.
 

 






How to change your Ubuntu hostname from terminal ?

    When users install Ubuntu on their system they would want to change the system name/hostname whenever they feel so. Linux users are fond of terminal with which they accomplish any task they prefer which may be from copying a file to installing a software. So, in this article I would show you a way in which you can change the hostname from terminal.

Step 1:
    • Open terminal application which is available in the dash-home from your Ubuntu Unity toolbar.

      

Step 2:
    • Once you have opened terminal, to change the hostname we have to edit the hostname file available in /etc/hostname. This can be done with the following command,
        • sudo gedit /etc/hostname

    • Here gedit denotes your default text editor and so if you use someother text editor specify that instead of gedit.
    • Press Enter.
    • After you press enter you will be prompted to type your administrator password. Type the password and press Enter.
    • The hostname file opens in your default text editor (in this case gedit).
       

Step 3:
    • Now, just enter the desired hostname(in this case vms20591) you need, save the file and close the editor.

    • Restart your system.
    • To verify if you system name has been changed check your terminal.
    •  In this example, the hostname has been changed from aldo to vms20591.
     So, with the help of just one command from your terminal you can change/edit your hostname/system name whenever you need.