0% found this document useful (0 votes)
107 views

Foss Lab Manual Final

The document provides instructions for installing Linux using Red Hat and configuring basic settings. It outlines 14 steps for installing Red Hat Linux, including inserting the DVD, selecting keyboard/display options, partitioning the disk, setting the root password, and rebooting. It then explains 9 post-installation configuration steps, such as accepting the license, configuring the firewall, sound, and creating a non-admin user. The document also provides details about basic Linux shell commands for file manipulation, general system information, and navigation.

Uploaded by

Balraj E
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

Foss Lab Manual Final

The document provides instructions for installing Linux using Red Hat and configuring basic settings. It outlines 14 steps for installing Red Hat Linux, including inserting the DVD, selecting keyboard/display options, partitioning the disk, setting the root password, and rebooting. It then explains 9 post-installation configuration steps, such as accepting the license, configuring the firewall, sound, and creating a non-admin user. The document also provides details about basic Linux shell commands for file manipulation, general system information, and navigation.

Uploaded by

Balraj E
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 75

M KUMARASAMY COLLEG OF ENGINEERING

(AUTONOMOUS)

THALAVAPALAYAM ,KARUR – 639 113.

DEPARTMENT OF INFORMATION TECHNOLOGY

REGULATIONS : 2018

YEAR / SEM : IV / VII

SUBJECT CODE : 18ITC402L

“FOSS LAB MANUAL “

Staff In Charge : Mr.E.Balraj Asst.Professor / IT


Dr.V.Ramasamy ASP/IT
Ms.R.Elankeerthana AP/IT
Ms.R.Vinotha AP/IT
Ex.No:1 LINUX INSTALLATION

Aim:

To write procedure to perform linux installation.

Procedure:

Step 1 – Insert the Red Hat Linux DVD into the DVD-drive of your computer. As soon as the
following screen pops up, press ‘Enter’ to install Red Hat Enterprise Linux (RHEL) through GUI
mode.

Step 2- RHEL installer would then prompt you conduct a check as to whether the CD media from
which you’re installing is functioning correctly or not. Choose ‘Skip’, press enter and the installation
would begin.

Step 3- Next, we need to select the language- English or any other language as per your
preference, and then press ‘Next’ .
Step 4- In this step, the RHEL installer would ask you about the appropriate type of keyboard for the
system. We take the ‘US English’ keyboard, you can pick any other option depending on the type of
your keyboard. Then press ‘Next’ to move to the next step.

Step 5- Next, the installer would ask for an ‘installation number’ if you wish to install full set of Red
Hat functionalities. Enter the installation number and press ‘OK’ if you have an officially licensed
installation number(for corporate clients that buy Red Hat’s backup support and full features).

Others can select ‘Skip entering installation number’ and press ‘OK’ to proceed. RHEL would show a
warning message, press ‘Skip’ in it to continue.
Step 6- The Red Hat installer would then require you to create partitions in your computer’s hard
disk for the installation. You can do it in four ways but the simplest way is to select ‘Use free space
on selected drives and create default layout’ as this option will not affect any other OS residing in
your system.

Check the ‘review and modify portioning layout’ to create partitions and click next.

Step 7- In this step you must create the required system partitions and mount points such as ‘/boot’,
‘/home’, ‘swap’ etc which are required for the Linux’s proper functioning.

To create different partitions such as /home, /var etc, click on ‘New’ to create the partitions.
Then, select /home in the mount point and choose ‘ext3’ as the file system and give the desired size
for it and then click ‘OK’. Similarly also create /boot and /var.

Also, create a swap partition by clicking on ‘New’ and then choosing the filesystem as ‘swap’ and
also give the size of Swap partition.(Usually size of swap partition SHOULD BE twice the size of
RAM available to the system but you can keep its size less than that too)
Once you have made all the desired partitions and given their mount points, click ‘Next’ to continue
installation.

Step 8- This step pertains to the default OS that will be loaded by the GRUB loader
(Note- If you have multiple Operating Systems installed, you would see multiple options here and
you have to check in front of the OS name that you want to be loaded by default when the system is
started.)

Click ‘Next’ to continue.

Step 9- This step pertains to the network settings of the Linux system that you are going to install.
You can select the Ethernet devices through which the system would communicate with other
devices in the network.

You can also provide the hostname, Gateway address and DNS address to the system during this
step. (However it’s better to adjust these settings once the system has been fully installed).

Step 10- The next step is to adjust the system clock to your particular time zone. Select your time
zone and then click ‘Next’.
Step 11 – This is a very important step that deals with the root(super-user) password for the
system . Type the password and confirm it and then click next.

Step 12 – The RHEL installer would then prompt you about if you wish to install some extra
‘Software Development’ or ‘Web Server’ features. By default, keep it at ‘Customize later’ and press
‘Next’.
 

Step 13- This next step will initiate the installation of Red Hat Linux, press ‘Next’ to begin the
process.

Step 14- Upon the completion of installation you should the following screen. Press Reboot and
you’d be ready to use your newly installed Red Hat Linux OS.
POST INSTALLATION CONFIGURATIONS

1. Accept the Red Hat License agreement and click ‘Forward.

2. The next step is regarding the configuration of the Firewall. You can Enable or Disable the firewall
according to your preferences and then click ‘Forward’.
3. Next step is about the configuration of another security tool- SE Linux. By default you should keep
it ‘Disabled’ unless you’re working with very secure information.

4. You can also choose to configure the Kdump, that stores information about system crashes if your
system fails but uses valuable disk space. By default don’t enable it.

5. Next, adjust the time and date settings, and then click ‘Forward’.
6. The next step is for software updates from Red Hat, at this point you should skip the registration
and register at a later time and then click ‘Forward’.

7. This step is to create a non-admin user for the system. Enter the details and click ‘Forward’.

8. This step is about configuration of your Sound Card, choose a sound device and then click
‘Forward’.
9. Click ‘Forward’ to complete the configurations and start using your Red Hat Linux OS.

(Note- On clicking ‘Finish’ the system would require a reboot if you have made changes to the
configurations of Firewall or SE Linux.)

Your Red Hat Linux OS is now all installed and configured, ready to be used. Good luck using
and exploring various features of Red Hat Linux.

Result:

Thus the above linux installation was done successfully and the

result was verified,


Ex.NO:2 BASIC SHELL COMMANDS

A im

To Study about basic Unix Commands.

FILE MANIPULATION COMMANDS

Command : Cat

Purpose : It is used to display the contents of the file as well as used to create a new
file.

Syntax : cat <file name

> Example : $ cat devi

Command : More

Purpose : It is used to display the contents of the file on the screen at a time.

Syntax : more <file name

> Example : $ more devi

Command : Wc
Purpose : It is used to count the number of lines ,words and characters in a file or group

of files.

Syntax : wc [options] <file name >

Example : $ wc –l devi

Command : File

Purpose : It is used to determine the type of the file.

Syntax : file <file name >

Example : $ file devi

Command : Spell

Purpose : It is used to find the spelling errors in the file.

Syntax : spell [options] <file name >

Example : $ spell -b devi


Command : Split

Purpose : It is used to split the given file into smaller pieces of given size.

Syntax : split –size <file name > < splitted file name >

Example : $ split –2 devi de

Command : Cp

Purpose : It is used to copy one or more files.

Syntax : cat <source file name > <destination file name>

Example : $ cp devi latha

Command : Mv

Purpose : It is used to move a file within a directory with different names and also

used to move a file to different directory with its original name.

Syntax : mv <source file name > <destination file name>

