Archive for the 'Ubuntu How To' Category

How to install apache, php, mysql and phpmyadmin in Ubuntu

Installing LAMP (Linux, Apache, Mysql, Php) in Ubuntu is pretty easy. Follow the following steps.

 

Open the terminal window and type:


sudo apt-get install apache2

This would install apache, which you could test by typing http://localhost/ in the browser. It will give you a successful message if it works.


sudo apt-get install php5 libapache2-mod-php5

This would install the latest stable version of php5 and apache mod. Now lets create a sample php file to see if it works:


sudo gedit /var/www/phpinfo.php

Once the new gedit window opens, type:


<?php phpinfo(); ?>

Save the file and restart apache for php to kick in:


sudo /etc/init.d/apache2 restart

Now go to http://localhost/phpinfo.php in the browser and it should show all the php settings.

We still need mysql, these commands will install it:


sudo apt-get install mysql-server

Next, we need apache mode, php5-mysql and phpmyadmin (if you want, it gets pretty handy):


sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Next, enable mysql in for php by editing php.ini file:


sudo gedit /etc/php5/apache2/php.ini

and uncomment the line


;extension=msql.so

by removing ‘;’ symbol in the beginning. Save the file and restart apache again:


sudo /etc/init.d/apache2 restart

Now navigate to http://localhost/phpmyadmin in your browser to start setting up the databases.

That’s it.

Using tar in Ubuntu

tar is pretty common command for archiving the files in Linux. It is pretty much the same across the distributions. You can type in the commands listed below in the Ubuntu terminal window.

Of course you can do:
man tar

and see all the flags and how to use, but hopefully this post will save you the effort.

To create an archive I usually do:
tar czf directory_name.tar.gz directory_name/

where “c” means create, “z” for gzip compression and “f” for file.

You can also do:
tar cjf directory_name.tar.bz2 directory_name/

for bzip compression or just:
tar cf directory_name.tar directory_name/

for a regular .tar

Basically, we specify the command with flags, type a file name that we want to create and pick a directory or file that we want to add to archive. These commands create an archive leaving the directory untouched.

 

Similarly, we extract these types of files using the “x” flag like this:
tar xf directory_name.tar
tar xzf directory_name.tar.gz
tar xjf directory_name.tar.bz2

That’s it.

How to use windows key to open Start menu in Ubuntu

The default short cut to open the “Start” panel in Ubuntu is “Alt+F1″, however you may wish to change it to the windows key. If you want to change it to something other than windows key, a combination of keys for instance, you would go to System > Preferences > Keyboard Shortcuts and click on “Show the panel’s main menu”, then, once selected just press they keys you want to use.

However, it doesn’t seem to do anything when you press the windows special key. In order to use it, you would have to open the terminal window or Run Application window (Alt+F2 by default) and execute this command:


gconftool-2 --set /apps/metacity/global_keybindings/panel_main_menu --type string "Super_L"

where Super L is the left “Super” key, which is left windows key.

How to open .rar files in Ubuntu

You need to install unrar to open .rar files in Ubuntu. It’s pretty easy, just open a terminal and type:


sudo apt-get install unrar

Now either double click the .rar file in GUI or right click -> Extract here. You can also type the following command in terminal:


unrar x /path_to_file/file_name.rar

How to update ati drivers on Ubuntu

Yes, you can go to hardware center and just pick the drivers ubuntu finds for you. I just tend to like manually installing Catalyst from ati. To do so, go to http://support.amd.com/us/gpudownload/Pages/index.aspx and download the drivers for your graphic card. Then save it, go to the folder in terminal and type:

sudo sh ati<tab>

<tab> meaning press the tab key to autocomplete the file name since I am not sure which version you got. :) Now you should have the latest version of Catalyst and drivers running on your system. Got to love ATI for Ubuntu. Worked perfectly for my radeon hd 4870.

Now if you want to configure it, open terminal window and type:

aticonfig

Good luck.

 

 

 

 

How to use apt-get

apt-get (apt stands for advanced packaging tool) is used to install the packages on your system.

To install a package use (in terminal):

sudo apt-get install <packagename>

To remove:

sudo apt-get remove <packagename>

where <packagename> is the name of the package you need to install.

Once I install the new Ubuntu, I usually do:

sudo apt-get update

and

sudo apt-get upgrade

which updates the local package list and upgrades to the latest versions from Ubuntu repositories.

You can also upgrade the entire distribution of your Ubuntu by typing:

sudo apt-get dist-upgrade

if you need more information, type

sudo apt-get help

 

Ubuntu 11.04 Screen Flickering During Installation

