You are on page 1of 32

Rmmod- unloads modules, ex: rmmmod ftape

Depmod- creates a dependency file,


“modules.dep”, later used by modprobe to
automatically load>>>

Modules are loaded from startup script files


using “modprobe” to handle loadable modules
automatically.
- Modprobe –I |more – list all the modules
available for your kernel
- Rmmod module_name – remove a module
from the kernel
It should be in the file /vmlinuz, or/ vmlinux.
In some installations,/vmlinuz is a soft link to
the actual kernel/
- On redhat 6.1 it is in “/boot/vmlinuz”. To
find the kernel being used look in
’’/ets/lilo.conf” .
Type “uname -a” to see the kernel version.

Compiling the kernel


Compiling custom kernel has it’s own
advantages and disadvantages. However, new
linux user /admin find it difficult to compile
linux kernel. Compiling kernel needs to
understand few things and then just type …

Ooriing uildliin sistemiin kernel huuchin bna


gej uzvel herhen shinechleh tuhai
Get latest linux kernel code
Extract the file
Configure kernel
Compile kernel
Install kernel

Preparation
 Sudo su-
 Apt-get install fakeroot build –essential
 Apt-get install crash kexec- tools
makedumpfile kernel –wedge
 Apt-get build-dep linux
 Apt-get install git core libncurses5
libncurses5-dev
 Apt-get install libelf-dev libdw-dev
asciidoc binutils-dev
 Exit

Getting the kernel source


Cd/d1/development/kernel/maverick (self
created directory)
Git clone
git://kernel.ubuntu.com/ubuntu/ubuntu-
maverick.git source
Cd source

Creating branch
To see all the available kernels available type
the following command:
-git tag-l| sort –V
Git checkout ubuntu-2.6.35.-23.37 –b core2
-this will create a branch called core2.

Creating new config


Cp
debian.master/comfig/i386/config.flavour.gene
ric
debian.master/config/i386/config.flavour.core2
fakeroot debian/rules clean debian/rules
updateconfigs

To make changes to the configuration file we


need to edit the configuration file. The kernel
develops have created a script to edit kernel
configuration which has to be called through
the debian/rules makefile, unfortunately you
will have to go through all the flavors for this
script to work properly

*debian/rules editconfigs. The script will ask


you if you want to edit particular configuration.
You shouldn’t make changes any of the
configurations until you see core2 to
configuration

*do you want edit config:


I386/config.flavour.core2? [Y/N]
*make your changes save the configuration and
then keep going until the scripts ends.

*when you’re done make a backup of the


config flavor file
*cp
debian.master/config/i386/config.flavour.core2
../.
*git reset –hardgit clean –xdf

Getting ready for compilation


Creating new flavor
*is debian.master/abicp
debian.master/abi/2.6.35-23.36/i386/generic
debian.master/abi/2.6.35-23.36/core2cp
debian.master/abi/2.6.35-
23.36/i386/generic.modules
debian.master/abi/2.6.35-
23.36/i386/core2.modules
*copy our flavoured configuration file back.
-
cp../config.flavour.core2debian.master/config/i
386

Edit some files:


*file:debian,master/etc/getabits
-search for the line:
* getail i386 generic generic-pae virtual
-change it in:
* getail i386 generic generic-pae virtual
core2

*file:debian.master/rules.d/i386.mk
--search for the line:
*flavours = generic generic-pae virtual
-change it in:
* flavours = generic generic-pae virtual
core2

Making compilation aware of own flavour


*cp debian.master/control.d/vars.generic
Debian.master/control.d/vars.core2

*you can edit the file and make it your own.


*arch=”i386amd64”supported=”core2”target=”
geared toward core2 desktop
systems.”desc=x86/x86_64”bootloader=”grub-
pc|grub……..

*our changes in the git repository.


*git add .git commit –a –m “core2
modifications”
*the text after –m is the message you add to
your commit
Compilation and installation
*After compiling and creating the packages we
are going to install the kernel
*To install the files
*cd ..sudo dpkg –I linux-headers-2.6.35-23-
core2_2.6.35-23.37_i386.deb linux –headers-
2.6.35-23_2.6.35-23.37_all.deb linux-image-
2.6.35-23-core2_2.6.35-23.37_i386.deb
File system
The unix operating system is built around the
concept of a filesystem which is used to store
all of the information that constitutes the long-
term stater of the system. This state includes…..