Example : $ mv devi jeya

Command : Rm

Purpose : It is used to remove a file from the disk.

Syntax : rm <file name >

Example : $ rm devi

GENERAL PURPOSE COMMANDS

Command : Banner

Purpose : It is used to display its argument in large letters.

Syntax : banner < string >

Example : $ banner BOOM

Command : Who

Purpose : It is used to get the information about all the users currently working in the
system.

Syntax : who

Example : $ who

Command : Who am i

Purpose : It is used to know in which terminal the user is currently logged on.

Syntax : who am i

Example : $ who am I

Command : Date

Purpose : It is used to display the system date and time.

Syntax : date

Example : $ date

Command : Cal

Purpose : It prints the calender for the specified year and month.

Syntax : cal <month> <year>

Example : $ cal 05 2003

Command : Id

Purpose : It is used to display the login name.

Syntax : id

Example : $ id
Command : Clear

Purpose : It is used to clear the screen.

Syntax : clear

Example : $ clear

Command : Tput

Purpose : It is used to manipulate the screen.

Syntax : tput < attributes >

Example : $ tput rmso

Command : Uname
Purpose : It is used to display the details about the OS in which we are working.
Syntax : uname [options]
Example : $ uname –n

Command : Tty

Purpose : It is used to know the terminal name on which we work.

Syntax : tty

Example : $ tty

Command : Pwd

Purpose : It is used to display the absolute pathname of current working directory.

Syntax : pwd

Example : $ pwd

Command : Bc

Purpose : It is used to perform simple mathematical calculations.

Syntax : bc <operation>
Example : $ bc 3+5 8 ^d

Command : Ls

Purpose : It is used to display the files in the current working directory.

Syntax : ls [options] <arguments>

Example : $ ls –p

Command : Echo

Purpose : It echoes the argument on the standard output device.

Syntax : echo [options] <string>

Example : $ echo ‘BOOM’

Command : Man

Purpose : It gives details about the unix commands.

Syntax : man < command name >

Example : $ man echo


COMMAND GROUPING & FILTER COMMANDS

Command : Head

Purpose : It is used to display the top portion of the file.

Syntax : head [options] <file name>

Example : $ head -5 devi

Command : Tail

Purpose : It is used to display the bottom portion of the file.

Syntax : tail [options] <file name >

Example : $ tail –5 devi

Command : Pr

Purpose : It is used to display the contents of the file by separating them into pages and

each page begins with the header information.

Syntax : pr [options] <file name >

Example : $ pr devi

Command : Cut

Purpose : It is used to extract selected fields or columns from each line of one or more

files and display them on the standard output device.

Syntax : cut [options] <file name >

Example : $ cut –c5 devi

Command : Paste

Purpose : It concatenates the line from each input file column by column with tab

characters in between them.

Syntax : paste [options] <file name >

Example : $ paste f1 f2

Command : Join

Purpose : It is used to extracts common lines from two sorted files and there should be the

common field in both file.

Syntax : join [options] <file name1 > <file name 2>


Example : $ join –a1 f1 f2

Command : Uniq

Purpose : It compares adjacent lines in the file and displays the output by

eliminating duplicate adjacent lines in it.

Syntax : uniq [options] <file name >

Example : $ uniq -c devi

Command : Sort

Purpose : It sorts one or more files based on ASCII sequence and also to merge the file.

Syntax : sort [options] <file name >

Example : $ sort -r devi

Command : Nl

Purpose : It is used to add the line numbers to the file.


Syntax : nl [options] [filename]

Example : $ nl devi

Command : Tr

Purpose : It is used to translate or delete a character or a string from the standard input

to produce the required output.

Syntax : tr [options] <string1> <string2>

Example : $ tr –t ‘a’ ‘b’ < devi>

Command : Tee

Purpose : It is used to read the contents from standard input or from output of another

command and reproduces the output to boyh in standard output and direct

into output to one or more files.

Syntax : tee [options] <file name >

Example : $ tee date dat.txt

Command : grep

Purpose : It is used to search the specified pattern from one or more files.

Syntax : grep [options] <pattern> <file name >


Example : $ grep “anand” devi

PROCESS MANAGEMENT COMMANDS

Command : mkdir

Purpose : It is used to create new directory or more than one directory.

Syntax : mkdir <directory name >

Example : $ mkdir riya

Command : rmdir

Purpose : It is used to remove the directory if it is empty.

Syntax : rmdir <directory name >

Example : $ rmdir riya

Command : cd

Purpose : It is used to change the control from one working directory to another

specified directory.

Syntax : cd <directory name >

Example : $ cd riya

Command : cd ..

Purpose : It is used to quit from current directory and move to the previous

directory.

Syntax : cd ..

Example : $ cd ..

Process Commands

Command : echo $$

Purpose : It is used to display the process number of the current shell.

Syntax : echo $$

Example : $ echo $$
Command : ps

Purpose : It is used to display the attributes of a process.

Syntax : ps

Example : $ ps

$ ps –f ( Display the ancestry of a process )

$ ps –u ( Display the activities of a user )

$ ps –a ( Lists processes of all users but not the system processes )

Command :&

Purpose : It is shell operator which is used to run a process in the background.

Syntax : <command> &

Example : $ sort emp.txt &

Command : nohup

Purpose : It permits the execution of the process even after the user has logged out.

Syntax : nohup <command>

Example : $ nohup sort emp.txt ( result is available on nohup.out )

Command : kill

Purpose : It is used to terminate the process.

Syntax : kill <PID>

Example : $ kill 105

Command : kill $!

Purpose : $! is the system variable which stores the process id of the last background job.

The command kill $! is used to kill the last process.

Syntax : kill $!

Example : $ kill $!

Command : at

Purpose : It is used to execute the process at the time specified.


Syntax : echo <time>

Example : $ at 14:08 (or) $ at 3 PM (or) $ at 4 :50 AM

Result:

Thus the above basic shell commands are studied and the output was verified.
Ex.No : 3

USER & GROUP MANAGEMENT,FILE OWNERSHIP & PERMISSIONS

AIM:

To write linux commands to create a new User & Group

PROCEDURE:

3.1. Introduction to Users and Groups

While users can be either people (meaning accounts tied to physical users) or accounts which exist for
specific applications to use, groups are logical expressions of organization, tying users together for a
common purpose. Users within a group can read, write, or execute files owned by that group.
Each user is associated with a unique numerical identification number called a user ID (UID). Likewise,
each group is associated with a group ID (GID). A user who creates a file is also the owner and group
owner of that file. The file is assigned separate read, write, and execute permissions for the owner, the
group, and everyone else. The file owner can be changed only by root, and access permissions can be
changed by both the root user and file owner.
Additionally, Red Hat Enterprise Linux supports access control lists (ACLs) for files and directories which
allow permissions for specific users outside of the owner to be set. For more information about this feature,
refer to the Access Control Lists chapter of the Storage Administration Guide.

3.1.1. User Private Groups

Red Hat Enterprise Linux uses a user private group (UPG) scheme, which makes UNIX groups easier to
manage. A user private group is created whenever a new user is added to the system. It has the same
name as the user for which it was created and that user is the only member of the user private group.
User private groups make it safe to set default permissions for a newly created file or directory, allowing
both the user and the group of that user to make modifications to the file or directory.
The setting which determines what permissions are applied to a newly created file or directory is called a
umask and is configured in the /etc/bashrc file. Traditionally on UNIX systems, the umask is set to 022,
which allows only the user who created the file or directory to make modifications. Under this scheme, all
other users, including members of the creator's group, are not allowed to make any modifications. However,
under the UPG scheme, this “group protection” is not necessary since every user has their own private
group.

