Q1.(a) Write a shell script which will accept the PID of a process and display the details of that process.

(b)Create Remote Access Policy. Show how you can change to Remote Access Logging setting in Windows 2000.


Ans:-  (a). Shell Script to Accept PID and Display Process Details


You can write a simple shell script using Linux commands like `ps` to get details of a process by its PID (Process ID). Here’s an example script:


```bash

#!/bin/bash


# Check if PID is provided as an argument

if [ $# -eq 0 ]; then

  echo "Usage: $0 <PID>"

  exit 1

fi


# Assign the PID to a variable

PID=$1


# Check if the process with the given PID exists

if ps -p $PID > /dev/null; then

  # Display details of the process

  echo "Process details for PID $PID:"

  ps -p $PID -o pid,ppid,cmd,%mem,%cpu,start_time

else

  echo "No process found with PID $PID"

fi

```

 Explanation:

1. `ps -p $PID` checks if a process with the given PID exists.

2. `ps -p $PID -o pid,ppid,cmd,%mem,%cpu,start_time` displays details of the process:

   - `pid`: Process ID

   - `ppid`: Parent Process ID

   - `cmd`: Command that started the process

   - `%mem`: Memory usage

   - `%cpu`: CPU usage

   - `start_time`: Start time of the process


 How to Run:

1. Save this script as `process_info.sh`.

2. Make it executable by running: `chmod +x process_info.sh`.

3. Execute it by passing a PID: `./process_info.sh <PID>`.


 (b). Remote Access Policy and Changing Remote Access Logging Settings in Windows 2000


 Remote Access Policy:

A Remote Access Policy defines the conditions and rules that govern the authorization and connection of remote clients to a network. These policies help in controlling who can access network resources remotely and under what conditions.


**Steps to Create Remote Access Policy in Windows 2000:**

1. Open the **Routing and Remote Access** tool from **Administrative Tools**.

2. In the console tree, right-click on the server you want to configure, and select **Properties**.

3. Go to the **Security** tab.

4. Click on **Authentication Methods** and set the appropriate authentication type (e.g., PAP, CHAP).

5. Under **Remote Access Policy**, you can create a new policy:

   - Click on **Add** to create a new policy.

   - Specify the conditions under which the policy will apply (e.g., user group membership).

   - Define the permissions (allow/deny access).

6. Save the policy.


Changing Remote Access Logging Settings in Windows 2000:

Logging remote access activities is essential for monitoring and troubleshooting. Here’s how to change Remote Access Logging settings:


1. Open **Routing and Remote Access** from **Administrative Tools**.

2. Right-click on the server and select **Properties**.

3. Go to the **Logging** tab.

4. Select the events you want to log (such as successful and failed connection attempts).

5. You can change the location of the log files by clicking on the **Browse** button and specifying a new path.

6. Set the log file size limits if necessary.

7. Click **OK** to save the changes.

This will configure logging for remote access activities on your Windows 2000 server.


Q2.(a) Write a shell program to scan all the files in a particular directory and list only those files which start (file_name) with "a" or "A". 

(b)Install and configure TCP/IP settings in LINUX/UNIX operating system.Explain with step by step procedure.


Ans:- (a). Shell Program to List Files Starting with "a" or "A"


You can use a simple shell script that utilizes a `for` loop to scan files in a directory and lists those whose names begin with "a" or "A".


Here’s the shell script:


```bash

#!/bin/bash


# Check if directory is provided as an argument

if [ $# -eq 0 ]; then

  echo "Usage: $0 <directory>"

  exit 1

fi


# Assign the directory to a variable

DIR=$1


# Check if the provided argument is a valid directory

if [ -d "$DIR" ]; then

  echo "Files in '$DIR' starting with 'a' or 'A':"

  # Use a for loop to scan all files in the directory

  for file in "$DIR"/*; do

    # Get the base file name and check if it starts with 'a' or 'A'

    filename=$(basename "$file")

    if [[ $filename == [aA]* ]]; then

      echo "$filename"

    fi

  done

else

  echo "Directory '$DIR' not found"

fi

```


 Explanation:

1. The script accepts a directory path as an argument.

2. It uses a `for` loop to scan through all files in the given directory.

3. The `basename` command extracts the file name from the full path.

4. It checks if the file name starts with "a" or "A" using a pattern match (`[[ $filename == [aA]* ]]`).

5. Files matching the condition are listed.


 How to Run:

1. Save this script as `list_files.sh`.

2. Make it executable: `chmod +x list_files.sh`.

3. Run the script and provide a directory path: `./list_files.sh /path/to/directory`.


---

(b). Installing and Configuring TCP/IP Settings in Linux/Unix


Configuring TCP/IP settings is essential to enable network connectivity on Linux/Unix systems. Below are the step-by-step instructions for configuring TCP/IP settings manually:


 Step 1: Check Existing Network Configuration

Before making changes, check the current network configuration using the following command:


```bash

ifconfig

```

or

```bash

ip addr show

```

Step 2: Edit Network Configuration Files

To configure the TCP/IP settings, you need to edit the network interface configuration files. These files vary by Linux distribution. Below are the configuration steps for a typical Linux distribution.


1. **Locate Network Interface**: Determine which network interface you are going to configure (e.g., `eth0`, `enp0s3`).

   - Run the command: `ip link show` to list network interfaces.


2. **Edit Network Interface Configuration File**:

   - On **Debian/Ubuntu-based** systems:

     Network interface settings are stored in the `/etc/network/interfaces` file.

     Edit the file using a text editor like `nano`:

     ```bash

     sudo nano /etc/network/interfaces

     ```


     Example configuration:

     ```bash

     auto eth0

     iface eth0 inet static

         address 192.168.1.100

         netmask 255.255.255.0

         gateway 192.168.1.1

         dns-nameservers 8.8.8.8 8.8.4.4

     ```

   - On **Red Hat/CentOS-based** systems:

     Network settings are stored in `/etc/sysconfig/network-scripts/ifcfg-<interface>`, for example `/etc/sysconfig/network-scripts/ifcfg-eth0`.


     Edit the file using a text editor:

     ```bash

     sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

     ```


     Example configuration:

     ```bash

     DEVICE=eth0

     BOOTPROTO=static

     ONBOOT=yes

     IPADDR=192.168.1.100

     NETMASK=255.255.255.0

     GATEWAY=192.168.1.1

     DNS1=8.8.8.8

     DNS2=8.8.4.4

     ```

 Step 3: Restart Network Service

After editing the configuration file, restart the network service to apply the new settings.


- On **Debian/Ubuntu** systems, run:

  ```bash

  sudo systemctl restart networking

  ```

- On **Red Hat/CentOS** systems, run:

  ```bash

  sudo systemctl restart network

  ```

Step 4: Verify Configuration

To verify that the network settings have been applied correctly, use the following command:


```bash

ifconfig

```

or

```bash

ip addr show

```

Check that the IP address, subnet mask, gateway, and DNS settings are correctly applied.


Step 5: Test Network Connectivity

Ping the gateway or an external server to ensure network connectivity:


```bash

ping 192.168.1.1

ping google.com

```

This completes the installation and configuration of TCP/IP settings on Linux/Unix systems.


Q3. (a) Create a user account in the LINUX/UNIX Server. Set its password and define its permission like'an administrator. 

(b)Configure a DNS Server as a Root Name Server in Windows 2000 Server. Explain with step by step procedure

Ans:- (a). Creating a User Account in LINUX/UNIX and Setting Permissions


 Step 1: Create a New User Account

To create a new user in a Linux/Unix server, use the `useradd` or `adduser` command.


```bash

sudo useradd username

```


or for some systems:


```bash

sudo adduser username

```


Replace `username` with the desired username for the new account.


Step 2: Set Password for the User

