0% found this document useful (0 votes)
25 views9 pages

OSY Practical

The document provides a comprehensive overview of Linux commands and their functionalities, including general purpose commands, file handling, and specific command descriptions. It discusses various Linux distributions, options for the date command, and file manipulation commands such as ls, rm, mv, and cp. Additionally, it includes shell script examples for conditional statements and loops.

Uploaded by

Nawaz Wariya
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)
25 views9 pages

OSY Practical

The document provides a comprehensive overview of Linux commands and their functionalities, including general purpose commands, file handling, and specific command descriptions. It discusses various Linux distributions, options for the date command, and file manipulation commands such as ls, rm, mv, and cp. Additionally, it includes shell script examples for conditional statements and loops.

Uploaded by

Nawaz Wariya
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/ 9

1.Execute general purpose command line.

i. date
ii. time
iii. cal
iv. clear
v. banner
vi. tty
vii. script
viii. man

a) Write down about distribution of linux OS.


b) Options of date command.
ANS:
Ans a)
Linux distributions, or distros, are variations of the Linux OS built for
different purposes, all sharing the Linux kernel but offering unique
features. Popular examples include Ubuntu, user-friendly for desktops and
servers; Fedora, for cutting-edge technology; Debian, valued for stability;
and CentOS, common in servers. Other notable distros are Arch Linux, for
advanced customization; Linux Mint, for simplicity; Kali Linux, for
cybersecurity; and Raspberry Pi OS, for Raspberry Pi devices.

Ans b)
date //display current date
date –u //display formatted current with time zone
date “+%Y/%m/%d” //display date in format year/month/day
2.Execute command to start, stop, restart a particular service of linux
system. List all services present in system with the help of command.

Write down about file handling in OS.


ANS:

Ans a)

File handling in an operating system involves creating, accessing,


managing, and manipulating files and directories on storage devices,
enabling efficient data reading, writing, organization, and security. Key
operations include file creation, modification, and deletion, with access
methods like sequential or direct. File systems such as FAT32, NTFS, and
ext4 manage storage, while permissions (read, write, execute) ensure
security. Metadata like size and timestamps and hierarchical directories
help organize files, making file handling essential for storing,
retrieving, and sharing data efficiently.
3.Execute a command for file manipulation command
i. ls
ii. rm
iii. mv
iv. cp
v. join
vi. split
vii. head
viii. tail
ix. touch

Write down description in brief for all commands.


ANS:
Brief Descriptions of Commands
1. ls: Lists the contents of a directory, including files and
subdirectories.
2. rm: Deletes files or directories. Use with caution as it permanently
removes data.
3. mv: Moves or renames files and directories.
4. cp: Copies files or directories to a specified location.
5. join: Combines lines of two files based on a common field.
6. split: Splits a large file into smaller parts.
7. head: Displays the first few lines of a file (default is 10 lines).
8. tail: Shows the last few lines of a file (default is 10 lines).
9. touch: Creates an empty file or updates the timestamp of an existing
file.

Descriptions of Additional Commands


1. tr: Translates or replaces characters in a file or input. It can be
used to replace or remove specific characters or convert uppercase
to lowercase.

2. wc: Counts the number of lines, words, and characters in a file.


Usage example: wc filename.

3. more: Displays the contents of a file one page at a time. It allows


for scrolling through large files interactively.

4. cut: Removes sections from each line of files and outputs the
result. Commonly used to extract columns from a file.

5. paste: Merges lines of files horizontally, often used to combine


multiple files side by side.

6. aspell: A spell checker that can check the spelling of text in files
and offer suggestions for corrections.

7. sort: Sorts the lines of a file in alphabetical or numerical order.


It can also sort based on specific columns or delimiters.

8. grep: Searches for patterns in a file and prints matching lines. It


is widely used for pattern matching in files and outputs.
4.Execute tr, wc, more, cut, paste, spell, sort, grep commands.
Write down description in brief for all commands.
ANS:
Descriptions of Additional Commands
1. tr: Translates or replaces characters in a file or input. It can be
used to replace or remove specific characters or convert uppercase
to lowercase.
2. wc: Counts the number of lines, words, and characters in a file.
Usage example: wc filename.

3. more: Displays the contents of a file one page at a time. It allows


for scrolling through large files interactively.
4. cut: Removes sections from each line of files and outputs the
result. Commonly used to extract columns from a file.
5. paste: Merges lines of files horizontally, often used to combine
multiple files side by side.

6. aspell: A spell checker that can check the spelling of text in files
and offer suggestions for corrections.
7. sort: Sorts the lines of a file in alphabetical or numerical order.
It can also sort based on specific columns or delimiters.
8. grep: Searches for patterns in a file and prints matching lines. It
is widely used for pattern matching in files and outputs.
5.Write down shell script for if statement where accept the subject name
and mark subject should be Linux.
ANS:

6.Write shell script to print pyramid using for loop.


* * * * *
* * *
* *
*
rows=5

for ((i=rows; i>=1; i--))


do
# Print leading spaces
for ((j=rows; j>i; j--))
do
echo -ne " "
done

# Print stars
for ((k=1; k<=i; k++))
do
echo -ne "* "
done

# Move to the next line


echo
done
7.Write shell script to check whether file has read, write and execute
permission or not.
ANS:

You might also like