3.1.2. Shadow Passwords

In environments with multiple users, it is very important to use shadow passwords provided by the shadow-
utils package to enhance the security of system authentication files. For this reason, the installation program
enables shadow passwords by default.
The following is a list of the advantages shadow passwords have over the traditional way of storing
passwords on UNIX-based systems:

 Shadow passwords improve system security by moving encrypted password hashes from the world-
readable /etc/passwd file to /etc/shadow, which is readable only by the root user.
 Shadow passwords store information about password aging.
 Shadow passwords allow the /etc/login.defs file to enforce security policies.

Most utilities provided by the shadow-utils package work properly whether or not shadow passwords are
enabled. However, since password aging information is stored exclusively in the /etc/shadow file, any
commands which create or modify password aging information do not work. The following is a list of utilities
and commands that do not work without first enabling shadow passwords:

 The chage utility.


 The gpasswd utility.
 The usermod command with the -e or -f option.
 The useradd command with the -e or -f option.

3.2. Using the User Manager Tool

 The User Manager application allows you to view, modify, add, and delete local users and groups
in the graphical user interface. To start the application, either select System → Administration →
Users and Groups from the panel, or type system-config-users at a shell prompt. Note that unless
you have superuser privileges, the application will prompt you to authenticate as root.

3.2.1. Viewing Users and Groups

 The main window of the User Manager is divided into two tabs: The Users tab provides a list of
local users along with additional information about their user ID, primary group, home directory,
login shell, and full name. The Groups tab provides a list of local groups with information about
their group ID and group members.

Figure 3.1. Viewing users and groups


 To find a specific user or group, type the first few letters of the name in the Search filter field and
either press Enter, or click the Apply filter button. You can also sort the items according to any of
the available columns by clicking the column header.
 Red Hat Enterprise Linux reserves user and group IDs below 500 for system users and groups. By
default, the User Manager does not display the system users. To view all users and groups, select
Edit → Preferences to open the Preferences dialog box, and clear the Hide system users and
groups checkbox.

3.2.2. Adding a New User

 To add a new user, click the Add User button. A window as shown in Figure 3.2, “Adding a new
user” appears.

Figure 3.2. Adding a new user

 The Add New User dialog box allows you to provide information about the newly created user. In
order to create a user, enter the username and full name in the appropriate fields and then type the
user's password in the Password and Confirm Password fields. The password must be at least
six characters long.
 Password security advice
 It is advisable to use a much longer password, as this makes it more difficult for an intruder to guess
it and access the account without permission. It is also recommended that the password not be
based on a dictionary term: use a combination of letters, numbers and special characters.
 The Login Shell pulldown list allows you to select a login shell for the user. If you are not sure
which shell to select, accept the default value of /bin/bash.
 By default, the User Manager application creates the home directory for a new user in
/home/username/. You can choose not to create the home directory by clearing the Create home
directory checkbox, or change this directory by editing the content of the Home Directory text box.
Note that when the home directory is created, default configuration files are copied into it from the
/etc/skel/ directory.
 Red Hat Enterprise Linux uses a user private group (UPG) scheme. Whenever you create a new
user, a unique group with the same name as the user is created by default. If you do not want to
create this group, clear the Create a private group for the user checkbox.
 To specify a user ID for the user, select Specify user ID manually. If the option is not selected, the
next available user ID above 500 is assigned to the new user. Because Red Hat Enterprise Linux
reserves user IDs below 500 for system users, it is not advisable to manually assign user IDs 1–
499.
 Clicking the OK button creates the new user. To configure more advanced user properties, such as
password expiration, modify the user's properties after adding the user.

3.2.3. Adding a New Group

To add a new user group, select Add Group from the toolbar. A window similar to Figure 3.3, “New Group”
appears. Type the name of the new group. To specify a group ID for the new group, select Specify group
ID manually and select the GID. Note that Red Hat Enterprise Linux also reserves group IDs lower than
500 for system groups.

Figure 3.3. New Group

Click OK to create the group. The new group appears in the group list.

3.2.4. Modifying User Properties

To view the properties of an existing user, click on the Users tab, select the user from the user list, and click
Properties from the menu (or choose File → Properties from the pulldown menu). A window similar to
Figure 3.4, “User Properties” appears.
Figure 3.4. User Properties

The User Properties window is divided into multiple tabbed pages:

 User Data — Shows the basic user information configured when you added the user. Use this tab
to change the user's full name, password, home directory, or login shell.
 Account Info — Select Enable account expiration if you want the account to expire on a certain
date. Enter the date in the provided fields. Select Local password is locked to lock the user
account and prevent the user from logging into the system.
 Password Info — Displays the date that the user's password last changed. To force the user to
change passwords after a certain number of days, select Enable password expiration and enter a
desired value in the Days before change required: field. The number of days before the user's
password expires, the number of days before the user is warned to change passwords, and days
before the account becomes inactive can also be changed.
 Groups — Allows you to view and configure the Primary Group of the user, as well as other groups
that you want the user to be a member of.

3.2.5. Modifying Group Properties

 To view the properties of an existing group, select the group from the group list and click Properties
from the menu (or choose File → Properties from the pulldown menu). A window similar to
Figure 3.5, “Group Properties” appears.
Figure 3.5. Group Properties

 The Group Users tab displays which users are members of the group. Use this tab to add or
remove users from the group. Click OK to save your changes.

3.3. Using Command Line Tools

The easiest way to manage users and groups on Red Hat Enterprise Linux is to use the User Manager
application as described in Section 3.2, “Using the User Manager Tool”. However, if you prefer command
line tools or do not have the X Window System installed, you can use command line utilities that are listed in
Table 3.1, “Command line utilities for managing users and groups”.

Table 3.1. Command line utilities for managing users and groups

Utilities Description

useradd, usermod,
Standard utilities for adding, modifying, and deleting user accounts.
userdel

groupadd, groupmod,
Standard utilities for adding, modifying, and deleting groups.
groupdel

gpasswd Standard utility for administering the /etc/group configuration file.

Utilities that can be used for verification of the password, group, and associated
pwck, grpck
shadow files.

Utilities that can be used for the conversion of passwords to shadow passwords, or
pwconv, pwunconv
back from shadow passwords to standard passwords.
3.3.1. Adding a New User

To add a new user to the system, typing the following at a shell prompt as root:

useradd [options] username


…where options are command line options as described in Table 3.2, “useradd command line options”.

By default, the useradd command creates a locked user account. To unlock the account, run the following
command as root to assign a password:

passwd username
Optionally, you can set password aging policy. Refer to Red Hat Enterprise Linux 6 Security Guide for
information on how to enable password aging.

Table 3.2. useradd command line options

Option Description

comment can be replaced with any string. This option is generally used to specify the full
-c 'comment'
name of a user.

-d home_director
Home directory to be used instead of default /home/username/.
y

-e date Date for the account to be disabled in the format YYYY-MM-DD.

Number of days after the password expires until the account is disabled. If 0 is specified,
-f days the account is disabled immediately after the password expires. If -1 is specified, the
account is not be disabled after the password expires.

Group name or group number for the user's default group. The group must exist prior to
-g group_name
being specified here.

List of additional (other than default) group names or group numbers, separated by
-G group_list commas, of which the user is a member. The groups must exist prior to being specified
here.

-m Create the home directory if it does not exist.

