|
Administration Tutors:
Tutor_01:
Recovering
Lost Data
If you
delect an
important directory, perhaps files you need, or even a partition, don't
cry yet, you can recover almost all lost files.
The Mini
Tutor
lets you know how-to recover lost files and directories into a
reiserfs partition, but you can also recover files from ext2 and ext3.
If you have a livecd or another distro installed, you can recover
almost all files without problems.
You are
going to
use reiserfsck command, a great tool for check and correct partitions.
First you have to boot using the livecd or your second installed
system. After finished the boot, umount your partition where lost files
were included, for example, /dev/hda5, umount /dev/hda5.
After
umount
your partition, type: reiserfsck --rebuild-tree -S -l
/root/recover..log /dev/hda5
The above command is going to rebuild your partition tree and remove
your lost data to lost+found directory, also is going to correct the
partition. The command send log messages to /root/recover.log using -l
option, and is going to scan whole partitions, -S option, instead of
only used space.
You have
to wait
a while for the command, but after it finishes, you probably have
almost all your files saved into /lost+found directory. Mount again
your partition, mount /dev/hda5, and go to lost+found directory, all
directories don't have anymore their name and they are identified by a
number, but inside all your files remain using original names, you have
to look inside to find files you want to recover.
Tutor_02:
Find The Package That Contains a File
This Mini
Tutor is based on an interesting tip from Dicas-L, a brazilian webpage
dedicated
to Linux tips, and it is about find which package contains a file.
If you
have a
.rpm package you can find by typing: rpm -qf filename
If you have a .deb package you can find by typing: dpkg -S
But
Slackware
and GoblinX use Slackware package (.tgz) and packages included are
listed in /var/log/packages.
You can
find
which package contains a file by using following method:
Open a console and go to /var/log/packages: cd /var/log/packages.
Type: grep -lir 'filename' *
The grep
command
uses a "-l" option to list names of files containing filename,
and "-i" to ignore case distinctions and "-r" to do a recursively
search.
The
command
lists files names which is equal to package name.
For
example:
grep -lir 'libdb' *
Result
HERE: aaa_elflibs-10.1.0-i486-1
xfce-4.2.2-i486-1

Tutor_03:
Clean Your Installed System
You must
from
time to time clean your system and remove not used traces left, like
files and occulted folders. There are a lot of abandoned traces in your
installed system and you
don't know.
First of
all you
have to control and clean all logs files. Logs files use to be saved at
/var/log folder and as it one receives some messages while you are
using the system, they are increasing their sizes while you are reading
this mini tutor. You can use logrotate to rotate those logs - we are
going to talk about it later - or remove and recreate mannually.
Another
files
you have to remove are removed packages description, every packages has
a description file inside /var/log/packages and some a script inside
/var/log/scripts, when you remove a package these files are not removed
only moved to /var/log/removed_packages and removed_scripts, and you
can remove those files.
About
packages,
they have a list of contents, so if you add some files after install a
package, these files are not removed when you remove the package, like
for example, you installed Mplayer and after the instalation you save a
new skin inside Mplayer folder, when you remove Mplayer package the
folder is going to not be removed because of the skin included after,
you have to remove mannually or list all files added into
/var/log/mplayer package description. If you want to have more
control, try rebuild the package and include the skin before install
it.
Inside
your home
folder there are some occulted directories (.) like .config, .kde,
every apllication when used for the first time will add a folder like
that, those folders are used to restore some settings and information
about the user and the applications itself, but when you remove the
application, the occulted folder remains, you have to remove those
folders mannually from time to time. In some case it's better don't
remove the occulted folder, it's the case if you plain to use again the
application in the future.
One occulted folder which increases size very fast it's .thumbnails,
that folder contains thumbnails images used by you and after a few week
it can be more than 1MB. Another occulted folder you have to look is
.mozilla, used by Mozilla,
Firefox... You have to clean caches, cookies and pages, and also you
have to mannualy remove your email folders because even when you delete
an email inside the trash it still have some traces left. If you are
using Mozilla, open a xterm and type 'du .mozilla', to see the size, I
just did it and I got 179MB of size.
If you
are not
going to use languages you can remove locale files and other files and
don't forget also to clean /tmp
from time to time. If you
have a
Nvidia card and you install a new driver version, you can remove Nvidia
files inside /var/lib/nvidia, like 101, 102, 103. Sometimes
when
you upgrade a package, doc folder from old one are not removed, you
have to control all doc folders.
Another
common
extensions is: (.~). The extension is used for backup of changed files,
when you edit a file and save again, a .~ is created and you can remove
it. There are
some
applications to help you to keep clean the system, but you have to do
it by yourself sometimes.