Items in unix file system in 4 groups


*ordinary files
*directories
*devices
*links

Ordinary files
Ordinary files can contain text, data or
program information. Files cannot contain
other files or directiories unlike other
operating systems, unix filenames are not
broken into a name part and an extension
part(although extensions are still frequently
used as a means to classify files). Instead they
can contain any keyboard character expect or
‘/’ and be up to 256 characters long(note
however that characters such as *.?,# and &
have special meaning in most shells and should
not therefore be used in filenames). Putting
spaces in filenames also makes them difficult to
manipulate – rather use the underscore”_”

Directories
*directories are containers or folders that hold
files and other directories.
Devices
*to provide applications with easy access to
hardware devices, unix allows them to be used
in much the same way as ordinary files. There
are 2 types of devices in unix- block oriented
devices which transfer data in blocks (e.g. hard
disk) and character –oriented devices that
transfer data on a byte-by-byte basis (e.g.
modems and dumb terminals)

Links
*a link is a pointer to another file. There are
two types of links – a hard link to a file is
indistinguishable from the itself. A soft link (or
symbolic link) provides an indirect pointer or
shortcut to a file. A soft link is implemented as
a directory file entry containing a pathname.
Unix-iin directory-iiin butets??????(sangiin
butets gsn ug)

Geriiin daalgawar
< Linux's directory structure - 1.2 >
As you may have noticed, Linux organizes its files differently from Windows. First the directory
structure may seem unlogical and strange and you have no idea where all the programs, icons,
config files, and others are. This tuXfile will take you to a guided tour through the Linux file
system. This is by no means a complete list of all the directories on Linux, but it shows you the
most interesting places in your file system.

Author: Nana Långstedt < nana.langstedt at gmail.com >


tuXfile created: 18 January 2002
Last modified: 22 September 2005

</>
The root directory. The starting point of your directory structure. This is where the Linux system
begins. Every other file and directory on your system is under the root directory. Usually the root
directory contains only subdirectories, so it's a bad idea to store single files directly under root.

Don't confuse the root directory with the root user account, root password (which obviously is
the root user's password) or root user's home directory.

< /boot >


As the name suggests, this is the place where Linux keeps information that it needs when booting
up. For example, this is where the Linux kernel is kept. If you list the contents of /boot, you'll
see a file called vmlinuz - that's the kernel.

< /etc >


The configuration files for the Linux system. Most of these files are text files and can be edited
by hand. Some interesting stuff in this directory:

/etc/inittab
A text file that describes what processes are started at system bootup and during normal
operation. For example, here you can determine if you want the X Window System to start
automatically at bootup, and configure what happens when a user presses Ctrl+Alt+Del.

/etc/fstab
This file contains descriptive information about the various file systems and their mount points,
like floppies, cdroms, and so on.

/etc/passwd
A file that contains various pieces of information for each user account. This is where the users
are defined.

< /bin, /usr/bin >


