0% found this document useful (0 votes)
15 views14 pages

OS Exercise 1 - 240726 - 151108

The document provides a step-by-step guide for installing Ubuntu on a Windows 10 64-bit system, including enabling the Windows Subsystem for Linux and installing Ubuntu from the Microsoft Store. It also lists basic Linux commands for file and directory management, I/O redirection, and filtering commands, along with examples. Additionally, it includes exercises for practicing command usage and understanding file permissions.

Uploaded by

manavjazzy6
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)
15 views14 pages

OS Exercise 1 - 240726 - 151108

The document provides a step-by-step guide for installing Ubuntu on a Windows 10 64-bit system, including enabling the Windows Subsystem for Linux and installing Ubuntu from the Microsoft Store. It also lists basic Linux commands for file and directory management, I/O redirection, and filtering commands, along with examples. Additionally, it includes exercises for practicing command usage and understanding file permissions.

Uploaded by

manavjazzy6
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/ 14

21CSC202J-Operating Systems Lab

OPERATING SYSTEM
Ex.No:1 INSTALLATION

Ubuntu installation guidelines in windows


Installing Ubuntu in windows 10- 64 bit

3
21CSC202J-Operating Systems Lab

Select Turn Windows features On or Off

Select Windows subsystem for linux then press Ok

4
21CSC202J-Operating Systems Lab

Now restart the PC to apply the changes

Choose Microsoft Store and search for Ubuntu and Install it

5
21CSC202J-Operating Systems Lab

Click on Install

6
21CSC202J-Operating Systems Lab

7
21CSC202J-Operating Systems Lab

Now Launch the Ubuntu

8
21CSC202J-Operating Systems Lab

Username : Any meaningful

name Password: any name

9
21CSC202J-Operating Systems Lab

Finally you will get the prompt on successful installation of Ubuntu in windows 10 64 bit
Ex. No. 1a BASIC LINUX COMMANDS Date :

a) Basics
1. echo SRM  to display the string SRM
2. clear  to clear the screen
3. date  to display the current date and time
4. cal 2003  to display the calendar for the year 2003
cal 6 2003  to display the calendar for the June-2003
5. passwd  to change password

b) Working with Files


1. ls  list files in the present working directory
ls –l  list files with detailed information (long list)
ls –a  list all files including the hidden files

2. cat > f1  to create a file (Press ^d to finish typing)

3. cat f1  display the content of the file f1

4. wc f1  list no. of characters, words & lines of a file f1


wc –c f1  list only no. of characters of file f1
wc –w f1  list only no. of words of file f1
wc –l f1  list only no. of lines of file f1

5. cp f1 f2  copy file f1 into f2

6. mv f1 f2  rename file f1 as f2

7. rm f1  remove the file f1

8. head –5 f1  list first 5 lines of the file f1


tail –5 f1  list last 5 lines of the file f1

c) Working with Directories


1. mkdir elias  to create the directory elias
2. cd elias  to change the directory as elias
3. rmdir elias  to remove the directory elias

4. pwd  to display the path of the present working directory

5. cd  to go to the home directory


cd ..  to go to the parent directory
cd -  to go to the previous working directory
cd /  to go to the root directory
d) File name substitution
1. ls f?  list files start with ‘f’ and followed by any one character

2. ls *.c  list files with extension ‘c’

3. ls [gpy]et  list files whose first letter is any one of the character g, p
or y and followed by the word et

4. ls [a-d,l-m]ring  list files whose first letter is any one of the character
from a to d and l to m and followed by the word ring.

e) I/O Redirection
1. Input redirection
wc –l < ex1  To find the number of lines of the file ‘ex1’

2. Output redirection
who > f2  the output of ‘who’ will be redirected to file f2

3. cat >> f1  to append more into the file f1

f) Piping
Syntax : Command1 | command2

Output of the command1 is transferred to the command2 as input. Finally


output of the command2 will be displayed on the monitor.

ex. cat f1 | more  list the contents of file f1 screen by screen

head –6 f1 |tail –2  prints the 5th & 6th lines of the file f1.

g) Environment variables
1. echo $HOME  display the path of the home directory

2. echo $PS1  display the prompt string $

3. echo $PS2  display the second prompt string ( > symbol by default )

4. echo $LOGNAME  login name

5. echo $PATH  list of pathname where the OS searches for an


executable file
h) File Permission
-- chmod command is used to change the access permission of a file.

Method-1
Syntax : chmod [ugo] [+/-] [ rwxa ] filename

u : user, g : group, o : others


+ : Add permission - : Remove the permission
r : read, w : write, x : execute, a : all permissions

ex. chmod ug+rw f1


adding ‘read & write’ permissions of file f1 to both user and group
members.

Method-2
Syntax : chmod octnum file1

The 3 digit octal number represents as follows


 first digit -- file permissions for the user
 second digit -- file permissions for the group
 third digit -- file permissions for others

Each digit is specified as the sum of following


4 – read permission, 2 – write permission, 1 – execute permission

ex. chmod 754 f1

it change the file permission for the file as follows


 read, write & execute permissions for the user ie; 4+2+1 = 7

 read, & execute permissions for the group members ie; 4+0+1 = 5

 only read permission for others ie; 4+0+0 = 4


Ex. No. 1b FILTERS and ADMIN COMMANDS Date :

FILTERS

1. cut
 Used to cut characters or fileds from a file/input

Syntax : cut -cchars filename


-ffieldnos filename

 By default, tab is the filed separator(delimiter). If the fileds of the files are separated by
any other character, we need to specify explicitly by –d option

cut -ddelimitchar -ffileds filname

2. grep
 Used to search one or more files for a particular pattern.

Syntax : grep pattern filename(s)

Lines that contain the pattern in the file(s) get displayed


pattern can be any regular expressions
More than one files can be searched for a pattern

-v option displays the lines that do not contain the pattern


-l list only name of the files that contain the pattern
-n displays also the line number along with the lines that matches the pattern

3. sort
 Used to sort the file in order

Syntax : sort filename

Sorts the data as text by default


Sorts by the first filed by default

-r option sorts the file in descending order


-u eliminates duplicate lines
-o filename writes sorted data into the file fname
-tdchar sorts the file in which fileds are separated by dchar
-n sorts the data as number
+1n skip first filed and sort the file by second filed numerically

4. Uniq
 Displays unique lines of a sorted file
Syntax : uniq filename
-d option displays only the duplicate lines
-c displays unique lines with no. of occurrences.

5. diff
 Used to differentiate two files

Syntax : diff f1 f2
compare two files f1 & f2 and prints all the lines that are differed between f1
& f2.

Q1. Write a command to cut 5 to 8 characters of the file f1.


$

Q2. Write a command to display user-id of all the users in your system.
$

Q3. Write a command to check whether the user judith is available in your system or not.
(use grep)
$

Q4. Write a command to display the lines of the file f1 starts with SRM.
$

Q5. Write a command to sort the file /etc/passwd in descending order


$

Q6. Write a command to display the unique lines of the sorted file f21. Also display the
number of occurrences of each line.
$

Q7. Write a command to display the lines that are common to the files f1 and f2.
$

You might also like