Tutor_04:
The Fstab
The Fstab
is a
configuration file (text) which contains information of all the
partitions and storage devices in your computer, and also information
about proc, devpts and more.
From
Fstab Man
Page:
"The file fstab contains descriptive information about the
various file systems. Fstab is only read by programs, and not
written; it is the duty of the system
administrator to properly create and maintain this
file. Each filesystem is described on a separate line; fields
on each line are separated by tabs or spaces. Lines
starting with '#' are comments. The order of records in
fstab is important because fsck, mount,
and umount sequentially iterate through fstab doing their thing."
It's
essential
understand the fstab and know how to edit it to fit your needs.
It contains information of where your partitions and storage devices
should be mounted and how, and as it is just a plain text
file, you can open and
edit
it with any text
editor you are familiar with. However, note that you must have the root
privileges before editing fstab. So, in order to edit the
file, you must either log in as root or use the su
command to become root. The fstab it's inside /etc folder.
An Fstab
example:
/dev/hda7
/
auto
defaults
1
1
/dev/hda1 /mnt/hda1
auto
defaults
0 0
/dev/hda5 /mnt/hda5
ext3
defaults
0 0
/dev/hdc /mnt/cdrom[hdc]
iso9660 noauto,owner,ro
0 0
/dev/sdb1
/mnt/sdb
vfat
auto,users,suid,dev,exec 0 0
/dev/fd0 /mnt/floppy
auto
noauto,user
0 0
devpts /dev/pts
devpts
gid=5,mode=620
0 0
proc
/proc
proc
defaults
0
0
As you can see at above example, the first field
indicates the block
special device or remote filesystem to be mounted, the second field
describes the mount point of the device, the third field indicates the
type of the filesystem, the fourth field describes mount options,
and the fifth field is used by dump and the sixty field is used by
fsck.
The first
field
describes the device as created by other scripts or by yourself, also
by mknod, those devices are in the case of GoblinX, configured at boot,
because as a livecd, GoblinX needs to rebuild your fstab each boot to
be able to boot from differents machines. Those devices describes your
hardware, your harddisk, cdroms, floppies, and more. The first line of
the above example tells we have a partition called hda7, it means that
7 is the numeric number of a partition inside our harddisk, and this
harddisk are connected to first IDE master (hda). You can notice one
cdrom connected to second IDE master (hdc), also an USB device found as
sdb1, and a floppy found as fd0.
The
second field
describes where the devices is going to be mounted. Linux systems mount
your partition and devices, it means to access your harddisk, for
example, you must mont it first, and the job of mounting is commanded
by fstab. The above example indicates all mount points, for example,
you partition hda1 are mounted in /mnt/hda7, if you wish to access any
files inside that partition, you can find it inside /mnt/hda7. It not
for default works like C:, D:, E:, but you can use those letters to
define your mount points, too.
The third
field
is very important because defines the type of the filesystem. Cdroms
are defined as iso9660, for example, floppies and harddisk partition
can be defined by using their filesystem, like /dev/sdb1 as vfat, or
just as auto, auto option is going to try find your filetype for you.
The forth
field
includes options to be used by mount command. There are several options
you can use, some are described above on the example, like defaults,
auto (mount automatically), users(allows any user to mount), and more.
You must study those options to better useyour fstab.
The fifth
field
is the dump option. Dump
checks it and uses the number to decide if a filesystem should be
backed up. If it's zero, dump will ignore that filesystem. If you take
a look at the example,
you'll notice that zero is most commom option.
The sixty
field
is used by fsck option. Fsck looks at that number
to determine in which order the filesystems should be checked. If it's
zero, fsck won't check the filesystem.
The FSTAB
is
necessary for all linux systems and must contain your devices in order
to let you use important devices like harddisk, cdroms and floppy disc.
While using the GoblinX as livecd, you do not need to worry about fstab
because the livecd is going to find your devices and create a correct
fstab, but if you have an installed distro, you have to pay attention
to your fstab or it cannot work well.
If you
cannot
access your cdrom, or a partition, probably is some mistake on fstab
file.
Tutor_05:
Console [Terminal] & Errors
Everyone is going someday to use a
console on Linux, and for some novice users the need to use a console
brings fear, but a console is one of most important instrument on
Linux, not only to run bash and scripts, but also to let you know more
about your system, applications and errors.
Probably the main place to find and
know about errors are log files, but you can know about errors while
using a console.
Open a console and type 'gimp' to
start the gimp, the results could be lines like following ones:
bash-3.00$ gimp
/usr/lib/gimp/2.0/plug-ins/helpbrowser: error while loading shared
libraries: libgtkhtml-2.so.0: cannot open shared object file: No such
file or directory
(gimp:7749): LibGimpBase-WARNING **: gimp: wire_read(): error
/usr/lib/gimp/2.0/plug-ins/print: error while loading shared libraries:
libgimpprint.so.1: cannot open shared object file: No such file or
directory
Those lines indicate some missing
libraries, Gimp is going to work without those libraries, but you can
correct the problem. The helpbrowser plugin uses a libgtkhtml, so to
run the plugin you need to install the library.
It's a very commom problem the
missing libraries. If you cannot run a program, probably you are
missing some libraries, so if you click on an icon and the program do
not start, open a console and type its command to see if you get any
error.
Another important example of errors
and console is used to compile applications. You need a console to
compile an application, or the kernel, and as you are using a console
you can see the output of all commands. An example result of
./configure command:
checking
for C compiler default output file name... configure: error: C compiler
cannot create executables
It's easy to identify the problem
above because there is no C compiler to compile a program, but the
configure command is going to look for all dependencies for you, you
just need to check the log file. It's also very usefull pay attention
to make command and its errors, sometimes you are going to see an
Error:1 stopping the compilation because an include file are missing.
Includes files are not be part of a program, but you need them to
compile the program.
Sometimes the command used for you
only gives a warning message, for example:
bash-3.00$
pyslsk
You do not have
Python
Vorbis bindings installed. Get them
from
http://www.vorbis.com/download_unix_1.0.1.psp or others
will not be able
to
see the lengths and the bitrates of Ogg
Vorbis files
that you
share. If you're using Debian, install
the
python-pyvorbis
package.
In the above example, the Pyslsk
program tells me that I need Python Vorbis to share bitrates of Ogg
Vorbis files, it's only a warning message, but relevant.
Another good example are about
crashes. During this week a friend got an error while using Open
Office, the
SWriter crashes after a few minutes, after open a console and start
Open Office using it, we got this message:
terminate
called after throwing an instance of
'com::sun::star::configuration::backend
::InsufficientAccessRightsException'
terminate called
recursively
KCrash:
Application
'soffice.bin' crashing...
soffice.bin:
Fatal IO
error: client killed
As you can see, you probably use
the console to compile applications and drivers, to run shell scripts
or bash commands, but you can also use it to identify errors, crashes
problems, missing libraries, missing includes and several problems in
your system.
Use the console
every time
you got
an error.