-M Do not create the home directory.

-N Do not create a user private group for the user.

-p password The password encrypted with crypt.

-r Create a system account with a UID less than 500 and without a home directory.

-s User's login shell, which defaults to /bin/bash.


Option Description

-u uid User ID for the user, which must be unique and greater than 499.

3.3.2. Adding a New Group

To add a new group to the system, type the following at a shell prompt as root:
groupadd [options] group_name
…where options are command line options as described in Table 3.3, “groupadd command line options”.

Table 3.3. groupadd command line options

Option Description
When used with -g gid and gid already exists, groupadd will choose another unique
-f, --force
gid for the group.
-g gid Group ID for the group, which must be unique and greater than 499.
-K, --key key=value Override /etc/login.defs defaults.
-o, --non-unique Allow to create groups with duplicate.
-p,
Use this encrypted password for the new group.
--password password
-r Create a system group with a GID less than 500.

3.3.3. Creating Group Directories

System administrators usually like to create a group for each major project and assign people to the group
when they need to access that project's files. With this traditional scheme, file managing is difficult; when
someone creates a file, it is associated with the primary group to which they belong. When a single person
works on multiple projects, it becomes difficult to associate the right files with the right group. However, with
the UPG scheme, groups are automatically assigned to files created within a directory with the setgid bit set.
The setgid bit makes managing group projects that share a common directory very simple because any files
a user creates within the directory are owned by the group which owns the directory.
For example, a group of people need to work on files in the /opt/myproject/ directory. Some people are
trusted to modify the contents of this directory, but not everyone.

1. As root, create the /opt/myproject/ directory by typing the following at a shell prompt:

mkdir /opt/myproject

2. Add the myproject group to the system:

groupadd myproject

3. Associate the contents of the /opt/myproject/ directory with the myproject group:

chown root:myproject /opt/myproject


4. Allow users to create files within the directory, and set the setgid bit:

chmod 2775 /opt/myproject


At this point, all members of the myproject group can create and edit files in the /opt/myproject/ directory
without the administrator having to change file permissions every time users write new files. To verify that
the permissions have been set correctly, run the following command:
~]# ls -l /opt
total 4
drwxrwsr-x. 3 root myproject 4096 Mar 3 18:31 myproject

File permissions and ownership on Linux


The usual file types are:
 Directory – associated symbol d
 Normal file – associated symbol - (minus, dash)
 Symbolic link (symlink) (like a shortcut on Windows) – associated symbol l

Permission types:

 Reading – associated symbol r, or number 4


 Writing – associated symbol w, or number 2
 Executing (running) – associated symbol x, or number 1
 No permission – associated symbol -, or number 0

User types:

 User – the user name of the owner of the file or directory; if a user creates a file or directory it
becomes the owner of that file of directory.
 Group – a group of users (ftp, mysql), all group members have the same rights for the file or
directory.
 Other – all users that do not own the file or directory and they do not belong to any group that has
right for the file or directory

Setting permissions:

You can set the permissions using the chmod command. There two methods for changing file permissions:

 Symbolic mode
 Numeric mode

Symbolic mode

Setting the permissions is made using the associated symbols – rwx.

Actions are defined using mathematical symbols: the + (plus) symbol is used to add a permission, the -
(minus) symbol is used to remove a permission, and the = (equal) symbol is used to remove the old
permission and set a new one.

For the owners, associated symbols are u for user, g for group, o for others (the rest) and a for all.

1. To make a file executable type in a console:


chmod +x myfile

2. To remove the write permissions of the group:

chmod g-w myfile

Numeric mode

Instead of symbols, the associated number are used for setting permissions. The number for each owner
will be the sum of the permissions for that owner.

To set the reading, writing and execution rights for the user you use the number 7 (4+2+1); to set the
reading and writing rights for group will you use the number 6 (4+2); the reading permission for the rest
(others) will be set using number 4.

The command for setting the permissions in numeric mode:

1chmod 764 myfile

Here is the association between numbers and letters:

0  |  ---
11  |  --x
22  |  -w-
33  | 
4-wx
54  |  r--
65  |  r-x
76  |  rw-
87  | 
rwx

Changing the owner:

It is done using the command chown.

1. To change the owner:

chown myusername myfile

2. To change the group and the owner:

chown mygroup:myowner myfile

3. To change only the group you use the command chgrp:

Chgrp group myfile


Result:

Thus the above experiment was done successfully and the result was verified.

Ex.NO: 4 CONFIGURATION OF NETWORK

Aim:

To Configuring the networking, basics of TCP/IP networking and routing , connection to the internet
(through dialup, DSL, Ethernet, leased line) in linux.
Procedure:

1. The NetworkManager Daemon

The NetworkManager daemon runs with root privileges and is usually configured to start up at boot time.
You can determine whether the NetworkManager daemon is running by entering this command as root:
~]# service NetworkManager status
NetworkManager (pid 1527) is running...
The service command will report NetworkManager is stopped if the NetworkManager service is not
running. To start it for the current session:
~]# service NetworkManager start
Run the chkconfig command to ensure that NetworkManager starts up every time the system boots:
~]# chkconfig NetworkManager on

2. Interacting with NetworkManager

Users do not interact with the NetworkManager system service directly. Instead, you can perform network
configuration tasks via NetworkManager's Notification Area applet. The applet has multiple states that
serve as visual indicators for the type of connection you are currently using. Hover the pointer over the
applet icon for tooltip information on the current connection state.

Figure 8.1. NetworkManager applet states

If you do not see the NetworkManager applet in the GNOME panel, and assuming that the
NetworkManager package is installed on your system, you can start the applet by running the following
command as a normal user (not root):

~]$ nm-applet &
After running this command, the applet appears in your Notification Area. You can ensure that the applet
runs each time you log in by clicking System → Preferences → Startup Applications to open the Startup
Applications Preferences window. Then, select the Startup Programs tab and check the box next to
NetworkManager.

2.1. Connecting to a Network

When you left-click on the applet icon, you are presented with:

 a list of categorized networks you are currently connected to (such as Wired and Wireless);
 a list of all Available Networks that NetworkManager has detected;
 options for connecting to any configured Virtual Private Networks (VPNs); and,
 options for connecting to hidden or new wireless networks.

If you are connected to a network, its name is presented in bold typeface under its network type, such as
Wired or Wireless. When many networks are available, such as wireless access points, the More
networks expandable menu entry appears.
2.2. Configuring New and Editing Existing Connections

Next, right-click on the NetworkManager applet to open its context menu, which is the main point of entry
for interacting with NetworkManager to configure connections.

Ensure that the Enable Networking box is checked. If the system has detected a wireless card, then you
will also see an Enable Wireless menu option. Check the Enable Wireless checkbox as well.
NetworkManager notifies you of network connection status changes if you check the Enable Notifications
box. Clicking the Connection Information entry presents an informative Connection Information window
that lists the connection type and interface, your IP address and routing details, and so on.
Finally, clicking on Edit Connections opens the Network Connections window, from where you can
perform most of your network configuration tasks. Note that this window can also be opened by running, as
a normal user:
~]$ nm-connection-editor &

Figure 8.4. Configure networks using the Network Connections window


There is an arrow head symbol to the left which can be clicked to hide and reveal entries as needed. To
create a new connection, click the Add button to view the selection list, select the connection type and click
the Create button. Alternatively, to edit an existing connection select the interface name from the list and
click the Edit button.

2.3. Connecting to a Network Automatically

For any connection type you add or configure, you can choose whether you want NetworkManager to try to
connect to that network automatically when it is available.