These two directories contain a lot of programs (binaries, hence the directory's name) for the
system. The /bin directory contains the most important programs that the system needs to
operate, such as the shells, ls, grep, and other essential things. /usr/bin in turn contains
applications for the system's users. However, in some cases it really doesn't make much
difference if you put the program in /bin or /usr/bin.

< /sbin, /usr/sbin >


Most system administration programs are stored in these directories. In many cases you must run
these programs as the root user.

< /usr >


This directory contains user applications and a variety of other things for them, like their source
codes, and pictures, docs, or config files they use. /usr is the largest directory on a Linux
system, and some people like to have it on a separate partition. Some interesting stuff in /usr:

/usr/doc
Documentation for the user apps, in many file formats.

/usr/share
Config files and graphics for many user apps.

/usr/src
Source code files for the system's software, including the Linux kernel.

/usr/include
Header files for the C compiler. The header files define structures and constants that are needed
for building most standard programs. A subdirectory under /usr/include contains headers for
the C++ compiler.

/usr/X11R6
The X Window System and things for it. The subdirectories under /usr/X11R6 may contain
some X binaries themselves, as well as documentation, header files, config files, icons, sounds,
and other things related to the graphical programs.

< /usr/local >


This is where you install apps and other files for use on the local machine. If your machine is a
part of a network, the /usr directory may physically be on another machine and can be shared by
many networked Linux workstations. On this kind of a network, the /usr/local directory
contains only stuff that is not supposed to be used on many machines and is intended for use at
the local machine only.

Most likely your machine isn't a part of a network like this, but it doesn't mean that /usr/local
is useless. If you find interesting apps that aren't officially a part of your distro, you should install
them in /usr/local. For example, if the app would normally go to /usr/bin but it isn't a part
of your distro, you should install it in /usr/local/bin instead. When you keep your own
programs away from the programs that are included in your distro, you'll avoid confusion and
keep things nice and clean.

< /lib >


The shared libraries for programs that are dynamically linked. The shared libraries are similar to
DLL's on Winblows.

< /home >


This is where users keep their personal files. Every user has their own directory under /home,
and usually it's the only place where normal users are allowed to write files. You can configure a
Linux system so that normal users can't even list the contents of other users' home directories.
This means that if your family members have their own user accounts on your Linux system,
they won't see all the w4r3z you keep in your home directory. ;-)

< /root >


The superuser's (root's) home directory. Don't confuse this with the root directory (/) of a Linux
system.

< /var >


This directory contains variable data that changes constantly when the system is running. Some
interesting subdirectories:

/var/log
A directory that contains system log files. They're updated when the system runs, and checking
them out can give you valuable info about the health of your system. If something in your system
suddenly goes wrong, the log files may contain some info about the situation.

/var/mail
Incoming and outgoing mail is stored in this directory.

/var/spool
This directory holds files that are queued for some process, like printing.

< /tmp >


Programs can write their temporary files here.

< /dev >


The devices that are available to a Linux system. Remember that in Linux, devices are treated
like files and you can read and write devices like they were files. For example, /dev/fd0 is your
first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on.
All the devices that a Linux kernel can understand are located under /dev, and that's why it
contains hundreds of entries.

< /mnt >