Tutor_06:
Proc Folder & Processes
The "The Proc Folder and Processes"
minitutor speaks about only
processes information stored at /proc folder.
The proc folder is like a filesystem inside the filesystem, used to
restore and show data kernel, it means, inside /proc
folder you have a lot of information about processes, hardware, drivers
and more.
From Proc Man Pages
"/proc is a pseudo-filesystem which is used as an interface to kernel
data structures rather than reading and
interpreting /dev/kmem. Most of it is read-only, but some files
allow kernel variables to be changed."
The /proc folder contains all runnings process information, showed by
their ID.
For example: You are running gpm to control your mouse, and by using
the command 'ps aux | grep gpm' you find that gpm has a process ID
2246, so if you type 'ls /proc/2246', you are going to get:
bash-3.00# ls
/proc/2246
auxv
cwd
exe ipaddr mem
oom_adj root smaps
statm task
cmdline
environ fd maps
mounts oom_score seccomp stat status
As you can see there are several pseudo-files and directories
containing source of information about the gpm process.
The 'cmdline' indicates exactly the command running, in the example,
when you use 'cat /proc/2246/cmdline',
you get '/usr/sbin/gpm-m/dev/mouse-tps2'.
The 'stat' is the one used by ps command to display information about
the process. The ps command used
above also let you know about your running process. The info get in the
stat is prepared to ps command,
like following example.
bash-3.00# cat
/proc/25998/stat
25998 (xinit) S
5754
5754 23844 1025 5754 8388864 584 0 4 0 0 0 0 0 16
0 1 0 43669 2347008
156 4294967295
134512640 134521372 3215734896 0 0 0 0 0 12807 0 0 0 17
0 0 0
The 'status' is like 'stat' but provides much of the information in
'stat' and 'statm' in an format that's easier
for humans to parse. If you type 'cat /proc/2246/status', you get
something like:
bash-3.00# cat
/proc/2246/status
Name: gpm
State: S (sleeping)
SleepAVG: 88%
Tgid: 2246
Pid: 2246
PPid: 1
TracerPid: 0
Uid: 0
0
0 0
Gid: 0
0
0 0
FDSize: 32
Groups:
VmSize: 1520 kB
VmLck: 0 kB
VmRSS: 340 kB
VmData: 148 kB
VmStk: 84 kB
VmExe: 60 kB
VmLib: 1196 kB
VmPTE: 12 kB
Threads: 1
SigQ: 1/4095
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000001000
SigCgt: 0000000008004202
CapInh: 0000000000000000
CapPrm: 00000000fffffeff
CapEff: 00000000fffffeff
The 'exe' pseudo-file is a simbolic link to the process command. Let us
used another example,
if you are running a Xterm as process ID 23400, you can start another
Xterm by typing /proc/23400/exe.
The 'maps' contains the current mapped memory regions and their access
permission.
The 'root' display a copy of your root filesystem.
The 'environ' pseudo-file contains the environment for the process.
If you type '(cat /proc/23400/environ; echo) | tr "\000" "\n"' you get
a lot of information about your system.
bash-3.00# (cat
/proc/23400/environ; echo) | tr
"\000" "\n"
CPLUS_INCLUDE_PATH=/usr/lib/qt/include
MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man:/opt/kde/man:/usr/lib/qt/doc/man
HZ=100
SSH_AGENT_PID=1771
HOSTNAME=darkstar.example.net
SHELL=/bin/bash
TERM=linux
HUSHLOGIN=FALSE
QTDIR=/usr/lib/qt
USER=root
GDK_USE_XFT=1
SSH_AUTH_SOCK=/tmp/ssh-LsSuz13910/agent.13910
KDEDIR=/opt/kde
SESSION_MANAGER=local/darkstar:/tmp/.ICE-unix/28024
T1LIB_CONFIG=/usr/share/t1lib/t1lib.config
MINICOM=-c on
MAIL=/var/spool/mail/root
PATH=/usr/bin:/usr/sbin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin
:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/kde/bin:/usr/lib/qt/bin
LC_COLLATE=C
INPUTRC=/etc/inputrc
PWD=/root
LANG=en_US
SHLVL=3
HOME=/root
LS_OPTIONS=
--color=auto -F -b -T 0
LESS=-M
LOGNAME=root
LESSOPEN=|lesspipe.sh
%s
DISPLAY=:0.0
Even though there are pseudo-files you cannot access by
using a simple
cat command, and other you can access at all, you can get more detailed
information about the process by looking inside their proc ID folder.
You can use some information about your process, or you can only look
around your running process to know more about your system. If you find
those info difficult to understand, try use only ps command. The ps
command is going to simplificate info about processes.
Don't forget, know about your running processes is know
about your
machine and system.
And also, don't forget to read the proc man pages.

