390 likes | 558 Views
GNU/Linux Fundamentals Part 3. by Aliaksandr Stelmachonak, Dzmitry Kuchko. Network Configuration. 2. Network i nter f ace config urator. ifconfig – configure and control TCP/IP network interfaces Example: Common uses for ifconfig include
E N D
GNU/Linux Fundamentals Part 3 by Aliaksandr Stelmachonak, Dzmitry Kuchko
Network interface configurator • ifconfig– configure and control TCP/IP network interfaces Example: Common uses for ifconfig include • setting an interface's IP address and netmask • and disabling or enabling a given interface • ifconfig displaying the current state of network interfaces
Network interface configurator display all interfaces which are currently available, even if down ifconfig –a ifconfig eth0 ifconfig eth0 up ifconfig eth0 down ifconfig eth0 inet 192.168.1.13 netmask 255.255.255.0 displaying the current state of eth0 interface Activating and deactivating eth0 interface Setting configuration for eth0 interface
Network commands sending a ping request $ ping google.com $ ping –c 5 google.com $ traceroutegoogle.com $ tracepathya.ru $ host ya.ru $ host 213.180.204.8 $ dig ya.ru $ dig –x 213.180.204.8 show the network route for a given host translate ip address to hostname or vice versa Another method
Linux distros hierarchy Slamd64 MOPSLinux Zenwalk SUSE Linux OpenSUSE Red Flag Yellow Dog CentOS Mandrake/Mandriva Fedora Knoppix Xandros Lindows/Linspire/Freespire SimplyMEPIS Ubuntu Family
Differences between distros Red Hat based /etc/sysconfig/network Debian based /etc/network/interfaces /etc/hostname /etc/resolv.conf • /etc/sysconfig/network-scripts/ifcfg-ethX • /etc/sysconfig/network • /etc/resolv.conf
Main Settings [root@rhel ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 root@ubuntu:~# cat /etc/network/interfaces auto lo eth0 iface eth0 inet static address 192.168.0.10 netmask 255.255.255.0 gateway 192.168.0.1 • DEVICE=eth0 • IPADDR=208.164.186.1 • NETMASK=255.255.255.0 • NETWORK=208.164.186.0 • BROADCAST=208.164.186.255 • ONBOOT=yes dhcp BOOTPROTO=dhcp
Host name [root@rhel ~]# cat /etc/sysconfig/network root@ubuntu:~# cat /etc/hostname myhost.local ;-) • NETWORKING=yes • FORWARD_IPV4=yes • HOSTNAME=myhost.local • GATEWAY=192.168.0.1
DNS and search domains root@generic-linux:~# cat /etc/resolv.conf • domain minsk.epam.com • search epam.com. minsk.epam.com. • nameserver 10.6.0.6 • nameserver 10.6.0.16
Restarting network root@ubuntu:~# /etc/init.d/networking restart * Reconfiguring network interfaces... [ OK ] root@rhel:~# service network restart Shutting down interface eth0: [ OK ] Bringing up interface eth0: Determining IP information for eth0... done. [ OK ]
Linux distros hierarchy Slamd64 MOPSLinux Zenwalk SUSE Linux OpenSUSE Red Flag Yellow Dog CentOS Mandrake/Mandriva Fedora Knoppix Xandros Lindows/Linspire/Freespire SimplyMEPIS Ubuntu Family
Some definitions A software package refers to computer software packaged in an archive format to be installed by a package management system or a self-sufficient installer. A package management system is a collection of tools to automate the process of installing, upgrading, configuring, and removing software packages from a computer.
General Differences between distros Red Hat based Debian based DEB dpkg apt • RPM • rpm • yum
Some definitions RPM (Red Hat Package Manager) is a package management system. Originally developed by Red Hat for Red Hat Linux, RPM is now used by many Linux distributions. YUM (The Yellow dog Updater, Modified) is an open source command line package management utility for RPM-compatible Linux operating systems and has been released under the GNU GPL. deb is the extension of the Debian software package format and the most often used name for such binary packages. Like the "Deb" part of the term Debian, it originates from the name of Debra, then girlfriend and now ex-wife of Debian's founder Ian Murdock APT, or The Advanced Packaging Tool, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants.
YUM: configuration and usage /etc/yum.conf yum –h yum list |more yum info firefox yum search firefox yum deplistfirefox yum install mc yum remove mc mc check-update yum update yum clean all main configuration file Viewing yum options Listing installed packages Getting package descriptions Searching for packages Viewing package dependencies Install package Remove package Check for update for particular package Update all of the outdated packages Cleaning up the yum cache
YUM: repositories [root@centos ~]# ls /etc/yum.repos.d/ CentOS-Base.repoCentOS-Media.repo [root@centos ~]# cat /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever – Base baseurl=http://mirror.yandex.ru/centos/5.4/os/x86_64/ gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 [updates] name=CentOS-$releasever – Updates baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 User friendly name of repo Name of repo url to repos activity flag
apt - Advanced Package Tool • apt-get • apt-cache • apt-cdrom • aptitude
apt-get apt-get is a simple command line interface for downloading and installing packages. The most frequently used commands are update and install. • update - Retrieve new lists of packages • upgrade - Perform an upgrade • install - Install new packages (pkg is libc6 not libc6.deb) • remove - Remove packages • purge - Remove packages and config files • check - Verify that there are no broken dependencies
apt-cache apt-cache is a low-level tool used to manipulate APT's binary cache files, and query information from them. • showpkg - Show some general information for a single package • search - Search the package list for a regex pattern • show - Show a readable record for the package • depends - Show raw dependency information for a package • pkgnames – show all installed packages
apt-cdrom apt-cdrom is a tool to add CDROM's to APT's source list. The CDROM mount point and device information is taken from apt.conf and etc/fstab. • add - Add a CDROM • ident - Report the identity of a CDROM
Synaptic Package Manager aptitude Synaptic is high-level interface to the package manager
aptitude aptitude aptitude is high-level interface to the package manager
apt: repositories root@host-93:~# cat /etc/apt/sources.list deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic main restricted deb-srcftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic main restricted deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic universe deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic-security main deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic-security restricted deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic-updates main deb ftp://mirror.minsk.epam.com/pub/Ubuntu/ubuntu/ karmic-updates restricted url to repos type name of distr types of repos
Samba client 26
Kickstart root@ubuntu:~# apt-get install smbclient root@ubuntu:~# apt-get install smbfs root@ubuntu:~#smbclient -U name_surname -W minsk.epam.com -L 10.6.5.70 root@ubuntu:~#smbclient -U name_surname -W minsk.epam.com //EPBYMINW0777/upload root@ubuntu:~#mkdir /media/1/ root@ubuntu:~#smbmount //EPBYMINW0934.minsk.epam.com/upload /media/1/ -o user=name_surname,dom=minsk.epam.com root@ubuntu:~# ls /media/1/ you must specify existing share!!!
Boot sequence summary • BIOS • LILO or GRUB (boot loader) • Kernel (+ initrd) • init • Run Levels
Boot sequence summary: BIOS • Load boot sector from one of: • Floppy • CDROM • Hard drive • The boot order can be changed from within the BIOS settings.
Boot sequence summary: LILO or GRUB • Lilo (Linux loader) • does not understand filesystems • uses the BIOS routines to load • Loading sequence • load menu code, typically /boot/boot.b • prompt for (or timeout to default) partition or kernel • for "image=" option load kernel image • GRUB (GRandUnified Bootloader) • More advanced and commonly used • Understands file systems • config lives in /boot/grub/menu.lst or /boot/boot/menu.lst
Boot sequence summary: kernel • initialize devices • (optionally loads initrd) • mounts root filesystem • runs /sbin/init which is process number 1 (PID=1)
Boot sequence summary: initrd • initrd • is a temporary file system used by the Linux kernel during boot • typically used for making preparations before the real root file system can be mounted • initramfs – modern substitute for initrd
Boot sequence summary: /sbin/init • reads /etc/inittab(see man inittab) • Run boot scripts, eg for redhat/etc/rc.d/rc.sysinit which: • loads modules • check root FS and mount RW • mount local FS • setup network • mount remote FS • Switches to default runlevel, eg 3 (defined in /etc/inittab, eg: id:3:initdefault: ) • run scripts /etc/rc3.d/S* • run programs specified in /etc/inittab
Boot sequence summary: runlevels The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Differs for different UNIX systems and Linux distributives Red Hat Linux/Fedora runlevels
Managing init levels root@ubuntu:~# init 3 root@ubuntu:~#telinit 5 root@ubuntu:~#runlevel 3 5 current previous