Procedure 8.1. Configuring NetworkManager to Connect to a Network Automatically When Detected

1. Right-click on the NetworkManager applet icon in the Notification Area and click Edit
Connections. The Network Connections window appears.
2. Click the arrow head if necessary to reveal the list of connections.
3. Select the specific connection that you want to configure and click Edit.
4. Check Connect automatically to cause NetworkManager to auto-connect to the connection
whenever NetworkManager detects that it is available. Uncheck the checkbox if you do not want
NetworkManager to connect automatically. If the box is unchecked, you will have to select that
connection manually in the NetworkManager applet's left-click menu to cause it to connect.

2.4. User and System Connections

NetworkManager connections are always either user connections or system connections. Depending on
the system-specific policy that the administrator has configured, users may need root privileges to create
and modify system connections. NetworkManager's default policy enables users to create and modify user
connections, but requires them to have root privileges to add, modify or delete system connections.
User connections are so-called because they are specific to the user who creates them. In contrast to
system connections, whose configurations are stored under the /etc/sysconfig/network-scripts/ directory
(mainly in ifcfg-<network_type> interface configuration files), user connection settings are stored in the
GConf configuration database and the GNOME keyring, and are only available during login sessions for the
user who created them. Thus, logging out of the desktop session causes user-specific connections to
become unavailable.

Increase security by making VPN connections user-specific

Because NetworkManager uses the GConf and GNOME keyring applications to store user connection
settings, and because these settings are specific to your desktop session, it is highly recommended to
configure your personal VPN connections as user connections. If you do so, other Non-root users on the
system cannot view or access these connections in any way.
System connections, on the other hand, become available at boot time and can be used by other users on
the system without first logging in to a desktop session.
NetworkManager can quickly and conveniently convert user to system connections and vice versa.
Converting a user connection to a system connection causes NetworkManager to create the relevant
interface configuration files under the /etc/sysconfig/network-scripts/ directory, and to delete the GConf
settings from the user's session. Conversely, converting a system to a user-specific connection causes
NetworkManager to remove the system-wide configuration files and create the corresponding
GConf/GNOME keyring settings.
Depending on the system's policy, you may need root privileges on the system in order to change whether a
connection is user-specific or system-wide.

1. Right-click on the NetworkManager applet icon in the Notification Area and click Edit
Connections. The Network Connections window appears.
2. If needed, select the arrow head (on the left hand side) to hide and reveal the types of available
network connections.
3. Select the specific connection that you want to configure and click Edit.
4. Check the Available to all users checkbox to ask NetworkManager to make the connection a
system-wide connection. Depending on system policy, you may then be prompted for the root
password by the PolicyKit application. If so, enter the root password to finalize the change.

Conversely, uncheck the Available to all users checkbox to make the connection user-specific.

3. Establishing Connections

3.1. Establishing a Wired (Ethernet) Connection

To establish a wired network connection, Right-click on the NetworkManager applet to open its context
menu, ensure that the Enable Networking box is checked, then click on Edit Connections. This opens the
Network Connections window. Note that this window can also be opened by running, as a normal user:

~]$ nm-connection-editor &
You can click on the arrow head to reveal and hide the list of connections as needed.

Figure 8.6. The Network Connections window showing the newly created System eth0 connection

The system startup scripts create and configure a single wired connection called System eth0 by default on
all systems. Although you can edit System eth0, creating a new wired connection for your custom settings
is recommended. You can create a new wired connection by clicking the Add button, selecting the Wired
entry from the list that appears and then clicking the Create button.
Figure 8.7. Selecting a new connection type from the "Choose a Connection Type" list

The dialog for adding and editing connections is the same

When you add a new connection by clicking the Add button, a list of connection types appears. Once you
have made a selection and clicked on the Create button, NetworkManager creates a new configuration file
for that connection and then opens the same dialog that is used for editing an existing connection. There is
no difference between these dialogs. In effect, you are always editing a connection; the difference only lies
in whether that connection previously existed or was just created by NetworkManager when you clicked
Create.

3.2. Establishing a DSL Connection

This section is intended for those installations which have a DSL card fitted within a host rather than the
external combined DSL modem router combinations typical of private consumer or SOHO installations.

Adding a New DSL Connection

You can configure a new DSL connection by opening the Network Connections window, clicking the Add
button and selecting DSL from the Hardware section of the new connection list.

1. Right-click on the NetworkManager applet icon in the Notification Area and click Edit
Connections. The Network Connections window appears.
2. Click the Add button.
3. The Choose a Connection Type list appears.
4. Select DSL and press the Create button.
5. The Editing DSL Connection 1 window appears.

Editing an Existing DSL Connection

You can configure an existing DSL connection by opening the Network Connections window and selecting
the name of the connection from the list. Then click the Edit button.

1. Right-click on the NetworkManager applet icon in the Notification Area and click Edit
Connections. The Network Connections window appears.
2. Select the connection you wish to edit and click the Edit button.

Configuring the Connection Name, Auto-Connect Behavior, and Availability Settings


Three settings in the Editing dialog are common to all connection types:

 Connection name — Enter a descriptive name for your network connection. This name will be used
to list this connection in the DSL section of the Network Connections window.
 Connect automatically — Check this box if you want NetworkManager to auto-connect to this
connection when it is available. Refer to Section 8.2.3, “Connecting to a Network Automatically” for
more information.
 Available to all users — Check this box to create a connection available to all users on the system.
Changing this setting may require root privileges. Refer to Section 8.2.4, “User and System
Connections” for details.

Configuring the DSL Tab


Username

Enter the user name used to authenticate with the service provider.

Service

Leave blank unless otherwise directed.

Password

Enter the password supplied by the service provider.

Saving Your New (or Modified) Connection and Making Further Configurations
Once you have finished editing your DSL connection, click the Apply button and NetworkManager will
immediately save your customized configuration. Given a correct configuration, you can connect to your
new or customized connection by selecting it from the NetworkManager Notification Area applet.
Figure 8.8.  Editing the newly created Wired connection System eth0

Configuring the Wired Tab


The final three configurable settings are located within the Wired tab itself: the first is a text-entry field where
you can specify a MAC (Media Access Control) address, and the second allows you to specify a cloned
MAC address, and third allows you to specify the MTU (Maximum Transmission Unit) value. Normally, you
can leave the MAC address field blank and the MTU set to automatic. These defaults will suffice unless you
are associating a wired connection with a second or specific NIC, or performing advanced networking. In
such cases, refer to the following descriptions:

MAC Address

Network hardware such as a Network Interface Card (NIC) has a unique MAC address (Media
Access Control; also known as a hardware address) that identifies it to the system. Running the ip
addr command will show the MAC address associated with each interface. For example, in the
following ip addr output, the MAC address for the eth0 interface (which is 52:54:00:26:9e:f1)
immediately follows the link/ether keyword:

~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN
qlen 1000
link/ether 52:54:00:26:9e:f1 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.251/24 brd 192.168.122.255 scope global eth0
inet6 fe80::5054:ff:fe26:9ef1/64 scope link
valid_lft forever preferred_lft forever
A single system can have one or more NICs installed on it. The MAC address field therefore allows
you to associate a specific NIC with a specific connection (or connections). As mentioned, you can
determine the MAC address using the ip addr command, and then copy and paste that value into
the MAC address text-entry field.
The cloned MAC address field is mostly for use in such situations were a network service has been
restricted to a specific MAC address and you need to emulate that MAC address.

MTU

