Problem : To open a .chm file in linux ( ubuntu).
To open a .chm file in linux, you can use the package xchm.
To install xchm run the command
sudo apt-get install xchm
or open the synaptic package manager, and search for xchm.
Then right click mark for installation-> apply->apply.
Once this is done, you will be able to see the xchm in
Applications-->office-->xCHM.
Cick on the xCHM, it will open the xCHM apllication.
Click on "open" on the top and then browse to the location where you have kept your .chm file, select it and click on open.
You .chm file should open now.
Search
Scripting -1 The Shell
Aim: To introduce the reader to the linux shell.
A Shell is nothing but an command interpreter that interprets commands entered by a user and sends it to the operating system.
The history of shell dates back to the initial days of Unix, when the shell was introduced.
Today there are various shells that are in use, some of the most popular being
Bourne shell: The very first version of shell introduced in 1970s as a part of the seventh edition Unix released by Bell labs. The name Bourne is derived from the creator "Steven Bourne".
This shell is a part of every distro even today. It has very basic capabilities as compared to the various other shells used today, but almost all the shells still use the similar syntax as the Bourne shell.
csh-- C shell : This shell is named as C shell because of the similarity with the syntax of C language. This became the default shell of the BSD version of Linux and was very popular because of the advanced fetures that it provided as compared to the Bourne shell.
Ksh-- Korn Shell: The popularity of the C shell was endangering the usage of the AT&T Unix and as as result AT&T came with their own version of shell, designed by David Korn and named it as the Korn shell. The main advantage of the korn shell was that even though it had almost all the advanced features that the c shell had to offer, it was backward compatible with the Bourne shell. That is the scripts written for the Bourne shell could also be executed in the Korn shell.
This war between shells was obviously not very favorable for the users. Because any script that was compatible with the C shell would not run on the korn shell and Vice Versa.
As a result the Bourne Again shell was created, which had the features of both c shell,korn shell, and was also back ward compatible with the Bourne shell and above all it was freely available.
Bourne Again shell(bash) has become one of the most popular shells today. Almost every Linux Distro in the market comes default with the bash shell. Though the others shells are also available for use.
The official POSIX standard shell is the Korn shell.
To find out what is the shell being used by your system run the following command
echo $SHELL.
The environment variable SHELL holds the value of the shell being used.
You can change the default shell that is used by your Linux distro using the command chsh .
Syntax: chsh username "path to shell"
for e.g.: chsh user1 /bin/ksh
Other than these there are other shells too, like the zshell, TCshell and a few graphical shells which are rarely used.
A Shell is nothing but an command interpreter that interprets commands entered by a user and sends it to the operating system.
The history of shell dates back to the initial days of Unix, when the shell was introduced.
Today there are various shells that are in use, some of the most popular being
Bourne shell: The very first version of shell introduced in 1970s as a part of the seventh edition Unix released by Bell labs. The name Bourne is derived from the creator "Steven Bourne".
This shell is a part of every distro even today. It has very basic capabilities as compared to the various other shells used today, but almost all the shells still use the similar syntax as the Bourne shell.
csh-- C shell : This shell is named as C shell because of the similarity with the syntax of C language. This became the default shell of the BSD version of Linux and was very popular because of the advanced fetures that it provided as compared to the Bourne shell.
Ksh-- Korn Shell: The popularity of the C shell was endangering the usage of the AT&T Unix and as as result AT&T came with their own version of shell, designed by David Korn and named it as the Korn shell. The main advantage of the korn shell was that even though it had almost all the advanced features that the c shell had to offer, it was backward compatible with the Bourne shell. That is the scripts written for the Bourne shell could also be executed in the Korn shell.
This war between shells was obviously not very favorable for the users. Because any script that was compatible with the C shell would not run on the korn shell and Vice Versa.
As a result the Bourne Again shell was created, which had the features of both c shell,korn shell, and was also back ward compatible with the Bourne shell and above all it was freely available.
Bourne Again shell(bash) has become one of the most popular shells today. Almost every Linux Distro in the market comes default with the bash shell. Though the others shells are also available for use.
The official POSIX standard shell is the Korn shell.
To find out what is the shell being used by your system run the following command
echo $SHELL.
The environment variable SHELL holds the value of the shell being used.
You can change the default shell that is used by your Linux distro using the command chsh .
Syntax: chsh username "path to shell"
for e.g.: chsh user1 /bin/ksh
Other than these there are other shells too, like the zshell, TCshell and a few graphical shells which are rarely used.
Right click to launch terminal in ubuntu gneome
Aim: To add the open terminal option in the right click menu, and launch terminal from the same location where we are presently in the GUI.
If you want to open a terminal in the same folder where you are present in the GUI then you will have to use nautilus-open-terminal.
For eg: In the GUI you are in the folder /home/user1/office/
you want to open a terminal that opens such that it directly opens with its "pwd" as /home/user1/office.
Then you would need to install the nautilus-open-terminal package.
To install the package open the terminal and type
sudo nautilus-open-terminal.
Reboot your system, and voila... right click in any folder you are working in.
You will see an option "open terminal", click on it and a terminal will pop up, working in the same folder.
If you want to open a terminal in the same folder where you are present in the GUI then you will have to use nautilus-open-terminal.
For eg: In the GUI you are in the folder /home/user1/office/
you want to open a terminal that opens such that it directly opens with its "pwd" as /home/user1/office.
Then you would need to install the nautilus-open-terminal package.
To install the package open the terminal and type
sudo nautilus-open-terminal.
Reboot your system, and voila... right click in any folder you are working in.
You will see an option "open terminal", click on it and a terminal will pop up, working in the same folder.
Cross Compiling linux for ARM
Cross compiling Linux 2.6.34 for arm (Innovate solutions ARM926 Kit).
1. Download the kernel from http://kernel.org/
2. untar the file to any location of your preference
3. Download and install the latest cross compiling tool chain from http://www.codesourcery.com/sgpp/lite/arm
4. Get the path to the directory where the "gcc" cross compiler is present.
For Eg : Codesourcery by default installs it in
/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
5. Go to the directory where you have untarred the kernel that you want to compile.
6. run the command
make defconfig
7. This should generate a default ".config" file in your present directory, taking the configuration from your currently installed system.
8. To compile the kernel for arm, run make as follows
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-
gnueabi-
Note that gcc has been omitted from the path to the cross compiler, that is because "gcc" would already have been set as the default compiler for the host.
9. This will generate a zImage in the arch/arm/boot folder.
10. In case you are using a U boot loader then you would need a uImage, to generate a uImage just add uImage when you run the make command i.e.
1. Download the kernel from http://kernel.org/
2. untar the file to any location of your preference
3. Download and install the latest cross compiling tool chain from http://www.codesourcery.com/sgpp/lite/arm
4. Get the path to the directory where the "gcc" cross compiler is present.
For Eg : Codesourcery by default installs it in
/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc
5. Go to the directory where you have untarred the kernel that you want to compile.
6. run the command
make defconfig
7. This should generate a default ".config" file in your present directory, taking the configuration from your currently installed system.
8. To compile the kernel for arm, run make as follows
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-
gnueabi-
Note that gcc has been omitted from the path to the cross compiler, that is because "gcc" would already have been set as the default compiler for the host.
9. This will generate a zImage in the arch/arm/boot folder.
10. In case you are using a U boot loader then you would need a uImage, to generate a uImage just add uImage when you run the make command i.e.
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-
gnueabi- uImage.
This will generate a uImage for ARM, in arch/arm/boot.
10. To make sure you have compiled the files for ARM, you can check any of the object files in the drivers folder with command "file", for eg:
file drivers/usb/storage/usb.o
you should see output similar to the following.
drivers/usb/storage/usb.o: ELF 32bit LSB Relocatable,ARM,Version 1,not stripped
11. A uImage generated using the config file generated from make defconfig, would genreally be around 10MB. This is quite a huge file in case you are planning to port it on to an ARM board.
12. To reduce the size of the uImage you can run "make menuconfig" and disable all the drivers that you feel are not needed. There will be a kernel and a .config file that would have come with your kit, you can refer to that to decide what config options are required.
In case make menuconfig is not working, the open the .config file in any text editor and comment out the config options that you don't want to compile and then run the make command as shown above again.
13. In case you are adding your own driver module, than make sure to include it in the config file and the respective makefiles.
Problem faced during the cross compilation of 2.6.34
You might get an error saying wrong value for __bad__udelay or some thing similar.
This is because of http://git390.marist.edu/cgi-bin/gitweb.cgi?p=linux-2.6.git;a=commit;h=cc05368c52fed7d9efa0f56c5270e95bb569713e
Workaround:
In the files mentioned below, modify the value of all the udelay() greater than 200 to a value less than 2000. 1500 worked for me.
atp870u.c in drivers/scsi
nsp32.c in drivers/scsi
sungem.c in drivers/net/
nsp32.c in drivers/scsi
sungem.c in drivers/net/
Missing battery and network icons from the panel
Problem: The icons of batters(if you are using a laptop) and the network icons have disappeared from the panel in ubuntu. ( This is for Gnome based systems).
Solution:
1. Right click on the panel
2. Select add to panel
3. Search for item name Notification area and click on add.
The Icons should come back on the panel.
Solution:
1. Right click on the panel
2. Select add to panel
3. Search for item name Notification area and click on add.
The Icons should come back on the panel.
Invalid ABI Option abi=aapcs-linux
In case you are trying to cross compile linux for arm and your make gives you the error
Invalid ABI Option abi=aapcs-linux
This is because you have a old cross compilation tool chain.
Solutions:
1. change abi=aapcs-linux to just abi=aapcs in the makefile in arch/arm
or better
2. Get a newer version of the tool chain, for eg from http://www.codesourcery.com/
Invalid ABI Option abi=aapcs-linux
This is because you have a old cross compilation tool chain.
Solutions:
1. change abi=aapcs-linux to just abi=aapcs in the makefile in arch/arm
or better
2. Get a newer version of the tool chain, for eg from http://www.codesourcery.com/
Crossword on Linux Commands
1 | 2 | |||
3 | ||||
4 | ||||
5 | ||||
6 | ||||
7 |
Across | Down | ||
3 | Smallest first | 1 | What files am i filled with |
4 | Oh not the one used to carry water | 2 | Cntrl + f |
6 | common to snail and linus | 4 | Change the security |
7 | Common fruit in the arabs | 5 | What kind of a file is it ? |
Mount of filesystem failed
Problem:
Mount of filesystem failed.
A maintenance shell will now be started.
CONTROL-D will terminate this shell and retry.
Solution:
1. type the root password
2. Enter the command "fsck"
3. Reboot.
The step 2 might have to be repeated a few times, but this should get you out of the problem.
Mount of filesystem failed.
A maintenance shell will now be started.
CONTROL-D will terminate this shell and retry.
Solution:
1. type the root password
2. Enter the command "fsck"
3. Reboot.
The step 2 might have to be repeated a few times, but this should get you out of the problem.
Using "rdtsc" with gcc
Using the "rdtsc"
rdtsc is a time stamp counter that returns the number of clock ticks from the time the system was last reset.
The rdtsc instruction returns the time stamp counter in EDX:EAX.
This instruction is useful when you want to measure the performance of a certain code or application in clock ticks, or compare the performance of two programs, which are too small to be counted in seconds.
Here is a sample C code that shows how you can make use of this instruction.
rdtsc is a time stamp counter that returns the number of clock ticks from the time the system was last reset.
The rdtsc instruction returns the time stamp counter in EDX:EAX.
This instruction is useful when you want to measure the performance of a certain code or application in clock ticks, or compare the performance of two programs, which are too small to be counted in seconds.
Here is a sample C code that shows how you can make use of this instruction.
Modifying GRUB
If you have a dual boot in your system and you might want to modify the grub menu for some of these reasons
1. Change the default boot order
2. Make the grub menu wait for a shorter or longer duration
3.Hide the grub menu completely
etc.
If you are using grub legacy and not grub2 you can look at how to do any of the following.
In the grub legacy, all the grub related settings are in the file "grub.conf" or "menu.lst" which in turn is placed in the folder /boot/grub.
To modify this file you need to be the superuser or "root".
1. To change the OS that boots by default open the file menu.lst/grub.conf
Look for the following set of lines
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0
the last line "default 0" specifies as to which option of the grub menu is going to boot by default. The numbering starts from "0". Hence the first option in the grub menu would be numbered "0" the second would be numbered "1" and so on.
To change the default OS to any of your choice, just change the number in front of the "default " to which ever number that points to your desired OS.
The number in front of "timeout" in the last line specifies the number of seconds the grub menu waits for the user to make a choice before it starts booting the default OS. You can change it to make the grub wait longer or shorter.
1. Change the default boot order
2. Make the grub menu wait for a shorter or longer duration
3.Hide the grub menu completely
etc.
If you are using grub legacy and not grub2 you can look at how to do any of the following.
In the grub legacy, all the grub related settings are in the file "grub.conf" or "menu.lst" which in turn is placed in the folder /boot/grub.
To modify this file you need to be the superuser or "root".
1. To change the OS that boots by default open the file menu.lst/grub.conf
Look for the following set of lines
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0
To change the default OS to any of your choice, just change the number in front of the "default " to which ever number that points to your desired OS.
2. Make the grub menu wait for a shorter or longer duration
Look for the following lines in the grub.conf/menu.lst file.
## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 10
The number in front of "timeout" in the last line specifies the number of seconds the grub menu waits for the user to make a choice before it starts booting the default OS. You can change it to make the grub wait longer or shorter.
3.Hide the grub menu completely
To not display the grub menu at all, unless you press the "esc" key look for the following lines in the grub.conf/menu.lst file.
## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu
Remove the "#" before the last line ,and from the next boot the grub menu will not be visible.
## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu
compiling c++ on ubuntu
If you want to compile c++ programs in linux you would need g++ installed on your system.
In ubuntu all you have to do is go to synaptic package manager, choose g++ (right click and mark for isntallataion) and apply.
then to compile the c++ programs type "g++ program_name.cpp" on the terminal.
In ubuntu all you have to do is go to synaptic package manager, choose g++ (right click and mark for isntallataion) and apply.
then to compile the c++ programs type "g++ program_name.cpp" on the terminal.
Processes
Aim: To introduce how various processes work in linux.
A process can be defined as any program in execution, the program in turn could be an application,a shell script or the shell it self. All of them are internally processes that are being handled by the kernel.
Each process that is being executed is recognized by a number called as the Processor Identification number of PID. The kernel or the operating system recognizes the processes by this number, which is unique for every process.
Every process can launch more processes, The processes that launches or more technically said "forks" a process is the parent of the new process and the new process is the child. The child in turn can launch more processes and so on.
To see a list of all the processes running in your system you can make use of the command "ps"
The "ps" command by itself lists very few active processes. To see and extensive list of all the processes being run in the system , we can use one of the following options
ps -e
ps -ef
ps -eF
ps -ely
All the above options give a dtailed out put of all the processes being run in the system. For eg:
ps -ef gives the information in the following format
UserID, ProcessID, ParentProcess ID, C(more later) , Start time, tty(terminal) , last access time, command that started the process
The other variations give a little more of littles less information about the processes.
The processes in linux also follow a tree structure just like the file system. Every process starts or spwans out of a previous process. The first process that starts execution in linux is the "init" function that does the forking or spawning of other functions.
To have look how one process is spawned out of other, run the command pstree.
It should give you an output some thing similar to the one shown below.
init─┬─NetworkManager─┬─dhclient
│ └─{NetworkManager}
├─acpid
├─apache2─┬─apache2
│ └─2*[apache2───26*[{apache2}]]
├─atd
To get to know the process id of a specific process we can use a combination of ps and grep as follows
" ps -ef | grep "process name" | cut -d' ' -f5 "
"cut" is a command that can be used to output only specific parts of the input file. In the above example we have "piped" the output of the "ps -ef" command to "grep" which searches for the specific process by name , the output of that is in turn piped to the "cut" command.
The output after the grep and before the cut will have all the 7 fields with respect to the specific process. Each filed is separated by a few spaces. The process id which is the second filed is separated by the user id by 5 spaces. Hence we tell the "cut " command to use "space" are the delimiter by giving the -d' ' as the option. and then ask it to print the 5th field after the 5 spaces which is the process id field. The output of the command will be only the process id corresponding to the process.
for eg:
ps -ef | grep firefox | cut -d' ' -f5
the above commands might produce
3903
3916
3920
6658
some thing like this.... but that is dependent on your system and will vary widely.
If you are aware of "awk" then you can pick up the process id in the following way too
ps -ef | grep firefox | awk {'print $2'}
Kill a process:
To kill a process we can use the command "kill".
syntax: kill [signal] processid
Generally to kill a process we would use the signal "9".
For eg to kill a process with pid 3920
kill -9 3920
You can get the process id of a process by using the command "ps -ef".
Kill has a lot more options, which you can explore once you get comfortable using Linux and the command line.
A process can be defined as any program in execution, the program in turn could be an application,a shell script or the shell it self. All of them are internally processes that are being handled by the kernel.
Each process that is being executed is recognized by a number called as the Processor Identification number of PID. The kernel or the operating system recognizes the processes by this number, which is unique for every process.
Every process can launch more processes, The processes that launches or more technically said "forks" a process is the parent of the new process and the new process is the child. The child in turn can launch more processes and so on.
To see a list of all the processes running in your system you can make use of the command "ps"
The "ps" command by itself lists very few active processes. To see and extensive list of all the processes being run in the system , we can use one of the following options
ps -e
ps -ef
ps -eF
ps -ely
All the above options give a dtailed out put of all the processes being run in the system. For eg:
ps -ef gives the information in the following format
UserID, ProcessID, ParentProcess ID, C(more later) , Start time, tty(terminal) , last access time, command that started the process
The other variations give a little more of littles less information about the processes.
The processes in linux also follow a tree structure just like the file system. Every process starts or spwans out of a previous process. The first process that starts execution in linux is the "init" function that does the forking or spawning of other functions.
To have look how one process is spawned out of other, run the command pstree.
It should give you an output some thing similar to the one shown below.
init─┬─NetworkManager─┬─dhclient
│ └─{NetworkManager}
├─acpid
├─apache2─┬─apache2
│ └─2*[apache2───26*[{apache2}]]
├─atd
etc....
To get to know the process id of a specific process we can use a combination of ps and grep as follows
" ps -ef | grep "process name" | cut -d' ' -f5 "
"cut" is a command that can be used to output only specific parts of the input file. In the above example we have "piped" the output of the "ps -ef" command to "grep" which searches for the specific process by name , the output of that is in turn piped to the "cut" command.
The output after the grep and before the cut will have all the 7 fields with respect to the specific process. Each filed is separated by a few spaces. The process id which is the second filed is separated by the user id by 5 spaces. Hence we tell the "cut " command to use "space" are the delimiter by giving the -d' ' as the option. and then ask it to print the 5th field after the 5 spaces which is the process id field. The output of the command will be only the process id corresponding to the process.
for eg:
ps -ef | grep firefox | cut -d' ' -f5
the above commands might produce
3903
3916
3920
6658
some thing like this.... but that is dependent on your system and will vary widely.
If you are aware of "awk" then you can pick up the process id in the following way too
ps -ef | grep firefox | awk {'print $2'}
Kill a process:
To kill a process we can use the command "kill".
syntax: kill [signal] processid
Generally to kill a process we would use the signal "9".
For eg to kill a process with pid 3920
kill -9 3920
You can get the process id of a process by using the command "ps -ef".
Kill has a lot more options, which you can explore once you get comfortable using Linux and the command line.
To make sudo not ask for password
Tired of entering password in ubuntu every time you run some thing with "sudo". Try
this work around.
To make the sudo not ask for password every time
1.sudo visudo
2.add the following at the end
"username" ALL=NOPASSWD: ALL
OR
To make a shell work as a root shell use
sudo -i
this work around.
To make the sudo not ask for password every time
1.sudo visudo
2.add the following at the end
"username" ALL=NOPASSWD: ALL
OR
To make a shell work as a root shell use
sudo -i
Welcome to Linux World
The world of Linux is fascinating, enjoyable and more completely free. This blog aims and introducing any one who is interested to World of Linux. Hope you have fun :-)
Learn Linux
Installation
Learn Linux-1 Overview
Learn Linux-2 Using the Terminal
Learn Linux-3 The Filesystem
Learn Linux-4 Basic Commands
Learn Linux-5 Basic Commands with Options
Learn Linux-6 vi Editor Basics
Learn Linux-7 More commands
Learn Linux-8 A Few More Commands
Forgot Root Password
Problem : Forgot Linux root password.
I think this must be a common problem to a lot of users, forgetting the root password of their system or in the case of New ubuntu like systems that do not have a root log in, if you forget the password for the only user in your system then you are stuck with no way of logging in. Well there is simple work around for situations like this.
Follow the following steps to reset your root password. [Please see below for ubuntu systems]
1. While your system boots go the GRUB menu by pressing "esc".
2. Highlight the OS you want to boot using the arrow keys.
3. Press "e"
4. You will see three options ( generally), move to the line that starts with "kernel".
5. press "e" again
6. You will see a line of text, move to the end of it.
7. Add "single" or "1" to the end of the line.
8. Hit Enter and press "b".
Your system should boot into a text mode, with a shell prompt.
typer "passwd" and hit enter.
You will be prompted for a new password. enter the password , you will be asked for confirmation enter the password again.
enter the command "reboot" and hit enter.
The system should boot back to your normal log in screen, you can use the new password that you just set for the root log in.
In case of Ubuntu systems this method does not work very well so there is slightly different way of making it work.
in step 7: instead of adding "1" add the text "/dev/sda=rw" assuming sda is the partition on which you have your Linux installed.
Hope you are able to log into your system again :-)
I think this must be a common problem to a lot of users, forgetting the root password of their system or in the case of New ubuntu like systems that do not have a root log in, if you forget the password for the only user in your system then you are stuck with no way of logging in. Well there is simple work around for situations like this.
Follow the following steps to reset your root password. [Please see below for ubuntu systems]
1. While your system boots go the GRUB menu by pressing "esc".
2. Highlight the OS you want to boot using the arrow keys.
3. Press "e"
4. You will see three options ( generally), move to the line that starts with "kernel".
5. press "e" again
6. You will see a line of text, move to the end of it.
7. Add "single" or "1" to the end of the line.
8. Hit Enter and press "b".
Your system should boot into a text mode, with a shell prompt.
typer "passwd" and hit enter.
You will be prompted for a new password. enter the password , you will be asked for confirmation enter the password again.
enter the command "reboot" and hit enter.
The system should boot back to your normal log in screen, you can use the new password that you just set for the root log in.
In case of Ubuntu systems this method does not work very well so there is slightly different way of making it work.
in step 7: instead of adding "1" add the text "/dev/sda=rw" assuming sda is the partition on which you have your Linux installed.
Hope you are able to log into your system again :-)
Subscribe to:
Posts (Atom)