Thursday, November 4, 2010

Reset GNOME to default

rm -rf .gnome .gnome2 .gconf .gconfd .metacity
This will reset the GNOME desktop to its default settings. If you have done a lot of changes and tweaks to your desktop and want to get it to its default setting, then you can delete these folders.
On restarting the system, the default settings will be restored.
To restore the panels to its default settings :
administrator@ubuntu:~$ gconftool --recursive-unset /apps/panel
administrator@ubuntu:~$ rm -rf ~/.gconf/ apps/panel
administrator@ubuntu:~$ pkill gnome-panel

Automatically login to GNOME and KDE

If you want to login without entering your password at boot up, you can do the following changes to your system.
For Ubuntu 10.04 (Lucid Lynx)
1. Load the Gnome Administration utility by clicking on System -> Administration -> Login Screen Settings
2. Unlock the window by hitting the unlock button (you will be asked for the administrator password)
3. Enable the checkbox for Log in as <> automatically (Select your User Name from the drop-down list of users).
1. K–>System Setting-> Login Manager.
2. Click on the Administrative Mode.
3. Enter your password when prompted.
4. Click on the Convenience tab and check the Enable Autologin checkbox option.
5. Select the user who would be logged in automatically(if there are multiple users).
Through command-line, it can be done by editing the kdmrc file and making the following changes /etc/kde4/kdm/kdmrc:

Switching between KDE and GNOME

If you’ve installed UBUNTU on your system, then the default desktop environment is GNOME. You can install KDE in UBUNTU through the following steps:
Open Ubuntu Software Centre.
Type Kubuntu and install Kubuntu Plasma Desktop system.Enter your password when prompted.
After the installation process is complete, log out and log in again. This time select KDE from the bottom of the log in screen.
However, you can only log out of KDE desktop environment back to the login screen. You will not have options like SHUTDOWN and RESTART in your KDE environment. This is because, although you login to KDE, the default display manager is still GDM (GNOME Display Manager).
If you want the (SHUTDOWN, RESTART etc.) options to appear in your KDE desktop environment, then you need to change the display manager to KDM (KDE Display Manager).
To do this, open up a terminal and type :
sudo dpkg-reconfigure kdm
and follow the fairly intuitive steps.
If you log out and log in again, the options should be enabled. But if you login to GNOME then those options will be disabled for the same reasons as above.
To change the display manager to gdm, simply type
sudo dpkg-reconfigure gdm.

A C program in Ubuntu

The GNU C compiler(gcc).
This is the GNU C compiler, a fairly portable optimizing compiler for C.
This is a dependency package providing the default GNU C compiler.
The first thing to do is to check if gcc is installed in your system.
This can be done by opening a terminal
and typing:
which gcc
This gives the location where it is installed.
Usually, the output is :
If gcc is not installed type :
sudo apt-get install build-essential
To check the version type
gcc -v
The output is :
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.
Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --
libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
The next part is to compile and run a C program.
Type the program in any editor
and save it as hello.c
Sample code is given below:
#include "stdio.h"
int main()
printf("Hello World\n");
printf("C in Linux\n");
return 0;
In your terminal, go to the location where you have saved your program.
cd Desktop, if it has been saved in the desktop.
Then type
gcc hello.c -o hello
followed by
You should get the output on your screen.
If u get any permission error then,
chmod +x hello.c
Digging a little deeper
I wrote a code and saved it as test.c
#include "stdio.h"
void main()
for (int i=0;i<10 ;i++)
When I tried to compile using
gcc test.c -o test
it gave an error:
test.c: In function ‘main’:
test.c:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
test.c:5: note: use option -std=c99 or -std=gnu99 to compile your code
It turns out that declaring 'i' inside the for loop is illegal in C90 mode, which
is the default mode. To compile it you either need to declare 'i' outside the for loop
int i
this works fine.
Or to use the c99 mode, where it is legal to declare variables inside the for loop.
gcc test.c -std=gnu99 -o test
gcc test.c -std=c99 -o test

My first Makefile

A starter’s guide to a makefile
This post is just the tip of the iceberg called “make” and its capabilities. It does not even scratch the surface but is meant as a tutorial to write your first makefile.
The following Makefile is used to make it easier to type commands to compile and run a program.
for eg. to compile arg.c
we use
gcc -o arg arg.c
Instead of this we can create a Makefile as:
(tab) gcc -o arg arg.c
and save it as Makefile in the directory where our program arg.c is saved.
Now we can type:
$ make 1
to compile the program
to run the program.
anand@anand-desktop:~/Desktop$ make 1
Makefile:5: *** missing separator. Stop.
This error comes if we have missed the tab in the newline before gcc -o arg arg.c
(Tab) gcc -o arg arg.c
Make sure you press the tab key and not write (Tab) .
If we can compile a program, why not run it too?
edit the Makefile and add the following:
(tab) ./arg
$make 1
$make 2
in your terminal is same as
gcc -o arg arg.c
followed by