0% found this document useful (0 votes)
17 views4 pages

LabReport-1 A2 0242220005101251

The lab report focuses on an introduction to Linux commands, detailing the creation and manipulation of files, managing file permissions, and using variables and user input in shell scripts. Key commands such as 'touch', 'chmod', and 'echo' are demonstrated with examples, including creating a simple script that outputs 'Hello World' and interacts with user input. The report is submitted by Kazi Tawhid Ibn Monir to lecturer Nushrat Jahan Oyshi at Daffodil International University.

Uploaded by

monir22205101251
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)
17 views4 pages

LabReport-1 A2 0242220005101251

The lab report focuses on an introduction to Linux commands, detailing the creation and manipulation of files, managing file permissions, and using variables and user input in shell scripts. Key commands such as 'touch', 'chmod', and 'echo' are demonstrated with examples, including creating a simple script that outputs 'Hello World' and interacts with user input. The report is submitted by Kazi Tawhid Ibn Monir to lecturer Nushrat Jahan Oyshi at Daffodil International University.

Uploaded by

monir22205101251
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/ 4

Lab Report

Course Title : Operating Systems Lab

Course Code : CSE 324

Topic : Introduction to Linux commands

Submitted To

Name : Nushrat Jahan Oyshi


Designation : Lecturer Computer Science & Engineering

Daffodil International University

Submitted By
Name : Kazi Tawhid Ibn Monir

Id : 0242220005101251\
Section : 63_A - (A2)
Daffodil International University

DIU Date-1/27/2025
Introduction to Linux Commands
1. Creating Directories and Files

In this section, we explored basic file manipulation using Linux commands. We


focused on creating and working with files in a terminal environment.

Creating a file using the touch command:

=> touch hello.sh

Opening the file:

The file hello.sh was opened using a script editor to input the content. A simple shell script
was written to output the text "Hello World".

Script content:

The script content included the shebang (#!/bin/bash) followed by an echo command to
display a message. The content of the file hello.sh was:

=> #! /bin/bash

=>echo "Hello World"

Saving and closing the file

2. Working with File Permissions

After creating the file, we learned how to manage file permissions to allow or restrict
access to the script file. This section covers how to make the .sh file executable and how
to modify its permissions.

Viewing the file's permissions:

The ls -al command was used to list detailed file information, including permissions:

=>chmod +x hello.sh

This allowed us to execute the script file.

Running the script:


DIU Date-1/27/2025
To run the script and print the output ("Hello World"), we executed the following command:

=>./hello.sh

Revoking and re-granting permissions:

To demonstrate how permissions can be modified, the script file was made non-
executable using chmod -x:

=>chmod -x hello.sh

After this, we granted execute permissions again:

=>chmod +x hello.sh

We were then able to run the script once more using:

=>./hello.sh

3. Using Variables in Shell Scripts


Next, we explored how to define variables in shell scripts and use them to print dynamic
content.

Creating a variable and printing its value:

A variable n was declared and assigned a value:

=>#! /bin/bash
=>n=123
=>echo $n

Running the script:

After saving the script, we ran it to print the value of the variable n:

=>./hello.sh

This output printed the value 123.

DIU Date-1/27/2025
4. User Input in Shell Scripts

In this section, we learned how to interact with users through the terminal and accept user
input in a shell script.

Prompting the user for input:

A prompt was created to ask the user for their name:

=>echo "Enter your name: "


=>read n
Displaying user input:

The user's input was displayed by echoing the variable:

=>echo "Your Name: "$n

Running the script with user input:

When the script was executed, the terminal requested the user's name and then displayed
it:

=>./hello.sh

Example output after running the script:

=>Enter your name: Kazi Tanvir


=>Your Name: Kazi Tanvir

DIU Date-1/27/2025

You might also like