After creating the user, set the password using the `passwd` command:


```bash

sudo passwd username

```


You will be prompted to enter and confirm a password.


 Step 3: Add the User to the `sudo` Group

To give the user administrator-like permissions (allow them to use `sudo` to run administrative commands), you need to add the user to the `sudo` group (on Ubuntu-based systems) or `wheel` group (on Red Hat/CentOS-based systems).


- On **Debian/Ubuntu** systems:


```bash

sudo usermod -aG sudo username

```


- On **Red Hat/CentOS** systems:


```bash

sudo usermod -aG wheel username

```


 Step 4: Verify the User’s Permissions

To ensure the user has the correct permissions, log in with the new user account:


```bash

su - username

```


Then test if the user can run `sudo` commands by executing:


```bash

sudo whoami

```


It should output `root`, confirming the user has administrative privileges.


---


(b). Configuring a DNS Server as a Root Name Server in Windows 2000 Server


A root name server is at the top of the DNS hierarchy, providing information on the location of authoritative name servers. Below is a step-by-step procedure to configure a DNS server as a root name server in Windows 2000.


 Step 1: Install DNS Server

1. **Open Control Panel** > **Add/Remove Programs**.

2. Click on **Add/Remove Windows Components**.

3. Select **Networking Services** and then click **Details**.

4. Check the **Domain Name System (DNS)** option and click **OK**.

5. Click **Next** and follow the prompts to install the DNS server.


 Step 2: Configure DNS as a Root Name Server

1. **Open the DNS Management Console**:

   - Go to **Start** > **Programs** > **Administrative Tools** > **DNS**.

2. In the DNS console, right-click on the server name and select **New Zone**.

3. The **New Zone Wizard** will start. Click **Next** to continue.

4. Select **Primary Zone** and click **Next**.

5. In the **Zone Name** box, type a single dot (`.`). This dot signifies that this server is the root DNS server.

6. Click **Next** and specify the file name where the DNS information will be stored (default is fine).

7. Click **Finish** to complete the zone creation.


 Step 3: Add DNS Records

You need to add various DNS records that allow the DNS server to respond correctly to queries.


1. In the newly created root zone, right-click and select **New Host (A or AAAA)**.

2. Leave the **Name** field blank to denote the root server.

3. In the **IP Address** field, type the IP address of your DNS server.

4. Click **Add Host** to save the record.


 Step 4: Configure Forward Lookup Zone

The DNS server must know where to forward queries it cannot resolve.


1. Right-click on the **Forward Lookup Zones** and select **New Zone**.

2. Follow the wizard to create a new forward lookup zone.

3. Add records as needed, pointing to the external DNS servers for query forwarding.


 Step 5: Configure Reverse Lookup Zone (Optional)

To allow the DNS server to perform reverse lookups (IP address to domain name), create a reverse lookup zone.


1. Right-click on **Reverse Lookup Zones** and select **New Zone**.

2. Follow the wizard to specify the network ID (the first three octets of your IP address) for reverse lookups.

3. Add PTR (Pointer) records to the reverse lookup zone, associating IP addresses with hostnames.


 Step 6: Start DNS Server

Once the configuration is complete, start the DNS service.


1. Open **DNS** from the **Administrative Tools**.

2. Right-click on your server and select **Start** (if it isn’t already running).

3. You can also restart the service to apply the new settings by right-clicking and selecting **Restart**.


 Step 7: Testing the Configuration

To test the DNS server:

1. Use the **nslookup** tool to query the server:

   ```bash

   nslookup

   server <DNS_Server_IP>

   ```


2. Query a domain to see if the DNS server resolves it correctly:

   ```bash

   nslookup google.com

   ```

This completes the configuration of a DNS server as a root name server in Windows 2000 Server.


Q4. (a) In LINUX/UNIX system, access your account available at a remote machine. Download a file from the remote location, modify that file and upload back to the remote machine. 

