Saturday, March 28, 2009

Class 12 Installing Packages in gnu/Linux.!

Redhat Package Manager - RPM
---------------------------------------------------------
* Can install, remove, query, and verify the software on your system
* Can run as root only, since it can change the underlying system.
* Used in other distro's like SuSe and Mandrake too
* have a local database and related files at /var/lib/rpm
* have four common elements : Name , Version (major.minor.patchlevel), Revision and Architecture.
* has frontends like Yum and up2date
* has Five basic modes of operation :
Installing - rpm -i
Uninstalling - rpm -e
Upgrading - rpm -U
Querying - rpm -q
Verifying - rpm -V

Querying:- 

Examples :

(1) rpm -qa | more -> what software you have installed on your system.

-q -> Query option
-a -> List all the packages

(2) rpm -qf /etc/sysctl.conf

-f -> Display the package that contains a particular file.

(3) rpm -qpl package_2.0.2-i386.rpm

-p -> Query a (uninstalled package file).
-l -> List the files in packages.

(4) rpm -qilsdc quota

-i -> displays package information including name, description, release, size, build date, install date, vendor, and other miscellaneous information.
-s -> displays the state of all the files in the package.
-d -> displays a list of files marked as documentation (man pages, info pages, READMEs, etc.).
-c -> displays the configuration files.

(5) rpm -q whatrequires package

print the other packages that depends on the package, installed

(6) rpm -qpR package_2.0.2-i386.rpm

to get the list of packages and programs that are required for instalation of the package_2.0.2-i386.rpm

Installing:- 

1. rpm -ivh package_2.0.2-i386.rpm

-v -> verbose
-h -> print hashes

Other options:- 

--test # simulate what will be done when executing "rpm -ivh package.rpm"
--nodeps # Don't perform a dependency check when installing or upgrading a package
--replacefiles # Install package even if it overwrites existing files
--replacepkgs # Install package even if it's already installed
--force # Combination of --replacefiles, --replacepkgs, and --oldpackage

Upgrading or Freshening:- 

Upgrading to a New package can be done in 2 ways, by freshening the package and by executing:

rpm -Uvh new-package.rpm

"-U" Upgrading option simple removes the old and installed package, then install the new one. The "-Uvh" can be used to install a package too, while freshening can upgrade only installed packages.

For downgrading also the same -U has to be used, but with an extra option though.

rpm -Uvh --oldpackage package_1.0.1-i386.rpm

Freshening --> rpm -Fvh package_2.0.2-i386.rpm <-- will upgrade only if old version of package exists. Erasing or Removing- rpm -e package rpm -e --test package - Don't actually remove package. Just show what will be removed. rpm -e --repackage package - A backup copy is made. The Old RPM will be generated on "_repackage_dir" RPM macro, usually /var/spool/repackage. _repackage_dir can be confirmed by the command, "rpm --showrc" rpm -q --whatrequires package - See a list of packages that requires the RPM package you're trying to erase Verification rpm -V package - Verify installed package rpm -Vp package_VVV-RRR.i386.rpm -- Verify package file, before installing rpm -Va -- Verify all packages Verify the packages downloaded using the GPG-Key rpm --import RPM-GPG-KEY (need to download the key first)
Debian Package Management
:-

.deb is the extension

Installation:-
 
apt-get install packagename

for installing from the repository.


Examples for package installation:-

dpkg --status package - To determine exactly which files are preserved during an upgrade.
dpkg -i package_2.0.2-1_i386.deb - Install package file
dpkg -R /usr/local/src - Install all packages recursively
dpkg --unpack package_2.0.2-1_i386.deb - Unpack the package, but don't configure it.
dpkg --configure package - Configure the unpackaged package
dpkg -r package - Remove an installed package, but leave the config file intact
dpkg -P package - Purge an installed package, including the config files.
dpkg -C package - Searches for packages that have been installed only partially on your system
dpkg -c package_2.0.2-1_i386.deb / dpkg --contents - List contents of package_2.0.2-1_i386.deb
dpkg -l mp3 - List packages matching the word mp3
dpkg -l - List all installed packages, along with package version and short description
dpkg -L package - List files installed to your system from package
dpkg -S 'search pattern' - Search for a filename from installed packages.
dpkg -p package - Display details about package.
dpkg --fsys-tarfile package_2.0.1-i86.deb | tar -xf - config.conf - Extract a single file named config.conf from the package.

Building binary packages from a source debian package:-

You will need all of package_*.dsc, package_*.tar.gz and package_*.diff.gz to compile the source. If there is no, package_*.diff.gz, don't panic. It's "OK".

Make sure dpkg-dev and fakeroot package is installed and dpkg-source command is available. After that,

dpkg-source -x package_version-revision.dsc

will extract the package into a directory called package-version.

If you want just to compile the package, you may cd into package-version directory and issue the command

dpkg-buildpackage -rfakeroot -b

Conversion b/w rpm and deb formats:-
Redhat Package Manager - http://labix.org/smart
Alien - http://kitenet.net/~joey/code/alien/