Tutor_07:
Proc Folder & Important Files
The above minitutor already talked
about the /proc, but the only subject was about the processes,
now it talks about some important files inside your proc folder.
The proc folder is like a
filesystem inside the filesystem, used to
restore and show data kernel, it means, inside /proc folder you have a
lot of information about processes, hardware, drivers
and more. From Proc Man Pages
"/proc is a pseudo-filesystem which is used as an interface to kernel
data structures rather than reading and interpreting /dev/kmem. Most of
it is read-only, but some files allow
kernel variables to be changed."
Inside the folder you can see
several directories and files, those files are the subject of this
minitutor and you must know everything about them, because they have a
source of information about your system you need. Those files are
common read by several commands and applications to get information to
display, for example, system monitors like Gkrellm and Karamba.
The 'cmdline' file receives
arguments passed to the Linux Kernel at boot time, it means this is the
file you can read about all cheatcodes you are using. You can write any
parameter during boot in this file, by using your boot manager or the
boot prompt. We use scripts to to read this file looking for cheatcodes
to start special services.
The 'cpuinfo' file is a collection
of CPU and system architecture dependent items, where you can get
information about your processor like model, model name cache size,
vendor_id and more.
The 'devices' files list major
numbers and devices groups, the 'dma' is a list of the ISA DMA (direct
memory access) in use, the 'execdomains' a list of the execution
domains, the 'fb' is the frame buffer information.
The 'filesystems' is a text list of
the filesystems which were compiled into the kernel. This file is used
b mount command to cycle through different filesystems when none is
specified. It's a important file and let you know more about
filesystems supported for your kernel.
The 'interrupts' file is used to
record the number of interrupts per each IRQ on the i386 architecture,
the 'iomen' is the I/O memory map, the 'ioports' is a list of currently
registered Input-Output port regions that are in use, the 'locks' file
shows current file locks and leases.
The 'meminfo' file, used by free
command, report the amount of free and used memory, phisical and swap,
on the system and also shared memory and buffers used by the kernel.
The 'mounts' is a list of all
filesystems currently mounted, the 'modules'
a list of the modules that
have benn loaded by by the system, the 'mtrr' is the memory type range
registers.
The 'partitions' file contains
major and minor number of each partition as well as number of blocks
and partition name, the 'slabinfo' list information about kernel
caches, the 'stat' is the kernel/system statistics, the 'swaps' list
swaps areas in use, the 'uptime' contains two number, the uptime of the
system and the amoun of tim spent in idle process, both in seconds, and
the 'version' identifies the kernel version.
As you can see above, those files
are common read by several commands to get information about the
system, the 'free' command for example reads info about memory on
/proc/meminfo, the 'lsmod' gets info about kernel loaded modules on
/proc/modules.
The Gkrellm and Karamba running on
GoblinX get the info showed to you from these files inside proc folder.
You can create your own scripts or applications to read and show
information about your system by using those files, you can let the
user know about some problems, some dangerous behaviors on his machine,
or give to him source of information he can not find anywhere.
Understand, read and use
the
files
inside proc folder is a good step to know better your system and your
machine.
Tutor_08:
Create and Delete Users
The
Linux has a master of the
system called 'root'. The root is the owner, the main user on the
system, and has virtual access and control of everything, because of
this power it is necessary create other users to retain the protection. Create an user is one of the
very first step you must do and there is a command you can use called:
useradd. Useradd is the command used to create a new user or update
default new user information, and the command has some important
options.
When the
useradd command is invoked without '-D' option, it creaes a new user
account using the values specified on the command line and the default
values from the system, in fact you can type only 'useradd
nameoftheuser' to create a new user account using default values and
when is invoked with the '-D' option, it either display the default
values or update values from command line. Another option you can use is
'-d', to specify the
user's login directory inside home dir using the user's login name as
user directory, for example -d /home/goblix_home, the default is going
to use the user's login name.
You can also set the
expire_date of the user account by using '-e' option, set the number of
inactive_days after password expires until the account is going to be
disabled, 'f', the initial group name or number of the user's initial
login group, '-g', a list of supplementary groups which the user is
also a menber of, '-G'.
The '-m' option allows the
useradd command to create the user's login directory for you, the '-s'
specify the user's login shell, and you have a few more options.
An example of useradd command:
useradd -m -c goblix -d /home/goblix_home -s '/bin/bash' goblix.
You can see the -m option to create the user's home, -c option to add a
comment to the user's password, the -d option specifying the user's
home directory and the '-s' option specifying the default shell,
followed by the name of the user.
As you can see above, no password is set to the new user, you must use
another command, the 'passwd'. The 'passwd' is the best way to set the
password of the new user, just type 'passwd goblix' and then twice the
password, and choose a good password using letters, number and symbols.
The /etc/passwd file has all
user account information and /etc/group file the group information, you
can specify the group of the new user and its supplementary groups. The
'-G' option is important if you wish to add some groups to only few
users, for example, you have a floppy group, it means only users added
to this group can mount floppies. You can use a command like: 'useradd
-m -c goblix -d /home/goblix_home -s '/bin/bash' -G floppy,cdrom
goblix'. In the example the goblix user is going to have acess to
cdroms and floppies, but you wish to enable groups to all users, it's
better to use another important file called 'login.defs'.
Login.defs
file,
inside /etc folder, defines the site-specific configuration for shadow
password suite and it's going to be subject to another minitutor, but
in the example you can define groups to all users, like following
example:
# List of groups to add
to the user's
supplementary group set when logging in on the console
# (as
determined
by the CONSOLE setting). Default is none.
CONSOLE_GROUPS floppy:audio:video:cdrom
The control of what you user
can do it's very important. If you wish to use XServer and connect to
internet, it's better create an user for this proposal instead of use
root, because you will have more security.
If you wish to delete an user,
you need to use 'userdel' command, just type 'userdel nameoftheuser' to
remove the user, and if you wish also to remove the user's login home
directory, type 'userdel -r namoeoftheuser', the '-r' option remove all
files and also the user's home directory.
Create at
least
one user for your system, you need to have one to be more protected.
Tutor_09:
Resize & Join Partitions
The Linux
uses several
filesystems types, such as ext2, ext3 and reiserfs, and those
filesystems have an application prepared to let you resize a harddisk
partition or partitions.
For
ext2/ext3
partitions you need to use: resize2fs
From resize2fs manpage:
"The resize2fs program will
resize ext2
file systems. It can be used to enlarge or shrink an ext2 file
system located on device. The size parameter
specifies the requested new size of the filesystem. If no units are
specified, the units of the size parameter shall be
the
filesystem blocksize of the filesystem. Optionally, the size parameter
may be suffixed by one of the following the units
designators: 's', 'K', 'M', or 'G', for 512 byte sectors,
kilobytes, megabytes, or gigabytes, respectively. The size
of the filesystem may never be larger than the size of the
partition. If size parameter is not
specified, it will
default to the size of the partition.
The resize2fs program does not manipulate
the
size of
partitions. If you wish to enlarge a filesystem, you must first
make sure you can expand the size of the underlying partition
first. This can be done using fdisk(8) by
deleting the partition and recreating it with a larger size."
For
reiserfs
partitions you need to use: resize_reiserfs
The idea behind both are the same, they are indicated you wish to
resize an existent partition and not change the size of the partition.
You can
notice
we have cfdisk and fdisk application to resize and parted your
harddisk, we will use in the example fdisk to join partitions and
resize2fs to resize the filesystem.
Let's use
an
example.
Imagine you
have two Linux partition on your system you wish to join,
/dev/hda5 and /dev/hda6, you only can join partition if they are side
by side in your harddisk. If you have doubt about it, type 'fdisk
/dev/hda' and then type 'p' to see the End and Start of each partition.
An example below:
Disk /dev/hdb: 120.0 GB, 120060444672 bytes 255 heads, 63 sectors/track, 14596 cylinders Units = cilindros of 16065 * 512 = 8225280 bytes Dispositivo Boot Start End Blocks Id System /dev/hda1 * 1 7298 58621185 83 Linux /dev/hda2 7299 14024 54026595 83 Linux /dev/hda5 14025 14250 1815345 83 Linux /dev/hda6 14251 14596 2779245 83 Linux
The above
example indicates you have two small partitions you wish to join.
Imagine now in the /dev/hda5 you have three directories you use to
store files, an example: images, documents, packages. And in the
/dev/hda6 you have oldfiles, and newfiles.
You want
to join
these partition in one /dev/hda5, and you can do it without lose your
files.
First you need
to copy all directories found inside /dev/hda6 to
/dev/hda5.
After copy all
contents we are going to join these partitions, by using
fdisk again. Type 'fdisk /dev/hda', then type 'd' to delete a
partition, type '6', then again 'd' and type '5'. Don't worry about
your files, we are only changing the harddisk table and not deleting
files, but if you have doubts, test it before.
Now you need to
join those partition, while inside fdisk type 'n' to
create the new partition, then type '5', number of the first partition
removed. After the step, type again 'p' to see if these partitions are
joined in one.
The results
must be:
Disk /dev/hdb: 120.0 GB, 120060444672 bytes 255 heads, 63 sectors/track, 14596 cylinders Units = cilindros of 16065 * 512 = 8225280 bytes Dispositivo Boot Start End Blocks Id System /dev/hda1 * 1 7298 58621185 83 Linux /dev/hda2 7299 14024 54026595 83 Linux /dev/hda5 14025 14596 4594590 83 Linux
After you
see
the results, type 'w' to realocate partitions. You have now a new
parition created by join the previous /dev/hda5 and /dev/hda6, but you
don't have the filesystem, to create it we will use resize2fs.
Just type
'resize2fs /dev/hda5' and your filesystem will be resized to fit your
new partition. Without any parameter the resize2fs will fit all
partition space, but you have the option to indicate the size of the
new resized filesistem by using 'resize2fs /dev/hda5 size', or if you
want a reiserfs partition instead of ext2, 'resize_reiserfs /dev/hda5'
or a differente size 'resize_reiserfs -s size /dev/hda5'. You now
have a
new partition resized and with your contents of older to partitions.
If you
have some
important files, it's better test the minitutor on some not important
partitions to see if it works ok for you.
This
Minitutor
is
based on a article written by Diniz Fernando Bortolotto Ferreira and
published by Dicas-l.com.br. Original article [Portuguese]: http://www.dicas-l.com.br/dicas-l/20060416.php