(b)Configure TCP/IP setting in LINUX/UNIX. Assume IP address is 192.168.1.2 and Port is 446.Explain with step by step procedure.

Ans:- (a). Accessing Your Account on a Remote Machine and Transferring Files in Linux/Unix


In Linux/Unix systems, you can access a remote machine and transfer files using `ssh` (Secure Shell) for remote access and `scp` (Secure Copy) for file transfers.


 Step 1: Access the Remote Machine

To log into your account on a remote machine, use the `ssh` command. The syntax is:


```bash

ssh username@remote_host

```


- Replace `username` with your username on the remote machine.

- Replace `remote_host` with the IP address or domain name of the remote machine.


Example:


```bash

ssh user@192.168.1.100

```


 Step 2: Download a File from the Remote Machine

To download a file from the remote machine to your local machine, use the `scp` command:


```bash

scp username@remote_host:/path/to/remote/file /path/to/local/destination

```


Example:


```bash

scp user@192.168.1.100:/home/user/remote_file.txt /home/local_user/

```


This command downloads the file `remote_file.txt` from the remote machine to your local directory `/home/local_user/`.


 Step 3: Modify the File Locally

Once the file is downloaded, open it using any text editor (e.g., `nano`, `vim`, or `gedit`):


```bash

nano /home/local_user/remote_file.txt

```


Make the necessary changes, save, and exit.


 Step 4: Upload the Modified File Back to the Remote Machine

After modifying the file, upload it back to the remote machine using the `scp` command:


```bash

scp /path/to/local/file username@remote_host:/path/to/remote/destination

```


Example:


```bash

scp /home/local_user/remote_file.txt user@192.168.1.100:/home/user/

```


This uploads the modified file back to the remote machine in the `/home/user/` directory.


 Step 5: Verify the Changes on the Remote Machine

Log back into the remote machine using `ssh` and check the file to verify that the changes have been successfully applied.


```bash

ssh user@192.168.1.100

cat /home/user/remote_file.txt

```

(b). Configuring TCP/IP Settings in Linux/Unix (IP: 192.168.1.2, Port: 446)


To configure TCP/IP settings manually in Linux/Unix, you need to assign an IP address and set the port configuration. Below is a step-by-step guide for configuring the IP address and managing ports.


 Step 1: Assign a Static IP Address

To configure a static IP address, follow these steps based on your Linux distribution.


1. **Edit Network Interface Configuration**:

   - On **Debian/Ubuntu-based systems**, network interface settings are stored in `/etc/network/interfaces`.

     Open the configuration file using a text editor:

     ```bash

     sudo nano /etc/network/interfaces

     ```


     Add the following configuration for your network interface (`eth0` in this case):


     ```bash

     auto eth0

     iface eth0 inet static

         address 192.168.1.2

         netmask 255.255.255.0

         gateway 192.168.1.1

     ```


     - `address`: Specifies the static IP address (`192.168.1.2`).

     - `netmask`: Sets the subnet mask (`255.255.255.0`).

     - `gateway`: Defines the default gateway for your network (`192.168.1.1`).


   - On **Red Hat/CentOS-based systems**, the configuration is stored in `/etc/sysconfig/network-scripts/ifcfg-<interface>` (e.g., `/etc/sysconfig/network-scripts/ifcfg-eth0`).


     Open the file for editing:

     ```bash

     sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

     ```


     Add or modify the following lines:


     ```bash

     DEVICE=eth0

     BOOTPROTO=static

     IPADDR=192.168.1.2

     NETMASK=255.255.255.0

     GATEWAY=192.168.1.1

     ONBOOT=yes

     ```


2. **Restart the Network Service**:

   After modifying the configuration file, restart the network service to apply the changes.


   - On Debian/Ubuntu:

     ```bash

     sudo systemctl restart networking

     ```


   - On Red Hat/CentOS:

     ```bash

     sudo systemctl restart network

     ```


