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

Farhan Lunix System

Uploaded by

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

Farhan Lunix System

Uploaded by

Alijan Jan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

ASSIGNMENT

SUBMITTED TO: Mr.BASIT


SUBMITTED BY : M. Farhan
DEPARTMENT: BS IT&CS
CLASS: 4TH EVENING (B)
SUBJECT Operating system
QUESTION NO:1
Set a basic web server using apache on
a linux system?
1. Update Your System
Before installing any software, it's always a
good idea to update your package index.
Open your terminal and run:
code
sudo apt update sudo apt upgrade
2. Install Apache
To install Apache, run the following
command:
code
sudo apt install apache2
3. Adjust the Firewall
If you have a firewall enabled, you need to
allow HTTP and HTTPS traffic. You can use
ufw to do this:
code
sudo ufw allow in "Apache"

5. Test Apache Installation

Open a web browser and navigate to your server’s IP address. You


should see the Apache2 Ubuntu Default Page, which means
Apache is successfully installed and running.

You can find your server’s IP address by running:

hostname -I

6. Manage Apache Service

You can manage the Apache service using the following


commands:

CODE:

Star Apache:

sudo systemctl start apacher

 Stop Apache:

sudo systemctl stop apache2

 Restart Apache:
code

sudo systemctl restart apache2

 Enable Apache to start on boot:

code

sudo systemctl enable apache2

 Disable Apache from starting on boot:

code

sudo systemctl disable apache2


7. Place Your Website Content

The default directory for web content is /var/www/html. You can


place your website files (HTML, CSS, JS, etc.) in this directory.

To create a simple HTML file, run:

Code:

echo "<html><body><h1>My Apache Web


Server</h1></body></html>" | sudo tee
/var/www/html/index.html

8. Configure Virtual Hosts (Optional)

If you want to host multiple websites on the same server, you can
set up virtual hosts. Create a new configuration file in
/etc/apache2/sites-available/:

code

sudo nano /etc/apache2/sites-available/yourdomain.conf

Add the following configuration to the file:

Apache

code

<VirtualHost *:80> ServerAdmin [email protected]


ServerName yourdomain.com ServerAlias www.yourdomain.com
DocumentRoot /var/www/yourdomain ErrorLog $
{APACHE_LOG_DIR}/error.log CustomLog
${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Create the document root directory:

code

sudo mkdir /var/www/yourdomain

Set the appropriate permissions:

code

sudo chown -R $USER:$USER /var/www/yourdomain

Enable the new virtual host:

code

sudo a2ensite yourdomain.conf

Reload Apache to apply the changes:

code

sudo systemctl reload apache2

9. Enable Rewrite Module (Optional)

To enable URL rewriting, you need to enable the mod_rewrite


module:

code

sudo a2enmod rewrite sudo systemctl restart apache2


10. Check Apache Configuration

To ensure there are no syntax errors in your configuration files,


run:

code

sudo apache2ctl configtest

QUESTION NO 2

Monitor system performance and resource


usage using built in linux tools
1. top
top provides a real-time view of the
system's resource usage, including CPU,
memory, and processes.
code
top
2. htop
htop is an interactive process viewer, which
provides a more user-friendly interface than
top. It is not installed by default on all
distributions but can be installed easily.
code
sudo apt install htop htop
3. vmstat
vmstat reports information about
processes, memory, paging, block IO, traps,
and CPU activity.
code
vmstat 1
The 1 argument updates the output every
second.
4. iostat
iostat reports CPU statistics and
input/output statistics for devices and
partitions.
code
sudo apt install sysstat iostat
5. free
free displays the amount of free and used
memory in the system.
code
free -h
The -h option prints the output in human-
readable format.
6. df
df reports the amount of disk space used
and available on filesystems.
code
df -h
The -h option prints the output in human-
readable format.
7. du
du estimates file space usage. To find out
the disk usage of a directory:
code
du -sh /path/to/directory
8. netstat
netstat displays network connections,
routing tables, interface statistics,
masquerade connections, and multicast
memberships.
code
netstat -tuln
The -tuln option shows TCP and UDP ports
in numeric form.
9. ss
ss is used to dump socket statistics. It can
display more detailed information than
netstat.
code
ss -tuln
10. sar
sar collects, reports, and saves system
activity information.
code
sudo apt install sysstat sar -u 1 3
This command displays CPU usage every
second for 3 seconds.
11. uptime
uptime tells how long the system has been
running, along with the load average.
code
uptime
12. dstat
dstat is a versatile resource statistic tool. It
combines the functionality of vmstat,
iostat, netstat, and ifstat.
code
sudo apt install dstat dstat
13. mpstat
mpstat reports global and per-processor
statistics.
code
sudo apt install sysstat mpstat -P ALL
14. nload
nload monitors network traffic and
bandwidth usage in real-time.
code
sudo apt install nload nload
15. ioping
ioping is a simple tool to monitor I/O
latency in real-time.
code
sudo apt install ioping ioping .
16. atop
atop is an advanced system and process
monitor.
code
sudo apt install atop atop
17. glances
glances is a cross-platform system
monitoring tool written in Python.
code
sudo apt install glances glances

You might also like