Tutor_10:
Chown & Chgrp
The Linux user when just start to use the system
will try
to learn more and more about the system and its application, in this
search of knowledge, the user is going to find several opinion and
warning about not use 'root' to do some tasks like browse the
internet... The first step when you installed a Linux distro is change
the root password and create a new user.
After create a new user without root power, you
need to
know some basic commands such as Chown and Chgrp.
From Chown Man Page:
Chown
changes the user and/or group ownership of each given file, according
to its first non-option argument, which is interpreted as
follows.
The GNU chown
command you
will use during all your Linux days and you must know its options
because change ownership of files and directories are definitively a
daily job. Chown main syntax to use is 'chown username:usergroup file'.
The example changes the ownership and also the group of the file. The
first item given is the username, if you only use 'chwon user
file.txt', you only change the user of the file.txt, but if you use
'chown user:group file.txt'.
There are some
good
options to use with chown, a very praticle one is '-R' option, or
'--recursive' which is used to change the ownership of files and
directories recursively, and example 'chown goblix /home'. There
are options to control the verbosity of the command if you wish to know
more information, such as '-c', that reports only when a change is
made, and '-v', that output a diagnostic for every file processed.
Imagine the
following
scenary, you have an user called goblix, and also root, and you create
another one called theuser, now you wish to copy some files
ownered by goblix to /home/theuser, but those files are in one
folder full of files ownered by others users, for that you can use the
option '--from'. This option will only change the ownership of files
ownered by the given user in the command, an example 'chown -R
--from=goblix theuser /etc'.
The Chgrp works
exactly
the same, but it changes the group ownership of a file, for example
'chgrp users file.txt' is going to change the group of the file to
users. Some options used with chown also are applicable with
chgrp command such as -R, -v, -h, -c, but the '--from' option are not
applicable.
These commands are
very
usefull and you will use them, specially chown command.
You will need to use files ownered by root logged as user and in order
to edit these files you need to change the mode or, better, change the
ownership of them, and chown is there for you.

