Professional Documents
Culture Documents
LINUX Redhat: Version - 9
LINUX Redhat: Version - 9
LINUX Redhat: Version - 9
Version 9
(Short Notes)
Prepared by:
Type of Accounts:
Shells
Limitations: Partitions:
LILO, GRUB (Recommended) Relative path: Absolute path: ext2 ext3 = = FAT 16 FAT 32 (NTFS)
File System:
Files or folder's name start with period(.) are hidden files or folders. is indication of installable / executable files (RPM means RedHat Package Manager) Make files with any commands, assign full permission and move to( /usr / local/bin ) folder for execution. crontab -e file is used for the purpose.
The LINUX FILE System: The LINUX is built around the concept of a file system, which is used to store all of the information that constitutes the long-term state of the system. This state includes the operating system kernel itself, the executable files for the commands supported by the OS, configuration infor, temp work files, user data, and various special files that are used to give controlled access to system hardware and operating system functions. LINUX file system belongs to one of four types of files: 1. ORDINARY files: These type of files contain text, data or program information. These files can not contain other files or directories. LINUX filenames are not broken into a name part and an extension part (although extensions are still used only for classification of files). Except special characters there can be up to 256 characters long. 2. DIRECTORIES files: 3. DEVICES files: Directories are used to store files and other sub-directories.
LINUX treats with devices as ordinary files instead of drives. There are two types of devices in LINUX. which transfer data in blocks(e.g. hard disks, CDs etc)
1.
Block-Oriented Devices:
2.
Character-Oriented Devices: which transfer data byte-by-byte basis (e.g modems and dumb terminals) Hard-Link Soft-Link = = Link to a file is indistinguishable from the file itself. Provide an indirect pointer or shortcut to a file.
4. LINKS:
Directory structure of Linux System: /root /boot /var /dev /bin home directory of root(administrator) Booting and startup information. Holding variable files (e.g LOG files) Device information and drivers etc. User based bin files (e.g. EXE files related users based software) /sbin = System based bin files (OS's files) /lib = Link files about user based EXE files (dll etc related to user bin) /home = contain separate folders for each users. /temp = contain files (temp) accessible to all users. /lost&found= holding accidentally corrupted files. /etc = configurations files of HW and Software (Most important directory) Minimum Hardware requirement for installation of Linux: Processor = P-I with 133 Mhz Ram = 08 MB for CLI and 16MB for GUI HDD = 02 GB for CLI and 03 GB for GUI CD = 8x INSTALLATION OF LINUX REDHAT VER.9. 2
Prepared by: CH. BASHIR AHMAD
= = = = =
For Installation of Linux. (Redhat on 3 CDs, or Fedora (a new version of Linux ) on 4 CDs is required) 1. 2. Insert Linux CD-1 (bootable) Select GUI or CLI mode (CLI is advised) Type = Linux Text
(press Enter)
3.
Type of installation: (1.Desktop 2.Client/ws 3.Server 4.Custom) Select Custom. Auto partitioning or Manual (Disk Druid) Select Manual (Disk Druid) partition. Firewall: (Monitor traffic for viruses etc.) Select Disabled Option. Mode selection: GUI or CLI Select CLI mode (which can be switched to GUI mode). Network option: 1. DHCP 2. Manual IP Select Manual IP Computer/Host name: Should be in small letter (due to case sen.) Partitioning:(compulsory) 1. Root partition 2. Swap partition Min. Swap(RAM/virtual) must be RAM x 2 Max 2GB for internet server etc. File system of SWAP is swap. File system of ext2 = FAT16 File system of ext3 = FAT32 (compulsory) Type / for Root Size in MB, 4000 MB (4 GB) Type nothing for 2nd partition (Not applicable) File Sys = SWAP # Size in MB 1000 MB (1 GB) 1. Selection of OS. 2. Reset Logon password Boot Loader: 1. GRUB Loader 3. LILO boot (Un Secure) 4. No boot Select GRUB option Leave Blank for Boot Loader Config. Use GRUB Password Boot Loader Password: redhat Confirm. redhat [ ] DOS = /dev/hda1 [*] RedHat Linux = /dev/hda8 (select/mark) 3
Prepared by: CH. BASHIR AHMAD
4.
5.
7.
8. 9. 10.
6.
[ ] F2 for selection of options /hda Master Boot Record (MBR) /dev/hda8 = First selection of boot partition. 7. Network configuration: [ ] use boot /dhcp [*] Active on boot.(select/mark) IP = 200.200.200.6 Netmask = 255.255.255.0 Host name = ws4 (any users defined computer name) Security Level = Select (NO Firewall) No Additional Languages. Clock. GMT = Select Asia/Karachi. Root password = Confirm = linux9 (must be different from GRUB pass) linux9 simply OK
8.
9. 10.
11. 12.
Authentication option =
13.
Packages Selection: [*] Admin Tools [*] DNS Name Server [*] Developing Tools (for database etc) [*] Editors [*] FTP Server [*] GNOM Desktop [*] Graphic Internet [*] Graphics [*] KDE Desktop Environment [*] Mail Server [*] Network Services [*] Office/Production [*] Printing Support [*] SQL Database Server [*] Server Config. Tools [*] Sound and Video [*] System Tools [*] Text Based Internet [*] WEB Server [*] Windows File Server [*] X-Software Development [*] X-Window System OK Log File / install/log will be created on root partition. Graphic Card Detection is processed.
LINUX COMMANDS:
Working in CLI mode. USER LOGIN:
[root@ws4root] #
[user ] [name] [Host] [Present] [name] [working] [directory]
[root@ws4root] # = '#' sign indicate that logged in have Administrator's rights. [root@ws4imran] $ = '$' sign indicate that logged in have User's right VIEW DIRECTORY CONTENTS: 1-
ls (list)
list of all file and directory will be listed like DIR Command. All files/directories will be displayed in different colour. Blue = Directory White = Files Green = EXE files ls (all files) ls filename.ext (specific file) ls abc*.txt (all files start with abc and having any extension) ls .txt (* matches all character) ls book?.* (? matches one character) ls | more (only down scroll) ls | less (up & down scroll) ls \* (not all files but files having asterisk in their names) ls \? -doquestion mark ls \) -dobracket ls -a (all files including hidden) hidden files and folders names start with dot (.) ls -lh displays files/folders with complete info. e.g. size etc. ls F File type, add a symbol at the end of each file. / indicate a directory, @ indicate symbolic link to another file, * indicate a executable file. ls r reverse. Lists the contents of the directory from back to front. Ls -R recursive. This option lists the contents of all directories below the current directory recursively. Ls S Size, Sort files by size. ls -l show detailed information of files/folders including permission etc. example mention below: -rw-r--r-1 root root 10048 Nov 23:00:35 abc.txt (common file) drwxr-xr-x 3 root root 4096 Dec 23:00:35 xyz (folder/directory) -rwxrwxrwx 3 imran imran 10048 Nov 23:00:35 editor (executable file) first means a common file first d means this is a folder/directory first l means this is a link file. 5
Prepared by: CH. BASHIR AHMAD
2.
dir
(display files in width wise all in white colour without distinction between files and folders etc.)
3. 4.
clear (to clear screen like cls in DOS) touch (to create a zero byte file.)
to create hidden file = touch abc.txt touch abc.txt (start with dot) mkdir xyz mkdir xyz (start with dot)
5.
mkdir
6.
logout
or
Ctrl+d
7.
cd
to change directory cd abc (change to abc directory/folder) cd / (come out from any depth of sub-directories to root) cd .. (come out one step back/up)
cd ../.. (come out two step up) cd ~ (return to your login directory) cd ~otheruser (take you to others login directory, if you are permitted) cd /home (take you to your home directory) cd /root (login to root directory, if you are permitted) 8. 9.
pwd (to display present working directory) cp (for copy file/files and folder) cp i (confirm overwritten ? ) cp -f (forcefully, do not display overwrite message) cp -v (verbose, display copying each file in progress) cp -fv (both switches together can be given.) cp -r abc xyz (abc folder will be copied in xyz folder including all files and sub folders/sub-directories.) cp -r abc/* xyz (copy all contents of abc folder in xyz folder, but not abc itself) cp -rfv abc/*.doc xyz (copy all files having .doc extension from abc to xyz folder) rm
rm i rm abc.txt rm -f abc.txt rm -r rm -r xyz rm -rf xyz (for Removing of files and folders) (confirm deletion ? ) (delete a single file) (delete file without confirmation) (delete a folder) (remove xyz folder) (delete xyz folder along with its files and sub-folders without confirmation)
10.
11.
mv (move/rename a file/folder) mv I (confirm overwritten ?) mv f (forcefully, do not display overwrite message) mv v (display progress) mv /abc/abc.txt /123/ (move file abc.txt from abc folder to 123 folder) mv /abc/abc.txt /123/xyz.doc (during move assign new name/rename)
(to find a file/files) find | -name "*.txt" (find all files having txt extension) find | -name "a*.d*" (find all files start with word a)
12.
find
12-a
file
(is used to display kind of file ) (will display ASCII Text) (also used to locate/find a file/folder) (is stand for concatenate/join the contents of different files)
locate cat
cat (to create / read / append / merge files) cat 123.txt (contents of 123.txt file will be displayed at once not page wise) cat 123.txt | less (display contents up and down ward page wise. The contents can be viewed by using up and down arrow) cat > xyz.doc (create xyz.doc file, now type any text/data and press Ctrl+D for save) cat abc.txt 123.doc (1. contents of abc.txt will be copied in 123.doc 2. Original data of 123.doc will be deleted. 3. 123.doc will be created auto if not already exists.) cat >> abc.txt (new typed data will be saved at the end of the file, any existing data will not be lost) cat abc.txt >> xyz.doc (contents of abc.txt will be appended at the end of contents of xyz.doc) 15.
more
more abc.txt
(view contents of files page wise only down ward scrolling allow)
16.
less
less abc.txt
(view contents of files page wise up and down ward scrolling allow)
17.
head
head abc.txt head -20 abc.txt
(to view top ten lines of file by default) (to view required top 20 of lines) (to view last 10 ten lines of file by default)
18.
tail
tail abc.txt tail -30 abc.txt
19.
(to view required last 30 lines) grep (to locate a line having required text from file) grep Govt. abc.txt (find the line having word Govt. from abc.txt file) grep Govt. abc.txt | lpr (search for particular file having required text and then result saved as a file or sent to a printer) 7
Prepared by: CH. BASHIR AHMAD
20.
(to display front end processing) ps -aux (to display front/back end processing) ps -aux | grep xinetd (display all process contained xinetd)
ps
21.
alias c = "clear" (assign clear command to c, now press c for clear screen
instead of clear command) alias abc = "vi /etc/passwd" (instead of typing a long command, just type abc & press enter to edit passwd file) NOTE: These aliases are temporary until rebooting the computer. For making permanent alias type these lines in /root/.bashrc file. e.g
vi /root/.bashrc (press enter) and type under mentioned lines: alias c = "clrar" alias b = "reboot" Save and exit from file. NOTE: These aliases are permanent for that user, not for all users
USER (CREATION/DELETION/MODIFICATION): 22. useradd imran (create a new user imran, useradd command will process four tasks: 1. create new user 2. assign id to user (id starts by 500, less than 500 is reserved) 3. assign group to user (by default his own name) 3. assign shell to user 4. create home folder for user. (by default create folder by users own name) Same home directory can be assigned to different/multiple users. useradd -u 600 imran (create user with custom user id i.e. 600 instead of by default) useradd -g sales imran (assign custom prim. group sales instead of by default of his own name) (assign home folder 'tech' instead of /home/imran by default) (assign C shell instead of bash Shell) (assign comments to user)
(or all above examples with one command) useradd -u 600 -g sales -d /opt/tech -s /bin/csh -c "Sales Dept" imran (press enter)
23.
24.
userdel
userdel imran userdel -r imran
(for deletion of user) (delete user imran but do not delete imran's home folder) (delete user imran and also his home folder etc.) (to assign or change a password)
25.
passwd imran
NOTE:
1. Password is compulsory for all users by default. 2. User cannot log on without assigning a password by default. 3. But it can be done by changing /etc/passwd file. (remove x and save file, now user can log on without password) (assigning password)
imrbsr imrbsr
OK
man (man command stands for Manual, it is used for display the detail
of any command) man ls (display complete help of ls command)
26-a. rpm (is used to install different software, installable files have .rpm extension) example: 27. rpm -ivh /mnt/cdrom/rhl-gsg-en-9.noarch.rpm
su
(command is used to work as root (superuser) temporarily, when you type su your logon by type roots password then the prompt change to # (superuser) instead of $(common user). When you finished working type exit to return to your original status ) (is used to print a file) lpr filename.ext
28.
lpr
29.
lpq
lpq
active root 389 abc.txt (in this case 389 is the print job) 30. 31. 32.
reset (is used to reset the terminal windows, it means that restore terminal
window, which was cleared by clear command) 9
Prepared by: CH. BASHIR AHMAD
33.
startx
OR
(is used to switch to graphical mode) or type (and press enter to enter the graphical mode)
init 5
34.
Ctr + Function Key (Ctrl+F2 or F3 and so on to switching between desktops) (Ctrl+F2 switch to Desktop2, and Ctrl+F3 for Desktop3) TEXT EDITOR ( VI ).
10
FLOPPY DRIVES:
mke2fs
(is used to create a Linux ext2 file system on a floppy/hard disk) On Linux system,
/sbin/mke2fs /dev/fd0
gfloppy
mount
(prepare to using CD) example: mount /mnt/cdrom using floppy: cd /mnt/cdrom (is used to spare CD) example: umount /mnt/cdrom/
umount
CD Creator:
Using X-CD-Roast: X-CD-Roast is a graphical application for duplicating and creating CDROMs. X-CD-Roast automates the process of burning CD-Rs and CD-RWs and is highly configurable to many CD copying or duplicating needs. Example: /usr/bin/xcdroast Using mkisofs The mkisofs utility creates ISO9660 image files that can be written to a CD-R(W). The images created by mkisofs can include all types of files. It is most useful for archival and file backup purposes. Suppose you wish to backup a directory called /home/joeuser/, but exclude the subdirectory /home/joeuser/junk/ because it contains unnecessary files. You want to create an ISO image called backup.iso and write it to CD-R(W) so that you can use it on your Red Hat Linux PC at work and your Windows laptop for trips. This can be done with mkisofs by running the following command: mkisofs -o backup.iso -x /home/joeuser/junk/ -J -R -A -V -v /home/joeuser/ 11
Prepared by: CH. BASHIR AHMAD
Option Function -o Specifies an output file name of the ISO image. -J Generates Joliet naming records; useful if the CD is used in Windows environments. -R Generates Rock Ridge (RR) naming records to preserve filename length and casing, especially for UNIX/Linux environments. -A Sets an Application ID a text string that will be written into the volume header of the image which can be useful to determine what applications are on the CD. -V Sets a Volume ID__ a name that is assigned to it if the image is burned, and the disc is mounted in Solaris and Windows environments. -v Sets verbose execution, which is useful for viewing the status of the image as it is being made. -x Excludes any directory immediately following this option; this option can be repeated. (for example, ... -x /home/joe/trash x /home/joe/delete ...).
USING CDRECORD
The cdrecord utility writes audio, data, and mixed-mode (a combination of audio, video, and/or data) CD-ROMs using options to configure several aspects of the write process, including speed, device, and data settings. To use cdrecord, you must first establish the device address of your CD-R(W) device by running the following command as root at a shell prompt:
cdrecord scanbus: This command shows all CD-R(W) devices on your computer. It is important to remember the device address of the device used to write your CD. The following is an example output from running cdrecord -scanbus.
Cdrecord 1.8 (i686-pc-linux-gnu) Copyright (C) 1995-2000 Jorg Schilling Using libscg version 'schily-0.1' scsibus0: 0,0,0 0) * 0,1,0 1) * 0,2,0 2) * 0,3,0 3) 'HP ' 'CD-Writer+ 9200 ' '1.0c' Removable CD-ROM 0,4,0 4) * 0,5,0 5) * 0,6,0 6) * 0,7,0 7) * To write the backup file image created with mkisofs in the previous section, switch to the root user and type the following at a shell prompt:
8 8 5 5 5 8
. ..
test.cfg test-data.cfg abc.txt newtext.txt
The result of ls l command is consist of following information about files/directories: Column Displayed values Description First drwxr-xr-x Permission Second 56,1 or any value User ID Third Root User name Forth Root Group name Fifth 4096 or size of file Size of Directory or File (4096 in case of Folder) Sixth Sep 8 23:35 Date and time of creation/up-dation of file/folder Seventh test.cfg File or Directory/folder name The detailed explanation of Columns:
(- - -)
(- - -)
(- - -)
| | | | type owner group others There are ten slots are in the column, explain below: First slot shows kind of file ( - means normal file, d means folder, l means symbolic link) Beyond the first slot, in each of three slots can have: (r = read, w = write, x = execution, if it is a program or directory) Second three slots have (rwx means = read, write & execute) permission for owner Third three slots have (rwx means = read, write & execute) permission for group Forth three slots have (rwx means = read, write & execute) permission for other users 13
Prepared by: CH. BASHIR AHMAD
-rw-rw-r--
1 root
root
abc.txt
In above example the owner and group have read and write permission(rw-), but other user have only read permission (r--). Now you want to permit other user to also write in the file and save it. Type this command: chmod o+w abc.txt | | others write permission Now you will see:
-rw-rw-rw-
1 root
root
abc.txt
Permissions can be provoked by using this command. chmod go-rw abc (provoke permission of read and write from group and users)
-rw- - - - - - - 1 root
Identities: Action:
root
abc.txt
(u = user/owner, g = group, o = others or a = all (u, g & o) (+ = Add, - = subtract or = makes it the only permission)
Remove all permission from all on the file abc.txt, type the following command. chmod a rwx abc.txt Remove execution permission on folder named bkup chmod a x bkup Now try to change the directory backup. cd bkup/ bash: bkup: Permission denied. By adding R (change permission for entire directory tree) Changing permission with numbers: Permission setting can be permitted by using numbers. (read =4, write=2, execute=1, 0=no permission)
14
(rw-)
| 4+2+0
(rw-)
| 4+2+0
(r- -)
| 4+0+0
The total number of user is (4+2=6), and the group is (4+2=6) and the other have (4+0=4) So the value permission is 664. Now try to provoke the permission of write from group, means subtract 2 from group value i.e. 6-2=4, now the value will be 4 instead of 6. type the following command: chmod 644 abc.txt
(rw-)
| 4+2+0
(r- -)
| 4+0+0
(r- -)
| 4+0+0
Here is a list of some common settings, numerical values and their meanings: -rw------- (600) Only the owner has read and write permissions. -rw-r--r-- (644) Only the owner has read and write permissions; the group and others have read only. -rwx------ (700) Only the owner has read, write, and execute permissions. -rwxr-xr-x (755) The owner has read, write, and execute permissions; the group and others have only read and execute. -rwx--x--x (711) The owner has read, write, and execute permissions; the group and others have only execute. -rw-rw-rw- (666) Everyone can read and write to the file. (Be careful with these permissions.) -rwxrwxrwx (777) Everyone can read, write, and execute. (Again, this permissions setting can be hazardous.) Here are some common settings for directories: drwx------ (700) Only the user can read, write in this directory. drwxr-xr-x (755) Everyone can read the directory; users and groups have read and execute permissions.
15
COMPRESSING THE FILES/FOLDERS: Linex have three powerful tools to compress the files and folders i.e gzip, bzip2 and zip utilities. The bzip2 compression tool is recommended because it provides the most compression and is used in most UNIX-like operating systems. The gzip compression tool can also be found on most UNIX like operating systems. If you need to transfer files between Linux and MS Windows, you should use zip because it is more compatible with the compression utilities on Windows. Compression Tool gzip bzip zip Example of bzip2: You can use bzip2 to compress multiple files and directories at the same time by listing them with a space between each one: bzip2 filename.bz2 file1 file2 file3 /usr/work/school The above command compresses file1, file2, file3, and the contents of the /usr/work/school directory (assuming this directory exists) and places them in a file named filename.bz2. To expand the compressed file, type the following command: File Extension .gz .bz2 .zip Un compression Tool gunzip bunzip2 unzip
bunzip2 filename.bz2
The filename.bz2 is deleted and replaced with filename. Example of gzip: To use gzip to compress a file, type the following command at a shell prompt:
gzip filename
The file will be compressed and saved as filename.gz.
gunzip filename.gz
The filename.gz is deleted and replaced with filename. You can use gzip to compress multiple files and directories at the same time by listing them with a space between each one:
16
Example of zip: To compress a file with zip, type the following command:
unzip filename.zip
You can use zip to compress multiple files and directories at the same time by listing them with a space between each one:
BACKING UP FILES/FOLDERS:
tar utility:
Some of the options used with the tar are: -c create a new archive. -f when used with the -c option, use the filename specified for the creation of the tar file. when used with the -x option, unarchive the specified file. -t show the list of files in the tar file. -v show the progress of the filesbeing archived. -x extract filesfrom an archive. -z compress the tar filewith gzip. -j compress the tar filewith bzip2. To create a tar _le, type:
18
EDITING PATH:
Start a text editor, such as gedit or vi, at a shell prompt. You can open the file called .bash_profile by typing the following:
gedit .bash_profile
You will see a PATH statement, similar to the one shown below.
PATH=$PATH:$HOME/bin:/usr/local/bin:
To the end of this statement, add $HOME/imran as shown below:
PATH=$PATH:$HOME/bin:/usr/local/bin/:$HOME/imran:
Save the file and exit the text editor. You can then make the changes to .bash_profile take effect immediately by typing the following command:
source .bash_profile
By adding paths to your .bash_profile, you can place utilities and programs in your path and be able to execute them without having to type ./ in front of the command.
19
mkdir /mnt/windows
Before you can access the partition, you will need to mount it in the directory you just created. As root, type the following command at a shell prompt (where /dev/hda1 is the Windows partition you found via Hardware Browser):
cd /mnt/windows
To automatically mount a Windows partition every time you boot your Red Hat Linux system, you must modify the /etc/fstab file, which configures all file systems and disk device mounting options. At a shell prompt, su to root, following the above example. Next, open the /etc/fstab in a text editor by typing (for example):
gedit /etc/fstab
Add the following on a new line (replacing /dev/hda1 with the Windows partition you found via Hardware Browser):
20
FORGOTTEN PASSWORD
You can log in using single-user mode and create a new root password. To enter single-user mode, reboot your computer. If you use the default boot loader, GRUB, you can enter single user mode by performing the following: 1. 2. At the boot loader menu, type [e] to enter into editing mode. You will be presented with a boot entry listing. Look for the line that looks similar to the following:
4.
sh-2.05#
5. You can now change the root password by typing
21
CHANGING CLI TO GRAPHIC MODE PERMANENT: Type the following command to amend the inittab file.
Vi /etc/inittab
The following information will display in editors windows; # Default run level. The run levels used by RHS are: # 0halt (Do NOT set init default to this) # 1Single user mode # 2Multi user, without NFS (The same as 3, if you do not have networking) # 3Full multi user mode # 4unused # 5XII # 6reboot (Do NOT set init default to this) # Id: 3: initdefault: . Amend carefully the line id:3:initdefault: to id:5:initdefault: save the file and reboot the
LOGGING OUT
(for logout )
23
SHORTCUT KEYS:
power off
CTRL+ALT+BKSPACE Shutdown the computer. Close the graphical desktop and return to logon screen, use only in case of normal exit is not working. Shutdown & reboot the system, use only in case of normal reboot/shutdown is not working. Ctrl+Alt+F1 to F6 keys are used to switching between different shells and F7 is used for Graphical Desktop. Switch between different open softwares. Logout (and close) shell prompt. This is equal to EXIT. Clear the terminal like clear command. Clear the current line while working in terminal Command Auto complete. Refresh the shell prompt screen.
CTRL+ALT+DEL
CTRL+ALT+FN
reset
24
exit
CONCEPT OF IPS:
The IP address or IP no consists of four parts: 000.000.000.000 Classes of IPs: (Range) From To 1 126 128 191 192 223 224 239 240 254
IP 127 is used for loop back testing or using for Virtual Network Card, which is not physically present in computer for windows. (MS Loop Adaptor 127.0.0.1)
Class E is reserved. Class D is used for multiple networks: The Box-1 (Ist three digits) indicates the Class of Networking. If the number in Box-1 is (from 128-191), it is a Class B network.
25
In the small networking the Network ID will be the same for all network and Host ID will be different for each computer. Box1 Box2 Box3 Box4 Class-C N N N Class-B N N H Class-A N H H
H H H
In the above table the Class A IP address, the numbers would present network, local, local, local and Calss C present network. network. network. local. The range of Class A is much bigger then Class B or C. The total numbers of computer can be attached with the networking class wise stated below:Computers 255 65025 16581375
Subnet mask is mentioned below Class wise. Class-C Class-B Class-A 255.255.255.0 255.255. 0.0 255. 0. 0.0
service network restart (or reboot system to use new IP) ifconfig
(now the new IP will appear) NETWORKING Configuration IPs, S.Masks : Enabling/Disbling Lan Card
Netconfig
is used to display:
ping 192.168.0.15
26
Prepared by: CH. BASHIR AHMAD
To use other computer name instead of IP, the following line should be added in following file. vi /etc/hosts add this line in file. 192.168.0.15 ws7 (other computers name, instead of IP) save the file. Now the computer name ws7 can be used instead of IP. ping ws7 To display IP address, submask and gateway address type: cat /etc/sysconfig/network-scripts/ifcfg-eth0 cat /etc/sysconfig/network (hotname or network IP)
27
MODEM installation:
The requirement of Linux is Hardware Modem instead of Win Modem/Software Modem. Hardware Modem is installed on COM1 or COM2 i.e. Physical Port for hardware modem. COM3, COM4 and COM5 etc are used for Win Modem/ Software modem. From Graphic Desktop select: System Setting -> Network -> New Modem -> Forward (checking modem) Select /dev/ttys0 Baud Rate: (COM1) 57600 (Speed)
Volume: ON / OFF Select Povider: Phone:___UserID___Password___-> (Forward) Activate Modem (PPPoE) from Network. (Point to Point Protocol over Ethernet) Now Modem is installed, Mozila (i.e. browser) can be used to access Internet.
28
/etc/dhcpd.conf
29
SERVERs:
DNS Server:
The DNS server is very important to use different servers via DNS server. It converts IPs address to Computer name and vice versa. Steps to configure DNS Server are stated below:
STEP-1:
vi /etc/named.conf Amend line 26. Zone localhost IN (in place of localhost type anyname.com) Zone anyname.com IN Line-32 give network ID in reverse order; 0.168.192 :wq! (save file and exit)
STEP-2:
cd /var/named vi /var/named/localhost.zone (forward lookup zone) $ORIGIN domain name. (type anyname.com in place of domain) Line-11 ID ws2 ID ftp ID www ID IN IN IN IN A 192.168.0.10 A 192.168.0.10 CNAME ws2 CNAME ws2 (Local server host)
:wq! (save file and exit) NOTE: Different computer name/address can be typed in case of different computers are used for different purpose i.e. www and ftp and so.
STEP-3:
vi /etc/named/named.local Line-2 localhost.root.domain.name (type anyname.com in place of localhost) Line-8 localhost.com (domain name) type anyname.com in place of localhost IN NS localhost. (No need of change) Add or modify these lines. 2 IN PTR domain.com. (anyname.com) 2 IN PTR ws2 :wq! (save file and exit) 30
Prepared by: CH. BASHIR AHMAD
STEP-4:
vi /etc/resolv.conf (this is a blank file) add these line in it. namedserver 192.168.0.10 (local host) domain anyname.com. :wq! (save file and exit) service named start (this service cannot restart)
To check the configuration of server, the following checks are required: nslookup check-1 > ws2 Server: Address: Name: Address: Check-2 (press enter) 127.0.0.2 127.0.0.1 # 53 anyname.com 192.168.0.10 (command is used to check configuration)
> 192.168.0.10
Server: Address: Name: Address: Check-3
> www
Server: Address: Name: Address: Check-4
> ftp
Server: Address: Name: Address:
The above mentioned results should be displayed and verify their configuration.
31
Now the server can be accessed by using these commands. ftp://192.168.0.10 (Access comp. by using IP) ftp://anyname.com (By comp. name instead of IP) http://www.anyname.com http://192.168.0.10 (Access by using comp. name) (By using IP instead of name)
The following files will be used for configuration of DNS Server: vi vi vi vi /etc/named.conf /var/named/localhost.zone /var/named/named.local /etc/resolve.conf (For activation of DNS Server)
Separate Computer for each server is necessary for large users, however, one computer can be used to create different server on it for small or limited users. In case of separate computer, IP address of each computer will be differed from each other but the gateway address will be the same. By using single computer for all servers, the IP address and Gateway will be the same.
32
SAMBA Server:
The following steps are required to create SAMBA Server.
Step-1:
Create Folder in / root partition. e.g testdata.
(Go to end of file & add these lines) (User defined sharing string, which will be displayed on window client) Path = /testdata (folder name) Writable = YES (to break read only attribute). Optional ValidUsers = user1 user2 (user list that can access) Optional Logfile = /var/log/samba/sm.log (History File) Optional Hostsall = 192.168.1. space 192.168.2. space (allow restricted hosted) :wq! (save file and exit) [mytestdata]
33
Step-4:
Now go to Windows based network computer: Select Start -> Run (type linux computers IP e.g.) \\192.168.0.10 (press enter) Logon screen of Linux Computer will be appeared: User ID: bashir User Password: ****** After verifying the password, the two folders will be displayed: Shared folder i.e. mytestdata Users personal folder bashir Now the folders from samba server side are enable to store/retrieve data.
34
FTP Server:
The File Transfer Protocol Server is called FTP Server. The DNS Server must be configured and started before using FTP Server. The under mentioned step are being made to configure FTP Server:
Step-1:
Copy some files in the /var/ftp/pub/ , every file or folder in the place are shared. Now configure the FTP server configuration file.
Step-2:
vi /vsftpd/vsftpd.conf Line-7 Anonymous enable = YES (enable and allow other users) Line-10 Local enable = NO (Local user do not allow) Line-26 Anon_mkdir_write_enable = YES (Allow to create folder) Line-36 Connect_from_post_20 = YES (in case of more load) Line-52 Idle_Session_timout = 600 :wq! (save file and exit)
Step-3:
useradd abcd password abcd
ftp://abcd@192.168.0.10
35
Step-1:
Server ends: mkdir datafile (make folder on root directory ) vi /etc/exports(this is blank file,add following line) /datafile (rw) (make datafile read & write) :wq! (save file and exit)
36
Step-1:
Copy some HTML page in to /var/www/html folder (index.html or default.html should be there or any html file can be used as default html)
37
Step-1:
vi /etc/squid/squid.conf line-53 http_port 3128 (replace 80 with 3128) line-666 cache_dir ufs/var/squid 100.16.256 (enable line only) add following line: line-1732 acl askaria src 192.168.0.1 / 255.255.255.0 (anyname) (host IP) (submask) http-access allow askaria (allow or deny access) (or deny) line-1923 cache-mgr 123@123.com (already # none) line-1955 visible_hostname (servername) :wq! (save file and exit)
Step-2:
service squid start (Start SQUID Service)
Step-5:
On windows side set LAN Setting: 192.168.0.1 Port: 80 *******************
setup (and select system services then mark [*] required service start automatic (autostart).
38
DHCP Server
DNS Server
SQUID/PROXY Server
39