The MTU (Maximum Transmission Unit) value represents the size in bytes of the largest packet that
the connection will use to transmit. This value defaults to 1500 when using IPv4, or a variable
number 1280 or higher for IPv6, and does not generally need to be specified or changed.

Saving Your New (or Modified) Connection and Making Further Configurations
Once you have finished editing your wired connection, click the Apply button and NetworkManager will
immediately save your customized configuration. Given a correct configuration, you can connect to your
new or customized connection by selecting it from the NetworkManager Notification Area applet.

Result:

Thus the above experiment was done successfully and the result was verified.
Ex.No:5 PERFORMING EVERYDAY TASKS

Aim:

To write procedure to perform the following tasks using GUN/Linux


i. Playing music,
ii. Editing documents and spreadsheets,
iii. Sending and receiving email,
iv. Copy files from disks and over the network
v. Playing games
vi. Writing CDs.

Procedure:

1.How to Play Music:

1. Launch the terminal (Ctrl + Alt +T) type the command below and strike enter:

sudo apt-get install sox

2. Input your password and  hit enter.

3. Type “y” without quotes and hit enter.


 

4.  After installation has been completed, run the command below to make SoX play .mp3 and other audio
file formats.

sudo apt-get install sox libsox-fmt-all

5. After the installation is done. Now you are ready to play any audio file from any directory.

 6. To play all .mp3 files in any directory, change directory and use this command:

play *mp3
 

7. To play a specific file, type play file-name.extension

eg: play Aqua_Barbie_Girl.mp3 will play only this file

8. To play next track Press Ctrl + c once and to stop or quit player, Press Ctrl  and hit c twice.

9. For more about Sox , type man sox in the terminal and hit enter.

2.How to Send & Receive Email:

a) mail: send and receive mail

b) from: print names of those who have sent mail

c) mutt: Mutt is a small but very powerful text based program for reading electronic mail under UNIX
operating systems, including support color terminals, MIME, and a threaded sorting mode.
d) pine: Yet another text based program for reading electronic mail under UNIX operating systems.
Originally written for inexperienced users, Pine's basic features are generally very easy to use.

(i) Check for mail / print names of those who have sent mail

The from utility prints out the mail header lines from the invoker’s mailbox.
$ from

Task: Read mail

Mail is an intelligent mail processing system:


$ mail

In normal usage mail is given no arguments and checks your mail out of the post office, then prints out a
one line header of each message found. The current message is initially the first message (numbered 1)
and can be printed using the print command (which can be abbreviated ‘p’). You can move among the
messages much as you move between lines in ed, with the commands ‘+’ and ‘-’ moving backwards and
forwards, and simple numbers.

After examining a message you can delete message by typing d


You can reply message by typing r
The message can be undeleted u by giving its number, or the mail session can be aborted by giving the exit
x command.

(ii) Compose mail

Use following format:


mail -s <subject> <mailaddress>

For example write mail to [email protected]:


$ mail - "Hello" [email protected]
You are then expected to type in your message, followed by an ‘control-D’ at the beginning of a
line. To stop simply type dot (.):
Output:

Hi,
This is a test
.
Cc:

(iii) Mail a whole text file

Mail a whole text file called demo.txt to [email protected]:


$mail -s "Report 05/06/07" [email protected] < demo.txt

You can also type mutt or pine to read and send mail:
$ mutt
(iv) Sending Email With Attachments From Unix / Linux Command [ Shell Prompt ]

If you need to send an email with a text file (or binary file) as attachment using shell script or command
prompt in Unix or Linux; try mutt - a terminal-based e-mail client for Unix-like systems.

Mutt is a small but very powerful text based program for reading electronic mail under UNIX /Linux operating
systems, including support for color terminals, MIME, and a threaded sorting mode.

Please note that mutt is a pure MUA and cannot send e-mail without proper email server . You need a
working Mail Transfer Agent (MTA) such as sendmail or postfix. I am assuming that you have a working
email server in your office.

How do I install mutt email client?

If mutt is not installed, use the apt-get or yum or up2date commands as follows (you must login as a root
user). Debian / Ubuntu Linux user type the following command to install mutt client:
# apt-get install mutt
Fedora / CentOS or Red Hat Enterprise Linux (RHEL) user type following command to install mutt:
# yum install mutt
OR (RHEL version <= 4 )
# up2date mutt
FreeBSD user type the following command to install mutt via pkg_add command:
# pkg_add -v -r mutt

How do I send email attachments from a command prompt?

Use mutt command as follows to send an email with attachment:


$ mutt -s "Test mail" -a /tmp/file.tar.gz [email protected] < /tmp/mailmessage.txt
Where,

[email protected] - is the recipient.


 /tmp/mailmessage.txt - is the main body of the e-mail (read message from the file
"mailmessage.txt").
 -a /tmp/file.tar.gz - is an attachment.
 -s "Test mail" - is a subject line.

3. Copy files from disks and over the network

(i)SCP Introduction

scp stands for secure cp (copy), which means you can copy files across ssh connection. That connection
will be securely encrypted, it is a very secure way to copy files between computers

You can use scp to copy files from or to a remote server. You can also copy files from one remote server to
another remote server, without passing traffic through your PC.

You can use scp on Linux, Mac and Windows (using WinSCP).

SCP Usage
scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
from-host

Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host
where you are actually issuing the command

user

Is the user which have the right to access the file and directory, that is supposed to be copied in the
case of the from-host, and the user who has the rights to write in the to-host

source-file

Is the file or files that are going to be copied to the destination host, it can be a directory but in that
case you need to specify the -r option to copy the contents of the directory

destination-file

Is the name that the copied file is going to take in the to-host, if none is given all copied files are
going to keep its names

SCP Options

-p

Preserves the modification and access times, as well as the permissions of the source-file in the
destination-file

-q

Do not display the progress bar

-r

Recursive, so it copies the contents of the source-file (directory in this case) recursively

-v

Displays debugging messages

SCP Examples

scp *.txt [email protected]:/home/user/

That is going to copy all files with .txt extension to the folder /home/user in the remote.server.com host

scp -r [email protected]:/home/miguel/ [email protected]:/home/miguel/

That is going to recursively copy all files from Miguel’s home directory on 10.1.2.2 to his home folder in
10.1.2.3 host.
As have been told before, scp copies files between computers using ssh, and there are three types of
usage:

(ii) Copy files from a local computer to a remote computer

scp somefile username@server:/home/username/

(iii) Copy files from a remote server to your local computer

scp username@server:/home/username/file_name /home/local-username/file-name

(iv) Copy files from a remote server to another remote computer

This is really interesting and very useful, as the files copied from one server to the other, are not going to
pass through your computer. The traffic is going to pass from one server to the other directly.

scp user_name1@server1:/home/user_name1/file_name user_name2@server2:/home/user_name2/

(v) Bandwidth limit

You may limit the bandwidth used by scp command