Tutor_11:
Change Process Priority
It could
often
happen that moment to change the priority of runnings process, or start
a command with an adjusted niceness, and for those moments you can use
'nice' and 'renice'.
All Linux processes work with priorities from
-20 to
+20, being -20 the
major priority, and root have control over the above scale, all though
common users only can set priority from 0 to +20.
The first command of this family is 'nice'. Nice is used to run command
with an adjusted niceness, which affects process scheduling. Nicenesses
range from -20 (most favorable scheduling) to 19 (least favorable).
The basic
sintaxe is: nice [OPTION] [COMMAND [ARG]...].
For
example 'nice
-n 12 leafpad
text' is going to start leafpad, open a file called text
with priority set to +12. The arguments must be the last entry because
they refer to the command to be executed and not to nice, you do not
need any argument or neither to set the niceness, by default nice uses
+10.
The second command of the family is 'renice'.
From
Renice Man
Pages:
Renice alters the
scheduling priority of one or more running processes. The following who
parameters are interpreted as process ID's, process group ID's, or user
names. Renice'ing a process group causes all processes in the
process group to have their scheduling priority altered. Renice'ing a
user causes all processes owned by the user to have their scheduling
priority altered. By default, the processes to be affected are
specified by their process ID's.
As you can see, if you wish to start a process and set its niceness you
need to use 'nice', but if you wish to change the priority of a running
process, you will use 'renice'.
The basic
sintaxe is: renice priority [[-p] pid ...] [[-g] pgrp ...] [[-u] user
...].
The '-u' option
is used to indicate user of running process to modify, '-p' the pid of
the process, and '-g' process group pid. An example 'renice +1 987 -u
daemon root -p 32' would change the priority of process ID's 987
and 32, and all processes owned by users daemon and root.
Let's pratice and understand. You desire to change the priority of the
'crond' process, first you need to know the PID of crond process, you
can type 'ps
-C crond' to get the PID, an example '5124' as PID. After get
the PID, you need to know its priority, you can use 'top' command to
know it, type 'top
-p 5124', you will see several columns and values, the 'NI'
column indicates the priority number set by nice, in the example '0'.
Now you can use, for example, 'renice -2 5124'
to change the priority to '-2', or a better scheduling priority.
These commands are very usefull in several ocasions, mostly when a
better performance are necessary, however they must be carrefully used
because change the priority to a high value like '-18' or '-19' can
decrease the performance and make the system works slowly. Before you
adventure yourself on changing priority process, it's better know more
about these commands.
Tutor_12:
Adjust Tunable Filesystem Parameters
System
administrator, or carrefully users, can adjust verious tunable
filesystem parameters on Linux filesystems in order to get better
performance, and they have tunning applications for every Linux
filesystem, for example, tune2fs for ext2/ext3 filesystems, jfs_tune
for jfs and reiserfstune for reiserFS.
Tune2fs is the tunning tool for ext2/etx3 filesystems and can be used
to adjust tunable filesystem parameters.
The first option of tune2fs is used to adjust the maximal count between
two filesystem checks.
The '-c' option is important because any Linux system must check
sometimes the partition and its filesystem. You can disable all checks
by set max-mount-counts to 0 or -1, but you should strongly consider
the consequences of disabling mount-count-dependent. The filesystem
must be checked from time to time because bad disk drives, cables,
memory, and kernel bugs could all corrupt a filesystem without marking
the filesystem dirty or in error. If you use 'tune2fs -c 10 /dev/hda2' after ten
mount-counts the filesystem will be checked.
Another option you can use in order to postoponed or accelerate the
next filesystem check is '-C'.
The '-C' option set the number of times the filesystem has been
mounted. You can use with -c to force an fsck on the filesystem at the
next boot, for example 'tune2fs -c 10
-C 9 /dev/hda2'.
You can
also
change the error behavior. It's an important option if you wish to
force a remount of kernel panic, in all cases, a filesystem error will
cause e2fsck(8) to check the filesystem on the next boot,
but if you set the '-e' option to remount-to or panic, instead of
continue, you will have the filesystem boot stopped.
You can override another error, this time errors while tunning the
filesystem with option '-f'.
As you
can see
above, you can specify all many times your filesystem will be mounted
before it's checked, but you can also specify certain period of time,
such as days, weeks and months, with '-i' option. It is strongly
recommended that either -c (mount-count-dependent) or -i
(time-dependent) checking be enabled to force periodic full e2fsck(8)
checking of the filesystem. An example 'tune2fs -c 10 -i 1w /dev/hda2'.
Some more
important options are '-j', to add an ext3 journal to the filesystem,
'-J' to override the default ext3 journal parameters, '-l' to list the
contets of a filesystem block, '-L' to set a volume label, '-m' to
reserve blocks percentage, '-u' set the user who can use reserved
blocks, '-U' set the unique identifier, and more.
You can
also use
the option '-o' to change the default mount options from /etc/fstab by
using tune2fs.
For some
reasons
if you disable the periodic filesystem check, you need to use tune2fs
to reconfigure the check periodic. Never stop all filesystem checks,
because an error or a bad block can damage your harddisk forever. If
you do not wish to check your filesystem every boot, change your init
scripts, and try use tune2fs to reconfigure options used by fsck. If
you often need to reboot your computer, you can use tune2fs to set a
long period between checks, but do not forget also to use the
time-dependent option.
It often
necessary checks the filesystem, if you have two or three partition and
use one a lot more than the other, because while you are using a
partition the others are mounted, in the next boot from the less used
filesystem.
Use
tune2fs to
tunable your filesystem parameters to get better performance of your
filesystem and better control of errors. Try read the manpage to know
more about the options.

|