This directory is used for mount points. The different physical storage devices (like the hard disk
drives, floppies, CD-ROM's) must be attached to some directory in the file system tree before
they can be accessed. This attaching is called mounting, and the directory where the device is
attached is called the mount point.

The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy
drive, /mnt/cdrom for the CD-ROM, and so on. However, you're not forced to use the /mnt
directory for this purpose, you can use whatever directory you wish. Actually in some distros,
like Debian and SuSE, the default is to use /floppy and /cdrom as mount points instead of
directories under /mnt.

< /proc >


This is a special directory. Well, actually /proc is just a virtual directory, because it doesn't exist
at all! It contains some info about the kernel itself. There's a bunch of numbered entries that
correspond to all processes running on the system, and there are also named entries that permit
access to the current configuration of the system. Many of these entries can be viewed.
< /lost+found >
Here Linux keeps the files that it restores after a system crash or when a partition hasn't been
unmounted before a system shutdown. This way you can recover files that would otherwise have
been lost.

< What next? >


If you're completely new to Linux, you might want to learn some commands for moving around
in the file system, viewing text files, or manipulating the files. In that case I suggest you take a
look at the set of tuXfiles in the Introduction to the Linux command line section

2 sariin 17 lecture 3
Shell
*command line interpreter or shell
- provides a traditional user interface for the
Unix operating system and for unix-like systems
*users direct the operation of the computer
-entering command inputs as text
-creating text scripts of one or more such
commands.
*the most influential Unix are
-Bourne shell (bash, sh)
-C shell (csh)

*the bourne shell, sh, was written by stephen


bourne at AT&T as the original Unix command
line interpreter
*it introduced the basic features common to all
the unix shells
-piping
-documents
-command substitution
-variables
-control structures for condition- testing
-looping
-filename wildcarding

 The C shell, was written by Bill hoy while a


graduate student at university of
California, Berkeley
 Language, including the control structures
and the expression grammar, was
modeled on C.
 The C shell also introduced a large
number of features for interactive work
-the history and editing mechanisms
- aliases
-directory stacks
- tilde notation
-Cdpath
-job control and path hashing

*the most generic sense of the term shell


means any programs that users employ to
type commands.
* in the unix operating system users may
select which shell to use for interactive
sessions.
*the program is called a “shell” because it
hides the details of the underlying
operating system behind the shell’s
interface
*the shell manages the technical details
of the operating system kernel interface,
which is the lowest-level, or “inner-most”
component of an operating system.

*the C shell is command processor that’s


typically run in text window, allowing the
user to type commands which cause
actions
*today, csh on most machines is actually
tcsh, an improved version of csh.
-as a practical matter, tcsh is csh

*just about every programming language


in existence has the concept of variables-
a symbolic name for a chunk of memory
to which we can assign values, read and
manipulate its contents.
*the bourne shell is no exception, and this
section introduces this idea.

#!/bin/sh
MY_MESSAGE=”Hello world”
Echo $MY_MESSAGE
There must be no spaces around the
“=”sign

*the shell does not care about types if


variables; they may store strings, integers,
real numbers – anything you like
*in truth, these are all stored as strings,
but routines which expect a number can
threat them as such
$ x=”Hello”
$ y=’expr $x + 1`
expr: non-numeric argument
$
External program expr only expects
numbers

*there is no syntactic difference between:


-MY_MESSAGE=”Hello world”
-MY_SHORT_MESSAGE=hi
-MY_NUMBER=1
-MY_PI=3.142
-MY_OTHER_PI=”3.142”
-MY_MIXED=123abc

*#!/bin/sh
*echo What is your name?
*read MY_NAME
*echo “Hello $MY_NAME – hope you’re well.”

Using the shell-built in command read which


reads a line from standard input into the
variable supplied
*variables in the bourne shell do not have to be
declared, as they do in languages like C.
*if we try to read an undeclared variable, the
result is the empty string. You get no warnings
or errors. This can cause some subtle bugs
-MY_OBFUSCATED_VARIABLE=Hello
-echo $MY_OSFUCATED_VARIABLE

You will get nothing (as the second


OBFUSCATED is miss-spelled).
*there is a command called export which has a
fundamental effect in the scope of variables. In
order to really knows what’s going in with your
variables, you will need to understand……

*myvar2.sh
-#!/bin/sh
-echo “MYVAR is: $MYVAR”
-MYVAR=”hi there”
-echo “MYVAR is: $MYVAR”
Ajilluulj uzsen ni:
*$./myvar2.sh
*MYVAR is:
*MYVAR is: hi there
*MYVAR=hello
*$./MYVAR2.sh
*MYVAR is:
*MYVAR is: hi there
*$export MYVAR
*$./MYVAR2.sh
*MYVAR is: hello
*MYVARis: hi there

Now look at the line 3 of the scripts: this is


changing the value of MYVAR………
$ echo $MYVAR
Hello
$
*once the shell script exits, its environment is
destroyed. But MYVAR keeps its value of hello
within your interactive shell
In order to receive environment changes back
from the script, we must source the script – this
effectively runs the script within our own
interactive shell, instead of spawning another
shell to run it.
*we can source a script via the “.” Command
Neg huudas zalhuurlaa

*one other thing worth mentioning at this point


about variables, is no consider the following
shell script
#!/bin/sh
Echo “what is your name?”
Read USER_NAME
Echo “Hello $USER_NAME”
Echo “I will create you file called
$USER_NAME_FILE”
Touch $USER_NAME_file

For example, if you enter “csms” as your


USER_NAME, should the script create
csms_file? Actually, no. this will cause an error
unless there is a variable called.
USER_NAME_file. The shell does not know
where the variables end and the rest starts.
How can we define this? The answer is, that we
enclose the variable itself in curly brackets

#!/bin/sh
Echo “what is your name?”
Read USER_NAME
Echo “HELLO $USER_NAME”
Echo “I will create you a file called $
{USER_NAME}_FILE”
Touch “${USER_NAME}_FILE”

2 sariin 18nd bagsh oroi 8 hurtel ajilllana. Bie


daaltiin sedew gargana huuhduud irj songono
songohgui neg ni oorsnoo sedwee bodoj irj
bolno.

You might also like