Package Managers:-

Yum, Apt, Slap-get, Emerge, pkgadd and so on are the package management tool or s/w that act as a automatic updater and package installer/remover for rpm, deb and tar.gz based systems.

Yum (Yellow dog Updater, Modified) is mainly used in the rpm based distros, like redhat, fedora, centos and so on.
Apt (Advanced Package Tool) is for debian based systems. Slap-get, slackpkg is for Slackware, Portage, Emerge for Gentoo and pkgadd for root linux, urpmi for Mandriva and Yast is used by SuSe

These are client server architecture for a software.

Some Yum Options:-

Escape the wild characters using the \.

yum install package
yum groupinstall "MySQL Database"
yum localinstall package.rpm

yum update package
yum groupupdate ""MySQL Database"

yum remove package
yum groupremove "MySQL Database"

yum list package - Search for specific package by name
yum grouplist - List all groups.
yum search mp3 - Searches the names, descriptions, summaries and listed package maintainers of all of the available packages to find those that match
yum provides libc.so - search for all packages that include files called libc.so

yum clean headers , yum clean packages , yum clean metadata , yum clean all - to redownload the indexes and cached files.

yum check update
yum upgrade

tell2humanlinux@gmail.com

Class 11 File Types



FileTypes:-

Ordinary - text, ./binary, .images, html and conf files
Directory - Also known as folders
Special/Device File - Hardware
Devices - /dev/lp0 , /dev/hda1, /dev/sda1, /dev/fd0
Logical Devices - /dev/null , /dev/zero
Links - Hardlinks and SoftLinks + Difference of Hardlinks & SoftLinks
Sockets - A socket refers to a special file with which communication between locally running processes happens
FIFOs Or Named Pipes - act more or less like sockets and form a way for processes to communicate with each other, without using network socket semantics

FIFO is a one way communication pipe, while Unix domain sockets (otherwise called as IPC Sockets) are two way communication pipes


ls -l /dev/console
crw------- 1 root root 5, 1 2008-03-30 17:45 /dev/console

- Regular file
d Directory
l Link
c Special file
s Socket
p Named pipe

Maximum number of characters for a file name --> 255
Use backslash for special characters
Case sensitivity for files

Color codes:-

blue directories
red compressed archives
white text files
pink images
cyan links
yellow devices
green executables
flashing red broken links

Suffix Schemes:-

nothing regular file
/     directory
*    executable file
@   link
=   socket
|     named pipe

PathNames:-

Relative Path and Absolute path

Relative Path: the relative path is the path to the destination file /directory from the current location.

Absolute Path : the absolute path is the path from the '/'

Maximum length of PathNames including slashes - 4096

Examples:-

/root/humanlinux/Desktop/FIL-102 - Absolute Path (beginning with /)
 

relative pathe are:

../Desktop/FIL-102

./FIL-102

~/FIL-102

tell2humanlinux@gmail.com

Saturday, February 28, 2009

Class 10 The gnu-Linux File System


The first thing that most new users shifting from Windows will find confusing is navigating the Linux filesystem. The Linux filesystem does things a lot more differently than the Windows file system.This article explains the differences and takes you through the layout of the Linux filesystem.there is only a single hierarchal directory structure.Everything starts from the root directory, represented by '/', and thenexpands into sub-directories.Windows, the various partitions are detected at boot and assigned a drive letter. Under Linux, unless you mount a partition or a device, the system does not know of the existence of that partition or device. This
might not seem to be the easiest way to provide access to your partitions or devices but it offers great flexibility.

the file system can be classified accourding to the purpose
1)Sharable/Variable
2)Unsharable/Static For eg:

                    Sharable                        Unsharable
..................................................................................
Static           /usr                                    /etc                      
                    /opt                                    /boot

..................................................................................
Variable     /var/mail                             /var/run
                   /var/spool/news                  /var/lock


We cant load them in a different file system location(partition) for eg, we cant load /etc & /lib in other partiotion.it should be under / the (root).here is the list of files n directories under / for fedora linux:

bin
boot
dev
etc
home
lib
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var

some explanations:
/usr->Unique System resource
/etc->Configuration files
/opt->Optional packages
/boot->boot files
/var->variable
/bin->essential executables for every user & to be used in single user mode
/sbin->essential system executables
/lib->essential shared libraries & kernel modules
/boot->static files of bootloader
/dev->device files & scripts called MAKEDEV,device types-c,h,d,b,l

the major no: & minor no: is used by kernel to identify a device
Major no:- it is an indication for which device driver should be used to acess a particular device.
Minor no:- is which tells the kernel the special characterstics of the device to be acessed.

to know the malor & minor no: of a device :- ls -la 'device name' eg: ls -la sd*

we should be familiar with the most of the files n directories under /etc. These files are of high imoprtance and should be modifiled for administration and for trouble shooting! the files n directories under /etc for fedora are:

adjtime
aliases
aliases.db
alsa
alternatives
anacrontab
anthy-conf
asound.conf
asound.state
at.deny
audisp
audit
avahi
bash_completion.d
bashrc
blkid
bluetooth
bonobo-activation
chkconfig.d
ConsoleKit
cron.d
cron.daily
cron.deny
cron.hourly
cron.monthly
crontab
cron.weekly
csh.cshrc
csh.login
cups
dbus-1
default
depmod.d
dhcp6c.conf
DIR_COLORS
DIR_COLORS.256color
DIR_COLORS.xterm
dirmngr
dnsmasq.conf
dnsmasq.d
dumpdates
enscript.cfg
environment
esd.conf
ethers
event.d
exports
favicon.png
fb.modes
fedora-release
festival
filesystems
fonts
foomatic
fstab
gconf
gcrypt
gdm
ghostscript
gimp
gnome-vfs-2.0
gnome-vfs-mime-magic
gnupg
gpm-root.conf
gpm-syn.conf
gpm-twiddler.conf
gre.d
group
group-
grub.conf
gshadow
gshadow-
gssapi_mech.conf
gtk-2.0
gtkmathview
hal
host.conf
hosts
hosts.allow
hosts.deny
httpd
idmapd.conf
init.d
initlog.conf
inittab
inputrc
iproute2
issue
issue.net
jwhois.conf
kde
kernel
kerneloops.conf
krb5.conf
ldap.conf
ld.so.cache
ld.so.conf
ld.so.conf.d
lftp.conf
libaudit.conf
libuser.conf
localtime
login.defs
logrotate.conf
logrotate.d
logwatch
lvm
mail
mailcap
mail.rc
makedev.d
man.config
mime.types
minicom.users
mke2fs.conf
modprobe.conf
modprobe.d
motd
mtab
mtools.conf
multipath.conf
netconfig
netplug
netplug.d
NetworkManager
networks
nscd.conf
nsswitch.conf
nsswitch.conf.bak
ntp
ntp.conf
obex-data-server
openldap
openvpn
opt
PackageKit
pam.d
pam_pkcs11
pam_smb.conf
pango
passwd
passwd-
pcmcia
pki
pm
pm-utils-hd-apm-restore.conf
PolicyKit
popt.d
portreserve
ppp
prelink.cache
prelink.conf
prelink.conf.d
printcap
profile
profile.d
protocols
pulse
purple
quotagrpadmins
quotatab
rc
rc0.d
rc1.d
rc2.d
rc3.d
rc4.d
rc5.d
rc6.d
rc.d
rc.local
rc.sysinit
redhat-release
resolv.conf
rmt
rpc
rpm
rsyslog.conf
rwtab
rwtab.d
samba
sane.d
sasl2
scim
scsi_id.config
securetty
security
selinux
sensors3.conf
services
sestatus.conf
setroubleshoot
setuptool.d
sgml
shadow
shadow-
shells
skel
smartd.conf
smolt
smrsh
sos.conf
sound
ssh
statetab
statetab.d
stunnel
sudoers
sysconfig
sysctl.conf
system-release
system-release-cpe
terminfo
udev
updatedb.conf
virc
vpnc
warnquota.conf
wpa_supplicant
wvdial.conf
X11
xdg
xinetd.d
xml
yp.conf
yum
yum.conf
yum.repos.d


Most of the configuration files for the system lies under /etc.  So please be sure before you edit them, or else take a back-up of it and edit to feel the changes on your system :)
tell2humanlinux@gmail.com

class 9 Answers

will be updated soon!

Thursday, February 19, 2009

Class 8 A few exercises.

Here let us do some exercises using the commands i have mentioned in the above classes.Please try yourselves, answers will be posted in next class!

1)list the last modified file at the beginning.(last modified file should be listed first)
2)descent the files according to its size.
3)to list the files and directories in a list and not in lines
4)to make directories recursively or like a tree ,one inside the other in a single command(ie a ,b inside a,c inside b ...etc)
5)needs to find all the .txt files in the current directory and copy it to a file in a single command
6)to list the files belonging to a user using uid
7)to copy all the files except the directories to a folder
8)to know the disk usage of the current folder


tell2humanlinux@gmail.com

Tuesday, February 17, 2009

Class 7 continued

cat >filename :to i/p the items to a file, but replaces the old data.
cat >>filename :will append the files,wont delete old data.
cat file1 file2 >file3 :file3 contains o/p of file file1 & file2 which are concatenated.
sort : hit enter, n type the data, n press ctrl D . it will sort the data alphabetically.
sort :will sort the contents of 'file' alphabetically.
who | sort :here a pipe '|' is used to o/p the sorted list of users.
host www.website.com : to display the static ip of a 'website'.
grep: to seach inside a file
grep -i "word" file : will search for files with "word" within a directory recursively.
grep -r "word" /etc :will search for "word" inside /etc, recursively.
grep 'word' *.c : to search for files with particular extension *.c
man heir :to know file system hierarchy.

next i wil post the file system hierarchy,some more commands n files.

tell2humanlinux@gmail.com