scp -l limit username@server:/home/uername/* .

Where limit is specified in Kbit/s.

(vi) Increase scp speed

scp uses AES-128 to encrypt data, this is very secure, but also a litle bit slow. If you need more speed and
still have security, you can use Blowfish or RC4.

To increase scp speed change chipher from the default AES-128 to Blowfish

scp -c blowfish user@server:/home/user/file .

Or use RC4 which seems to be the fastest

scp -c arcfour user@server:/home/user/file .

This last one is not very secure, and it may not be used if security is really an issue for you. You can also
increase security while decreasing speed. Everything has its cost.

scp -c 3des user@server:/home/user/file .

That is maybe the slowest, but also maybe the more secure one (I may be wrong, I’m not an expert in
encryption).

4.How To Play Music?


Installing PlayOnLinux depends on what distribution you use, these details are found on the downloads
page. After PlayOnLinux has been installed, you should find it under "Games" in most distributions, here
own under KDE3.

If you are unable to locate it in the menus, you may try to launch it using the command "playonlinux" from a
terminal window. If this fails it is probably not correctly installed and you should consult the download
instructions again.

PlayOnLinux main window

When you first start PlayOnLinux, you will find that the main screen is rather empty. That is because most of
the space is reserved for the list of application that are installed, which are currently none. In order to nstall
applications, click the Install button.

The installer dialog

The install dialog allows you to select an application either by navigating through the categories listed on the
left, or through the search bar located at the top of the dialog.
After you have located the application you want, you must first select it in the list and then click "Apply".

Once you have clicked apply, the application specific installer is launched. Unless you are installing a patch
to an existing application, most installers will begin with a presentation of the application. Following that it
will create the PlayOnLinux directory for this application's files.
After this point several things could happen - the installer may begin downloading, it may ask for a setup file,
it may ask for the CD-ROM of the game depending on what the game needs to do. This will depend
completely on the application and what is scripted for it. Some examples are included below as illustration
At some point, PlayOnLinux will launch the application's native Windows installer. Since the form is
completely up to the application, there is no example but you must navigate through this yourself. What is
important is that scripts may need to modify this installation after it has completed, so please install to the
default directory using the default options unless you have been instructed otherwise. After the installer has
finished, PlayOnLinux will present a shortcut dialog of its own. Please select the options you want.
Running an application

At this point PlayOnLinux will tell you that the installation is finished, and you will return to the main window.
The application you installed will have been added to the list. To run this application, simply select the
application from the list and click run. You can also double-click the application instead, or you can launch it
from the desktop or regular menu if you chose to install those shortcuts.

Removing an application

To remove an application, simply select it in the list and click Remove. Note that while the application and all
its files and registry settings are deleted, currently PlayOnLinux may not remove all shortcuts to the
application.
5.WRITING IN CD

To create a DVD from which to install an up-to-date copy of Ubuntu, you first need to download a copy of
the latest version. Once you’ve done so, you can create your installation DVD. The procedure may differ
slightly depending on which version of Ubuntu you are currently using.

1. Insert a blank CD into your burner. A 'CD/DVD Creator', 'Choose Disc Type' or 'Blank Disc' window
might pop up. Close this, because we will not be using it.

2. Look for the downloaded ISO file in the file browser.

3. Right click on the ISO file and choose 'Write to Disc'.


4. Where it says 'Write disc to', you might have options such as 'File image' as well as your CD drive.
Choose your CD drive. Your CD drive might show as something like 'BD-MLT UJ-210S'.

5. Select the write speed. If you are burning an Ubuntu Live CD (one that you may want to start your
computer up from), it is recommended that you write at the lowest possible speed.
6. Start the burning process.
7. After burning is completed, verify that your CD contains multiple files and folders and not just the
ISO file. This way you will know the process was completed correctly.
Result:

Thus the above experiment was successfully completed and the result was verified.

Ex.No:6 Setting UP Web Server

Aim:

To write procedure to setup web server for http services, printer services, proxy services.

Procedure:

1. Installing Apache:

Getting apache onto your Ubuntu machine is easy. Using either the Synaptic Package Manager,
Ubuntu Software Center, search and install the “apache2” module. Alternatively, you can open a
terminal and type the following command:

sudo apt-get install apache2


Once the installation finished, open a browser and go to the URL “http://localhost“. If you see the

word “It Works!“, then your installation of apache is successful.


2. Configuring Apache

Start, Stop and Restart Apache

After you have installed Apache, it will be added to the init.d list and will auto start whenever you
boot up your computer. The following commands allow you to start, restart, stop Apache.

sudo /etc/init.d/apache2 start #start apache


sudo /etc/init.d/apache2 stop #stop apache
sudo /etc/init.d/apache2 restart #restart apache

To prevent Apache from autostart when booting up:

sudo update-rc.d -f apache2 remove

To restore Apache back to the autostart list:

sudo update-rc.d apache2 defaults

Note: the above commands will work in debian-based distro (including Ubuntu) only.

3.Changing the default localhost folder

By default, apache will operate on the “/var/www” folder. This means that whatever files you place
in this /var/www folder will be visible from the URL http://localhost. In some instances, you may
want the “localhost” to point to another folder instead, say /home/user/public_html. Here is how
you do it:

First, make sure the /home/damien/public_html folder exists. Create a simple html file, name it
index.html and place it in the public_html folder.
Open a terminal and type:

gksu gedit /etc/apache2/sites-enabled/000-default

Change DocumentRoot /var/www to DocumentRoot /home/user/public_html.

Change <Directory /var/www/> to <Directory /home/user/public_html/>.

Save and exit the file.

Restart the apache

sudo /etc/init.d/apache2 restart

Now, in your browser, reload the URL http://localhost. You should see the html file that you have
placed in the public_html folder.
4.Configuring different sites

The above trick allows you to change the default operating folder of apache, however, some of you
might not want to override the default settings. An alternative is to create multiple sites and point
apache to the active site.

Create a new settings file for your new site.

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site1

Next, edit this settings file.

gksu gedit /etc/apache2/sites-available/site1

Change DocumentRoot /var/www to DocumentRoot /home/user/public_html.

Change <Directory /var/www/> to <Directory /home/user/public_html/>.

Save and exit the file.

Disable the default setting and make active the site1 settings

sudo a2dissite default && sudo a2ensite site1

Lastly, restart the apache.

sudo /etc/init.d/apache2 restart

With this trick, you can create multiple site configuration file, each pointing to a different folder.
You can then easily switch between the sites with the a2dissite and a2ensite command
Enabling .htaccess file

.htaccess file is a powerful file that can be used to control and customize a site server behavior
without editing the core Apache module. By default, the .htaccess functionality is turned off and all
instances of .htaccess files are completely ignored. The server will not even attempt to read
.htaccess files in the filesystem.

To enable .htaccess file, open up the settings file that you have created earlier:

gksu gedit /etc/apache2/sites-available/site1

Scroll down the file until you see the part “<Directory /home/user/public_html/>“.
Underneath that line of code, change AllowOverride None to AllowOverride All.
Result:

Thus the above experiment was done successfully and the result was verified.

7.QT Programs

Aim:

To write simple program using QT Programming for the following.

a)Creating a new window


b)Creating a new notepad

C)Layout Management

Procedure :

1.Open The new Terminal window in linux or CTRL+ALT+T.

2.Create a new directory& change the directory.

mkdir dirname

chdir dirname

3.Open the editor to type the program by using gedit editor.

Gedit filename.cpp

4. Save the file & exit

5. For compilation, do the following steps in Shell prompt.

qmake – project

qmake

make

6. Execute the program by using the command

./filename

Program:

A.Creating Window

#include <QtGui>

int main(int argc, char *argv[])


{
QApplication app(argc, argv);
QWidget window;
window.resize(320, 240);
window.show();
window.setWindowTitle(
QApplication::translate("toplevel", "Top-level widget"));
return app.exec();
}

Output:
B.Creating a new simple notepad

#include <QtGui>

int main(int argv, char **args)


{
QApplication app(argv, args);
QTextEdit *textEdit = new QTextEdit;
QPushButton *quitButton = new QPushButton("&Quit");

QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));

QVBoxLayout *layout = new QVBoxLayout;


layout->addWidget(textEdit);
layout->addWidget(quitButton);

QWidget window;
window.setLayout(layout);

window.show();

return app.exec();
}
Output:
C. Layout Management

#include <QtGui>

#include "dialog.h"

Dialog::Dialog()
{
createMenu();
createHorizontalGroupBox();
createGridGroupBox();
createFormGroupBox();

bigEditor = new QTextEdit;


bigEditor->setPlainText(tr("This widget takes up all the remaining space "
"in the top-level layout."));

buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok


| QDialogButtonBox::Cancel);

connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));


connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

QVBoxLayout *mainLayout = new QVBoxLayout;


mainLayout->setMenuBar(menuBar);
mainLayout->addWidget(horizontalGroupBox);
mainLayout->addWidget(gridGroupBox);
mainLayout->addWidget(formGroupBox);
mainLayout->addWidget(bigEditor);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);

setWindowTitle(tr("Basic Layouts"));
}

void Dialog::createMenu()
{
menuBar = new QMenuBar;

fileMenu = new QMenu(tr("&File"), this);


exitAction = fileMenu->addAction(tr("E&xit"));
menuBar->addMenu(fileMenu);

connect(exitAction, SIGNAL(triggered()), this, SLOT(accept()));


}

void Dialog::createHorizontalGroupBox()
{
horizontalGroupBox = new QGroupBox(tr("Horizontal layout"));
QHBoxLayout *layout = new QHBoxLayout;

for (int i = 0; i < NumButtons; ++i) {


buttons[i] = new QPushButton(tr("Button %1").arg(i + 1));
layout->addWidget(buttons[i]);
}
horizontalGroupBox->setLayout(layout);
}

void Dialog::createGridGroupBox()
{
gridGroupBox = new QGroupBox(tr("Grid layout"));
QGridLayout *layout = new QGridLayout;

for (int i = 0; i < NumGridRows; ++i) {


labels[i] = new QLabel(tr("Line %1:").arg(i + 1));
lineEdits[i] = new QLineEdit;
layout->addWidget(labels[i], i + 1, 0);
layout->addWidget(lineEdits[i], i + 1, 1);
}

smallEditor = new QTextEdit;


smallEditor->setPlainText(tr("This widget takes up about two thirds of the "
"grid layout."));
layout->addWidget(smallEditor, 0, 2, 4, 1);

layout->setColumnStretch(1, 10);
layout->setColumnStretch(2, 20);
gridGroupBox->setLayout(layout);
}

void Dialog::createFormGroupBox()
{
formGroupBox = new QGroupBox(tr("Form layout"));
QFormLayout *layout = new QFormLayout;
layout->addRow(new QLabel(tr("Line 1:")), new QLineEdit);
layout->addRow(new QLabel(tr("Line 2, long text:")), new QComboBox);
layout->addRow(new QLabel(tr("Line 3:")), new QSpinBox);
formGroupBox->setLayout(layout);
}

Output:
Result:

Thus the above Qt Programs are executed successfully and the result was verified.

8.GTK Programming
Aim:

To write the simple GTK Program for student mark entry..

Procedure:

1.Open Python Terminal

2.File -> New->Write the program

3.Compile the source program

4.Run the program

Program:

import gtk
class PyApp(gtk.Window):
def __init__(self):
super(PyApp, self).__init__()
self.set_title("Box demo")

box = gtk.VBox()
vb = gtk.VBox()
lbl = gtk.Label("Enter name")

vb.pack_start(lbl, expand = True, fill = True, padding = 10)


text = gtk.Entry()

vb.pack_start(text, expand = True, fill = True, padding = 10)


btn = gtk.Button(stock = gtk.STOCK_OK)

vb.pack_start(btn, expand = True, fill = True, padding = 10)


hb = gtk.HBox()

lbl1 = gtk.Label("Enter marks")


hb.pack_start(lbl1, expand = True, fill = True, padding = 5)
text1 = gtk.Entry()

hb.pack_start(text1, expand = True, fill = True, padding = 5)


btn1 = gtk.Button(stock = gtk.STOCK_SAVE)

hb.pack_start(btn1, expand = True, fill = True, padding = 5)


box.add(vb)
box.add(hb)
self.add(box)
self.show_all()
PyApp()
gtk.main()
Output:
Result:

Thus the above programs are executed and the result was verified.

9.PHP & MYSQL

Aim:
To make data base connectivity by using PHP & Mysql.

Program:

Front End:

<html>

<head>

<title> Student Registration Form ,/title>

</head>

<body bgcolor =”red”>

<form name="registration" method="post" action="registration.php">


<br>

Name:

<input name = “name” type=”text” value =”text”>

</br>

<br>

Rollno:

<input name = “rollno” type=”text” value =”text”>

</br>

<br>

Dept:

<input name = “dept” type=”text” value =”text”>

</br>

<br>

Option:

<input name = “opt” type=”radio” value =”text”>

</br>

<br>

<input name = “name” type=”submit” >

</br>

</body>
</html>

Back End: [registration.php]

<?php

mysql_connect("localhost","root","");

mysql_select_db("student");

$a=$_POST['name'];

$b=$_POST['rollno'];

$c=$_POST['dept'];

$d=$_POST['opt'];

mysql_query("Insert into studentdetails (name,rollno,dept,opt) values ('$a','$b','$c','$d')");

echo " 1 record added successfully";

?>

Result :

Thus the above program was executed and the result was verified.

10.Installing Samba

Aim:
To write simple procedure to install & Configure samba server.

Procedure :

A Samba file server enables file sharing across different operating systems over a network. It lets
you access your desktop files from a laptop and share files with Windows and macOS users.

Installing Samba

To install Samba, we run:

sudo apt update


sudo apt install samba
We can check if the installation was successful by running:

whereis samba
The following should be its output:

samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba


/usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz
Setting up Samba

2.Setting Up Samba

Now that Samba is installed, we need to create a directory for it to share:

mkdir /home/<username>/sambashare/
The command above creates a new folder sambashare in our home directory which we will share
later.

The configuration file for Samba is located at /etc/samba/smb.conf. To add the new directory as a
share, we edit the file by running:

sudo nano /etc/samba/smb.conf


At the bottom of the file, add the following lines:

[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes
Then press Ctrl-O to save and Ctrl-X to exit from the nano text editor.

What we’ve just added


comment: A brief description of the share.
 path: The directory of our share.
 read only: Permission to modify the contents of the share folder is only granted when the
value of this directive is no.
 browsable: When set to yes, file managers such as Ubuntu’s default file manager will list
this share under “Network” (it could also appear as browseable).

Now that we have our new share configured, save it and restart Samba for it to take effect:

sudo service smbd restart


Update the firewall rules to allow Samba traffic:

sudo ufw allow samba


3. Setting up User Accounts and Connecting to Share
Since Samba doesn’t use the system account password, we need to set up a Samba password for
our user account:

sudo smbpasswd -a username


Note
Username used must belong to a system account, else it won’t save.

Connecting to Share

On Ubuntu: Open up the default file manager and click Connect to Server then

enter: 

On macOS: In the Finder menu, click Go > Connect to Server then

enter: 

On Windows, open up File Manager and edit the file path to:
\\ip-address\sambashare
Note: ip-address is the Samba server IP address and sambashare is the name of the share.

You’ll be prompted for your credentials. Enter them to

connect! 

Result:

Thus the samba server installation was done successfully and the output was verified.

You might also like