Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Linux Servers:
Telnet Server SSH(Secure Shell) Server Apache(httpd) Server FTP(File Transfer Protocol) Server DNS(Domain Naming Server) DHCP(Dynamic Host Configuration Protocol) Server SQUID Proxy Server SAMBA Server
We will talk about the installation but before that before installation process let us look at some of the important things. These are:
Shell: In an operating system there is a special program called the shell. The shell accepts human readable commands and translates them into something the kernel can read and process. In Linux, there are various shells. Most common and most used are: BASH(Bourne-Again SHell) CSH(C Shell) KSH(Korn Shell) To find all the available shells in your system, use the following command: $ cat /etc/shells
INSTALLATION:
Here well discuss about the installation of Ubuntu. First of all GET UBUNTU. There are two ways you can get Ubuntu. One is that if you have a faster internet connection and a CD writer you can download its ISO file from
http://www.ubuntu.com/desktop/get-ubuntu/download and then write it on a CD. Get a free burner from http://download.cnet.com/Free-Easy-CD-DVD-Burner/3000-2646_4-10627009.html Or you can order it from its official website http://www.ubuntu.com
Install the FREE EASY BURNER and open it. And click on create an image, now follow the wizard. Keep the speed unchanged and finish the wizard. And when the wizard is finished. You are ready to go.
Now boot from this CD and start the installation. 1. Select the Install Ubuntu option.
5. On the next screen select the third option and click forward
7. Here, allocate the space you want Ubuntu to install on, and select Extended-4 file system (File systems will be discussed in the next article), and select / as mount point and click ok.
MOUNT POINT:
A mount point is a directory or file at which a new file system, directory, or file is made accessible.
8. Now select the free space which you have already specified for swap area and select swap area. There is no mount point for swap area. SWAP AREA: This is a virtual memory used to speed up the Linux processes.
We can format with any one of several different file systems: FAT File Allocation Table is the original, old 16 bit DOS system is probably used in 90% of all PCs. It is also called FAT16 contrary to: FAT32 This is a new addition to FAT, which Microsoft introduced with Windows 95 B the December 96 version (OSR2). The performance has been even improved with Windows 98. NTFS from Windows NT This is a 32 bit file system like HPFS, but not compatible with it. NTFS can only be used in Windows NT/2000/XP. If it was available for use in Windows 95/98, it may be preferable to FAT and FAT32. UNIX UNIX servers have their own file system. Here the use of upper/lower case in file naming is significant. Extended 2-3 and 4 are the main file systems Used in Linux. UFS, NFS and HSFS are also used. The file system is actually the interface between operating system and drives.
fdisk /mbr
TERMINALS IN LINUX:
There are 7 terminals in Ubuntu. Each terminal can be accessed by pressing [ctrl + alt (F1 to F7)]. All the terminals are command line and only one is with graphical interface which we use mostly. Different terminals are used by those
APT-GET COMMAND:
apt-get is the command-line tool for handling packages for Debian Linux which is use to: Install/manage individual packages Upgrade packages
10
Linux System Administration Apply security patch(s) Keep Debian system up to date Download source .deb files For example if you want to install wine after downloading it from the internet, you may write this command to complete the operation: apt-get install wine(version)
11
Linux System Administration find lpr date cal bc ls a ls l clear whoami date df h uname a vi nano gedit which ps echo ping ifconfig chgrp chsh username useradd userdel shutdown h now search for files in a directory hierarchy print files print or set the system date and time displays a calendar calculator to see the hidden files to list the file contents in long format to clear the screen in terminal prints out your login name prints out date used to tell you about the free space in your system(-h for Human Readable format) Prints out the name of UNIX OS you are using text editor text editor text editor To locate the exact path of a program, you can use the which command Show information about the active processes Used to display a message used to check out the connectivity between two devices shows the network interface cards configuration to change the group of a file to change shell of a user add a user delete a user shutting down the system
12
D:\Folder\subfolder\file.txt
In Linux, this is the basic format
/Folder/subfolder/file.txt Youll notice that the slashes are forward slashes in Linux versus backslashes in Windows. Also, there is no drive name (C:, D:, etc.) in Linux. At boot, the root partition is mounted at /. All files, folders, devices and drives are mounted under /. It is important to note that files and folders in Linux are case sensitive. The Directory Structure in UNIX & Linux are a unified Directory Structure where in all the directories are unified under the / Root file system. Irrespective of where the File System is physically mounted all the directories are arranged hierarchically under the Root file system. These are the main directories in LINUX.
/root:
The Directory Structure starts with the Root file system / and is indeed the root directory for the whole structure. The partition where / (the root directory) will be located on a UNIX or UNIX-compatible system.
/boot:
The /boot directory contains the Boot loader files including Grub or LILO, the Kernel, initrd and system.map config files.
/sys:
This contains the Kernel, Firmware and system related files.
/sbin:
This directory contains the essential System Binaries and System Administration tools essential for the system operation and performance.
/bin:
This directory contains the essential binaries for users and those utilities that are required in single user mode. Examples include cat, ls, cp etc.
13
/lib:
Contains the library files for all the binaries held in the /sbin & /bin directories .
/dev:
The /dev directory contains the essential system files and drivers.
/etc:
The /etc directory contain essential System configuration files including /etc/hosts, /etc/resolv.conf, nsswitch.conf, defaults and network configuration files. These are mostly host specific system and application configuration files.
/home:
All the user home directories are held under this directory with the exception of the root home directory which is kept under /root directory. This directory holds users files, personal settings like .profile etc.
/media:
This directory is a generic mount point for removable media like CD-ROM, USB, Floppies etc.
/mnt:
This directory is a generic mount point for temporary file systems. This comes handy particularly when troubleshooting from CDROM etc wherein you might have to mount the Root file system and edit configurations.
/opt:
This directory is a rarely used directory in Linux for Optional Software Packages. This is extensively used in UNIX OS like Sun Solaris where the software packages are installed.
/usr:
This directory is a sub hierarchy to the root file system which is a User data directory. It contains user specific utilities and applications. You will again see a lot of important but not critical file systems are mounted. Here you would again find a bin, sbin & lib directory which contains non-critical user and system binaries and related libraries and a share directory.
/var:
The /var directory is mostly mounted as a separate file system under the root where in all the variable content like logs, spool files for printers, mail, running process, lock files etc. Care has to be taken in planning this file system and maintenance as this can fill up pretty quickly and when the File System is full can cause system and application operational issues.
/temp:
This directory is a temporary file system which hold temporary files which are cleared at system reboot. There is also a /var/tmp directory which holds temporary files too. The only difference between the two is that /var/tmp directory holds files that are protected at system reboot. In other words, /var/tmp files are not flushed upon a reboot.
14
15
However, the password in /etc/passwd is stored as a single "x" character (i.e. not actually stored in this file). A second file, called /etc/shadow, contains encrypted password as well as other information such as account or password expiration values, etc. The /etc/shadow file is readable only by the root account and is therefore less of a security risk. With shadow passwords, the /etc/passwd file contains account information, and looks like this: Zaeem16:x:561:561:Zaeem Hassan:/home/Zaeem16:/bin/bash Each field in a passwd entry is separated with colon characters : and are as follows:
16
Now let us start adding users step by step: You want to create an account with the name Zaeem Type the command: adduser Zaeem
Now if you want to check out the details related to this user, you can go to the following directory and can view the details about the new user Zaeem. nano /etc/passwd
Now to give a password to this user use the following command and change the password: passwd Zaeem
17
Now finally if you want to see the detailed info about this user , go to the following directory and all the details will be visible over there: nano /etc/shadow
If you want to see the password policies related to users, go to this directory: cd /etc/login.def
To see all the groups on your system go to this directory: cat /etc/groups
Now suppose that you have a user Zaeem and there are two groups on the system, named students and the other one teachers. You want to ass this user to both of these groups. To do this, use the following command: useradd Zaeem G teachers, students
18
File Permissions:
To check the permissions for any file or directory in Linux, simply type the following command and you will get the permissions set on the files and directories: ls -l
drwerwerwe
There are a total of 10 characters in this example, as in all Linux files. The first character indicates the type of file, and the next three indicate read, write, and execute permission for each of the three user types, user, group and other. Following table will make you understand the concept of file permissions more clearly: The values for Read, Write and Execute are as follows: R=4 W=2 X=1
19
If there is a "-" in a particular location, there is no permission. This may be found in any field whether read, write, or execute field. Lets take an example: A user Zaeem created a directory named MyFile and the group to which this file belongs to is MyGroup. The size of the directory is 124 bytes, and the date created is 12 th April, 2010. Following is the illustration of the given example:
Now the question arises that how to change the permissions of a file/directory. Its simple. Use chmod command.
If you want to change the permissions for the file named Zaeem, so that only user can read and write it and group can only read it, following command will be used. chmod Zaeem u=rw, g+r
Before going towards the numerical configuration, you should understand the concept of umask. The umask command is used to set and determine the default file creation permissions on the system. It is the octal complement of the desired file mode for the specific file type. Default umask is 0022 .Default permissions are: 777 - Executable files 666 - Text files The permission for the creation of new executable files is calculated by subtracting the umask value from the default permission value for the file type being created. An example for a text file is shown with a default umask value of 022:
20
It means that a user can read and write the file, and group members and other users can only read the file. In Ubuntu the configuration file is placed in /etc/profile And in Red Hat it is located in /etc/bashrc
For example you want to zip a directory named MyDir and the tar name is MyDir.bkp, use the following command:
tar<space> cvf<space>MyDir.bkp<space>MyDir
And to untar the same file use the following command:
tar<space> xvf<space>MyDir.bkp
G-zip: This utility is used to zip a file/directory. Use the following to compress the directory named MyDir.tar:
gzip<space>MyDir.tar
21
tar<space>zxvf<space>MyDir.tar.gz
This is all about the tar and gzip concept.
Linux Servers:
This is an important section and the first server we are going to cover is telnet server. But before doing this let us study a command through which we will connect the two computers by giving the ip-address to the Linux machine. The command is:
22
When you type in this command, following screen will appear: Select the Network Configuration option.
Select the device and assign the ip address and the subnet mask and you are done. You have now given a static ip-address to your Linux Machine. Select ok and then restart the service by typing the following command:
Service network restart This will restart the service and now the server is assigned and configured with a static ip.
23
Now lets move towards the installation and proper configuration of different servers.
TELNET SERVER:
WHAT IS TELNET?
Telnet stands for Telecommunications Network. Telnet is based on the telnet protocol that provides the ability to connect to computers or servers over the Internet as well as having the ability to control remote UNIX based systems. Like most Internet applications and protocols telnet uses a standard port number, which in this case is port 23. However different telnet ports can be used by the server that the client is connecting to. Unlike most things, telnet has remained very much the same as it did when it was created and as such has a text based command driven interface, which may deter some but for those who appreciate it find telnet is a very useful tool. Although not widely used anymore, it is still convenient because some commands execute faster over telnet than over the Web or any other similar systems.
24
Start>Run and typing cmd.exe. A window with a black background will pop
up. In the command prompt, type telnet Internet name/IP address. For example: telnet professor.nyc.edu. Once connected, you will be prompted to supply your username and password.
IN LINUX:
In Linux operating system telnet utility is not installed by default. We have to install it by ourselves. There are two ways by which we can install TELNET in Linux.
25
One is by command line interface and one is using graphic user mode. Both the ways are easy. Let us discuss them one by one.
CLI
In CLI mode we go to Applications>Accessories>terminal.
Log in to ROOT account by using the following command. sudo su. You will be prompted to give the ROOT password. Once youre in the root account, download the Telnet package by typing in apt-get install telnetd The next screen will prompt you for the confirmation to the act. Press y and hit enter. The package will be downloaded and installed on your PC.
GUI:
In GUI mode go to: System>Administration>Synaptic Package Manager.
26
In the search tab, type telnetd. And download all the relative packages. This is the easiest way to install telnet.
First of all open the port number 23 to enable telnet services. This can be done by giving the following command: ufw allow 23
LOGGING IN LINUX:
Simply supply the necessary details and press enter. After being verified, you are then taken to the root directory of the machine you have just accessed. If you cant login, verify with your systems administrator that you have permission to access the server. Otherwise, you wont be able to use telnet for your intended purpose.
EXECUTING COMMANDS:
Once inside the machine, you can issue a variety of commands for the other machine to perform. For example, you can type ls l and press enter to see a list of files in the
27
current directory. You can also browse files, move them, rename them and copy them. A whole slew of other commands is available by typing ?/help. In Red
Hat:
Package name for telnet is telnet-server AND Service name is xinetd. The configuration files are placed in /etc/xinetd.d/telnet To switch on the From now onwards, red hat version of Linux will be used. So lets start configuring other servers on rhel5.
28