Tried to install Ubuntu 11.04 on my other computer today and ran into a ton of problems.  Once I inserted a CD and started to install, I couldn’t even get to the main menu. The purple screen just kept on flickering so much that I couldn’t see anything. I am still battling with it, but I got it to install. Right now I am trying to update the drivers for nvidia geforce 8200 which seem to be the problem.

Anyway,I was able to get the flickering down to the extent where I could at least see the installation screen and progress. It still flickered a little, but not as much. Here is what I had to do:

1) Press “Shift button” while it loads from the cd – it should give you configuration screen.

2) Press F6 for additional options and select “nomodeset” option.

3) Pick Install Ubuntu and you should be good to go.

As far as I can tell, your graphic card drivers are not supported if you run into this problem. Hope this will help you to install Ubuntu and get into the next phase of configuration. :)

How to find out Ubuntu system information

There are a few ways to figure out which version of Ubuntu and kernel you are using.

First, lets try GUI. Just go to System > About Ubuntu. It will shows you a lot of information, including the version you are using.

You can use the Terminal to find out more. Open it up and type:

uname -a

It will print all the information, -a stands for all. You can try other flags, such as -r, -o or -v.

uname -r

will show only the kernel information

uname -o

shows only your operating system, and

uname -v

displays the version of your kernel.

 

There are other ways to find the version of your linux. Type:

lsb_release -a

-a shows all information once again. You can alternatively use:

cat /etc/lsb-release

or try

cat /etc/issue

 

Don’t you just feel better now, knowing more about what exactly is under the hood of your PC case? :)

How to check disk space in Ubuntu

Ubuntu Disk Usage Analyzer

Ubuntu Disk Usage Analyzer

There are quite a few ways to check the hard drive disk space in Ubuntu. Lets look at the most popular ones.

1) Using GUI in Gnome – Just go to Applications > Accessories > Disk Usage Analyzer. Open it and it will show you used and free disk space. Easy, huh? Well, here is what else you can do – click filesystem scan and it will show you the usage of each individual directory and display it in a pretty graph.

2) Using command line. Now this is where it gets fun. There quite a few ways to check the disk space using the Terminal. One of the most popular is:

df

Now df by itself as you can see is confusing. Let’s try it with a flag:

df -h

A lot better, huh? -h flag stands for human readable format.

There are a lot of other tools you can add to make the command line look prettier and more user friendly. One such tool is discus (disc usage). Type:

sudo apt-get install discus

After installation you can just type in:

discus

and it will show you the stats in very friendly format. It is configurable, so check out

man discus

 

We can also use du command (disc usage) to show the size of the current directories. Type in Terminal:

du

and it will show you not too friendly output, try again using some flags

du -sh *

or

du -s -m *

-s stands for summary, -m to show it in megabytes, or you can once again use -h for human readable.

 

Check total free space in the system – use free CLI command. Open terminal and just type:

free

or

free -m

Once again, -m flag to show it in a nice format in Mb.

 

Do you need it to take one step further and check the CPU load and Memory Usage?

Use top command. Type in Terminal:

top

as you can see, it shows you the computer load and usage in real time. You can sort it while watching by pressing m key by memory, l by load, t by process time.

 

This is about it. You should now know how to check you system status, free and used space, cpu and memory usage.

It takes time to memorize these commands, but once you do it will be easy. Just remember that each command in Ubuntu is well documented and you can also do

man <command>

or try

<command> --help

to refresh the memory.

How to add a new user in Ubuntu

You create your first user during the initial Ubuntu installation. This user has special privileges, such as create new users and performing a lot of administrative tasks. There is also a root user account which is the main administrative account and has pretty much all the priveleges the user can get. Now we can get a lower level of user with just basic privileges.

Adding new user in Ubuntu is pretty easy. There are two ways – using GUI and Terminal CLI.

 

Lets take a look at GUI first (just in case, GUI stands for Graphical User Interface). Go to System > Administration and  pick Users and Groups menu option, it will prompt you for your main user password.

You are now in Users and Groups section. Now click “Add User”. Check out the “Advanced” options and “User Privileges”. Obviously, you would want to modify some privileges, such as “Connect to Internet”. Now press OK, get back to the previous screen that now lists the new user and press OK again. You have just created a new user and the new home folder for the user.

Try playing around in Users and Groups section. Create new groups and try placing users into different ones. This would allow users to share their files and folders, and you can set permissions on other folders in the system (will need to make another post on this) to use by certain groups.

 

Now lets create a user using a terminal window, open a Terminal and type:

sudo adduser newuser

or

sudo useradd -d /home/newuser -m newuser

where -d flag helps creating the home directory for the user and -m forces the directory creation. You can also specify the password right away with useradd function by using -p flag and typing password after it.

Also, you can just specify the password for the newuser as:

sudo passwd newuser

These commands are almost identical but adduser is a bit easier because it will prompt you for every piece of information after you press enter. Try it out.