3. **Verify the IP Address**:

   To verify that the IP address has been set correctly, use the following command:


   ```bash

   ifconfig

   ```


   or


   ```bash

   ip addr show

   ```


   You should see the IP address `192.168.1.2` assigned to the interface `eth0`.


 Step 2: Configure Port Settings (Port 446)


Ports in Linux are generally handled by services or applications, and the operating system allows traffic to flow through specific ports. Here, we configure firewall rules to allow traffic through port 446.


1. **Install `iptables`** (if not already installed):

   - On **Debian/Ubuntu**:

     ```bash

     sudo apt-get install iptables

     ```


   - On **Red Hat/CentOS**:

     ```bash

     sudo yum install iptables

     ```


2. **Allow Traffic on Port 446**:

   To allow incoming traffic on port 446, add the following `iptables` rule:


   ```bash

   sudo iptables -A INPUT -p tcp --dport 446 -j ACCEPT

   ```


   This command allows incoming TCP traffic on port 446.


3. **Save `iptables` Rules**:

   After adding the rule, save the `iptables` configuration so that it persists across reboots.


   - On **Debian/Ubuntu**:

     ```bash

     sudo iptables-save > /etc/iptables/rules.v4

     ```


   - On **Red Hat/CentOS**:

     ```bash

     sudo service iptables save

     ```


4. **Verify the Port is Open**:

   Use the `netstat` command to verify that port 446 is open and listening:


   ```bash

   sudo netstat -tuln | grep 446

   ```


   This will show you if the port is actively listening for connections.


 Step 3: Test the Configuration

Once the IP address and port are configured, you can test the connection by running a service or an application that listens on port 446 (e.g., an HTTP server or a custom application).


You can test connectivity by using `telnet` or `nc` (Netcat):


```bash

telnet 192.168.1.2 446

```

If the connection is successful, your configuration is complete.

This completes the configuration of TCP/IP settings with IP address `192.168.1.2` and port `446` in Linux/Unix.


Q5. List and execute the following LINUX/UNIX commands:

(a) To list all the current users logged in the system. 

(b) To print and set the date. 

(c) To show the reference and name of the terminal. 

(d) To create a new file with name "abc" in the current directory.

(e) To kill a process with its PID.


Ans:-  Executing Common Linux/Unix Commands


Below are the commands and explanations for each task.


---

 (a) **To list all the current users logged in the system**


Command:


```bash

who

```


- The `who` command displays a list of all users currently logged into the system along with the time they logged in and the terminal they are using.


Alternatively, you can use:


```bash

w

```


- The `w` command gives more detailed information about the users logged in, including what they are currently doing.


---


 (b) **To print and set the date**


- **To print the current date and time**, use:


```bash

date

```


- **To set the date and time**, you need root privileges. Use the following command to set the date (in the format `MMDDhhmmYYYY`):


```bash

sudo date MMDDhhmmYYYY

```


Example to set the date to October 18, 2024, 10:00 AM:


```bash

sudo date 101810002024

```


---


(c) **To show the reference and name of the terminal**


Command:


```bash

tty

```


- The `tty` command displays the file name of the terminal connected to standard input, showing the reference and the name of the terminal (e.g., `/dev/pts/0`).


---

 (d) **To create a new file with name "abc" in the current directory**


Command:


```bash

touch abc

```


- The `touch` command is used to create a new, empty file named `abc` in the current directory.


You can verify the file has been created by listing the contents of the directory:


```bash

ls

```


---

 (e) **To kill a process with its PID**


Command:


```bash

kill PID

```


- Replace `PID` with the actual process ID of the process you want to kill. For example, to kill a process with a PID of `1234`, the command would be:


```bash

kill 1234

```


- If the process doesn’t terminate, you can use a forceful kill command with `-9` option:


```bash

kill -9 PID

```


You can find the PID of a process using the `ps` command or `top`:


```bash

ps aux | grep process_name

```


or


```bash

top

```

These commands are widely used for managing users, system settings, processes, and files in a Linux/Unix environment.

No comments: