0% found this document useful (0 votes)
11 views18 pages

Linux Assignment Final

The document is a Linux assignment completed by a student named Tejaswini, detailing various topics such as quoting in shell scripting, the differences between lists and arrays, common server errors, and security measures for SSH access. It includes explanations, examples, and solutions for issues like 'Address Already in Use' and 'Permission Denied'. The assignment also covers firewall configuration and regular system updates as part of security best practices.

Uploaded by

tadityha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views18 pages

Linux Assignment Final

The document is a Linux assignment completed by a student named Tejaswini, detailing various topics such as quoting in shell scripting, the differences between lists and arrays, common server errors, and security measures for SSH access. It includes explanations, examples, and solutions for issues like 'Address Already in Use' and 'Permission Denied'. The assignment also covers firewall configuration and regular system updates as part of security best practices.

Uploaded by

tadityha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

LINUX ASSIGNMENT

1/5/2024

NAME:TEJASWINI
CLASS:G
USN:ENG22CS0484
SUBJECT:LINUX
LINUX ASSIGNMENT 2

1.question
Single quotes:
Enclosing characters in single quotation marks (‘) holds onto the literal value of each
character within the quotes. In simpler words, the shell will interpret the enclosed text
within single quotes literally and will not interpolate anything including variables,
backticks, certain \ escapes, etc. No character in the single quote has special meaning. This
is convenient when you do not want to use the escape characters to change the way the bash
interprets the input string.
Double quotes:
Double quotes are similar to single quotes except that it allows the shell to interpret dollar
sign ($), backtick(`), backslash(\) and exclamation mark(!). The characters have special
meaning when used with double quotes, and before display, they are evaluated. A double
quote may be used within double quotes by preceding it with a backslash.

Examples

1. In the below-mentioned case, the test is a variable that is initialized with 10. The dollar
sign ($) indicates that the characters following are a variable name and should be replaced
with the value of that variable which in this case is 10. When the $test is enclosed within
single quotes, then the text inside is retained and the value does not get displayed. The $test
does not get interpolated. But when it is closed within double quotes, then the $test is
evaluated and the value of the variable which is 10 is printed.

2.
Syntax:
For
Variable in list
Do
Statements
Done
Here variable is a user defined or of words that take some value from the list the list
Can be anything ranging from an array of words to numbers
Example: values (1,2,3,4,5)
for num in ${values [0]}
do
echo ”$num”
done

3 rd question(factorial)
4th question:

list array
List is a interference in shell , collection of Array organizes items in a sequential
information manner is memory .

List can store only objects An array can store both primitives values
and also objects
To find the length of list we use size() To find length of an array we use
method length()method
List is dynamic in nature An array is static in nature
List usually takes more time than array as it Array performance is fast because of its size
utilizes and adds the operation to perform

5question:

6th question
7th (question)
8th question
10th question server
Client server
11th question
Server
Client

12th question
Server
13th question
Question 14
Address Already in Use:

 Cause: This error occurs when the specified address (IP and port combination) is
already in use by another process.
 Solution: Choose a different port or ensure that the previous process using that port
has terminated.

Permission Denied

 Cause: The process doesn't have the necessary permissions to bind to the specified
port.
 Solution: Run the program as a privileged user (e.g., use sudo), or choose a port
number greater than 1024 which doesn't require special privileges
Connection Refused:

sage: Connection refused


 Cause: The server is not running, or the specified host/port is unreachable.
 Solution: Ensure that the server is running and check the specified host/port.
2. Socket Timeout:

 Cause: The connection attempt took longer than the specified timeout period.
 Solution: Check the network connectivity, firewall settings, and increase the
timeout if needed.
3. Invalid Argument:

 Cause: The arguments provided to the socket creation function are invalid.
 Solution: Double-check the arguments passed to socket functions.
4. Address Family Not Supported:

 Cause: The specified address family (IPv4/IPv6) is not supported on the


system.
 Solution: Check the system capabilities and choose a supported address
family.
5. Network Unreachable:

 Cause: The network to which the connection is attempted is not reachable.


 Solution: Check the network connectivity and ensure that the target host is
reachable.
6. Invalid Socket Descriptor:

 Cause: Trying to perform an operation on a socket descriptor that is not valid.


 Solution: Check if the socket descriptor is properly initialized and hasn't been
closed prematurely.

Question 15

1. Secure SSH Access:

a. Disable Password Authentication:


b. Use SSH Key Authentication:

c. Change SSH Port (Optional):

2. Implement SSL for Web Services:

a. Install and Configure Let's Encrypt SSL:

Install Certbot on the server:

Obtain and install SSL certificate

b. Enable HTTP to HTTPS Redirect (Optional):

Edit the Nginx configuration

Add a server block to redirect HTTP to HTTPS:


Restart Nginx

3. Firewall Configuration:

a. Configure UFW (Uncomplicated Firewall):

Install UFW

Allow SSH and enable the firewall

4. Regular System Updates:

5. Fail2Ban for Brute Force Protection:

Install Fail2Ban

Configure Fail2Ban to protect SSH:


Restart Fail2Ban:

9th question

You might also like