0% found this document useful (0 votes)
2 views22 pages

Operatingsystemfull Manual

The document provides a comprehensive overview of various Linux commands related to directory management, file management, general-purpose commands, and filters and communication commands. Each command is explained with its syntax and examples of usage, demonstrating practical applications. The results of executing these commands are also included, confirming their successful execution.

Uploaded by

chinnaa
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)
2 views22 pages

Operatingsystemfull Manual

The document provides a comprehensive overview of various Linux commands related to directory management, file management, general-purpose commands, and filters and communication commands. Each command is explained with its syntax and examples of usage, demonstrating practical applications. The results of executing these commands are also included, confirming their successful execution.

Uploaded by

chinnaa
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/ 22

PART-A

Ex.NO:1 DIRECTORY MANAGEMENT COMMANDS

DATE:

AIM:

To execute the following directory management commands and write the


results.

1. ls 2. cd 3. pwd 4. mkdir 5. rmdir

DIRECTORY MANAGEMENT COMMANDS:

1) ls commands

(i) $ls

It displays all files and folders in current directory.

Eg:

$ ls

Install example1 gpt student

exer1 graf1 poly stud

(ii) $ls -a

It displays the hidden files in current directory.

2) mkdir command

It is used to create a directory.

Syntax

$mkdir directory_ name

Eg:

$mkdir GPTC

$ ls

Ct ex1 ex2 GPTC


3) cd command

It is used to change the present working directory to new directory.

Syntax

$cd directory name

Eg:

1. $cd GPT
- Change directory path to GPT directory.
2. $ cd
- To exit all directory and go to root directory.

4) rmdir command

This command is used to remove the created directory.

Syntax

$rmdir directory name

Eg:

$rmdir GPTC

$ ls

Ct ex1 ex2

5) pwd

It displays the current working directory.

Eg:

$pwd
OUTPUT:

gpt@gpt-OptiPlex-7040:~$ mkdir subject

gpt@gpt-OptiPlex-7040:~$ mkdir test

gpt@gpt-OptiPlex-7040:~$ ls

b.txt Downloads subject Filecopy.sh lab Pictures ram sindhu

simple test

gpt@gpt-OptiPlex-7040:~$ cd test

gpt@gpt-OptiPlex-7040:~/test$ mkdir -p linux/command

gpt@gpt-OptiPlex-7040:~/test$ cd linux

gpt@gpt-OptiPlex-7040:~/test/linux$ cd command

gpt@gpt-OptiPlex-7040:~/test/linux/command$ pwd

/home/gpt/test/linux/command

gpt@gpt-OptiPlex-7040:~/test/linux/command$ cd

gpt@gpt-OptiPlex-7040:~$ ls

b.txt Downloads subject Filecopy.sh lab Pictures ram sindhu

simple test

gpt@gpt-OptiPlex-7040:~$ rmdir subject

gpt@gpt-OptiPlex-7040:~$ ls

b.txt Downloads Filecopy.sh lab Pictures ram sindhu simple

test

gpt@gpt-OptiPlex-7040:~$ rmdir -p test/linux/command

gpt@gpt-OptiPlex-7040:~$ ls

b.txt Downloads Filecopy.sh lab Pictures ram sindhu simple


Result:

Thus, the various commands for directory management were executed and
verified successfully.
EX.NO:2 FILE MANAGEMENT COMMANDS

DATE:

AIM:

To execute the following file management commands and write the results.

FILE MANAGEMENT COMMANDS:

1) cat command
This command is used to create a new file.

Syntax:
$cat > file name
Eg:
cat>gpt
HELLO I AM THE STUDENT OF COMPUTER BRANCH.
Ctrl + Z

2) chmod command
This command is used to change the given permission for file.

Syntax:

$ chmod [options] filename

2-write 6-read write 4-read 1-execute

r-read w- write x-execute

Eg:
$ chmod 641 gpt
$ chmod +r gpt
$ chmod +w gpt
$ chmod +x gpt
3) cp command

This command is used to copy one file into another file.

Syntax
$cp filename1 filename2
Eg:
$cp gpt lab

4) mv command

This command is used to rename the file.


Syntax:
$mv filename1 filename2
Eg:
$mv lab practical

5) rm command

This command is used to remove the file.

Syntax:
$rm filename
Eg:
$rm gpt

6) more command

This command is used to view the contents of a text file one screen at a time.

Syntax:
$more filename
(or)
$more [option] filename
Options:

ns - skip n lines and display another screenful


nf - skip n screenful and display another screenful
= - display the current line number
h - display all the option in more
n - integer

Eg:
$more practical

7) concatenate command

This command is used to concatenate the files.


Syntax :
$cat filename1 filename2 > filename3
Eg:
$cat lab1 lab2 > lab

8) cmp command

This command is used to compare the files


Syntax:
$cmp filename1 filename2
Eg:
$cmp lab1 lab2
OUTPUT:
gpt@gpt-OptiPlex-7040:~$ cat>practical
linux lab
dld lab
c lab
^Z
[1]+ Stopped cat > practical
gpt@gpt-OptiPlex-7040:~$ cat practical
linux lab
dld lab
c lab
gpt@gpt-OptiPlex-7040:~$ cat -n practical
1 linux lab
2 dld lab
3 c lab
gpt@gpt-OptiPlex-7040:~$ cat>>practical
digital logic
os lab
^Z
[2]+ Stopped cat >> practical
gpt@gpt-OptiPlex-7040:~$ cat practical
linux lab
dld lab
c lab
digital logic
os lab
gpt@gpt-OptiPlex-7040:~$ touch practical2
gpt@gpt-OptiPlex-7040:~$ cp practical practical2
gpt@gpt-OptiPlex-7040:~$ cat practical2
linux lab
dld lab
c lab
digital logic
os lab
gpt@gpt-OptiPlex-7040:~$ mv practical lab
gpt@gpt-OptiPlex-7040:~$ cat lab
linux lab
dld lab
c lab
digital logic
os lab
gpt@gpt-OptiPlex-7040:~$ more -s +2 lab
dld lab
c lab
digital logic
os lab
gpt@gpt-OptiPlex-7040:~$ chmod 641 lab
gpt@gpt-OptiPlex-7040:~$ ls -l lab
-rw-r----x 1 gpt gpt 46 Jan 27 03:28 lab
gpt@gpt-OptiPlex-7040:~$ rm lab

Result:

Thus, the various commands for file management were executed and verified
successfully.
EX.NO:3 GENERAL PURPOSE COMMANDS
DATE:

AIM:
To execute the following general-purpose commands and write the results.
1) wc 2) od 3) lp 4) cal 5) date 6) who 7) tty 8) ln

GENERAL PURPOSE COMMANDS:

1) wc
- To count the number of lines, words and characters in a file.

Eg:
$ cat file1
Hai
Good morning
How are you

$ wc file1
3 6 23 file1

2) od
- To dump the files in octal and other formats.

Eg:
$ od file1
0000000 064554 072556 020170 060554 005142 062542 062545 066040
0000020 061141 061412 066040 061141 000012 0000031

3) lp
- To submit the files for printing or alters a pending job.

Eg:
$ lp xyz.c
-This command prints the xyz.c file to the default printer.
4) cal

- This command is used to display the calendar.


Eg:
$cal June 2016

5) date

- This command is used to display the date.

Eg:

1) $date –d yesterday

- It displays yesterday’s date.

2) $ date –d tomorrow

- It displays tomorrow’s date.

3) $date

- It displays today’s date.

4) $ date + ”%d-%m-%y”

24-8-2016

6) who

- To know the details about the users currently working on the system.

Eg:
$who

7) tty

- To print the file name of the terminal connected to standard input.

Eg:
$ tty

8) ln
- This command is used to link a file or directory.

Syntax:

$ln filename newfilename

(or)

$ln directoryname or newdirectoryname

Eg:
$ ln file1 file2

- It is used to link a file.


$ ln -s file1 file2

- It is used to create symbolic link to a file.


OUTPUT:
guest-z9BVJD@gpt-OptiPlex-7040:~$ cat>linux
general purpose commands
file managements commands
directory management commands
^Z
[2]+ Stopped cat > linux
guest-z9BVJD@gpt-OptiPlex-7040:~$ wc linux
3 9 81 linux
guest-z9BVJD@gpt-OptiPlex-7040:~$ od linux
0000000 062547 071156 066141 070040 071165 067560 062563
061440
0000020 066557 060555 062156 005163 064546 062554 066440
067141
0000040 063541 066545 067145 071564 061440 066557 060555
062156
0000060 005163 064544 062562 072143 071157 020171 060555
060556
0000100 062547 062555 072156 061440 066557 060555 062156
005163
0000120
guest-z9BVJD@gpt-OptiPlex-7040:~$ cal 03 2006
March 2006
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%Z
IST
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%a
Fri
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%d
28
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%b
Jun
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%H
21
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%d
28
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%T

21:23:17
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%r
09:23:29 PM IST
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%Y
2024
guest-z9BVJD@gpt-OptiPlex-7040:~$ date +%y
24
guest-z9BVJD@gpt-OptiPlex-7040:~$ who
guest-z9BVJD :0 2024-06-28 21:15 (:0)
guest-z9BVJD pts/0 2024-06-28 21:16 (:0)
guest-z9BVJD@gpt-OptiPlex-7040:~$ tty
/dev/pts/0
guest-z9BVJD@gpt-OptiPlex-7040:~$ ln linux lab
guest-z9BVJD@gpt-OptiPlex-7040:~$ cat lab
general purpose commands
file managements commands
directory management commands

RESULT:

Thus, the above general-purpose commands are executed and verified


successfully.
EX.NO:4 FILTERS AND COMMUNICATION COMMANDS

DATE:

AIM:

To execute the following commands and write the results.

1) pr 2) head 3) tail 4) cut 5) paste 6) nl 7) sort 8) grep 9) egrep

10) fgrep 11) uniq 12) write 13) wall

FILTERS AND COMMUNICATION COMMANDS:

1) pr commands

This command is used to format the text files for printing.

Syntax:

$ pr [-option] filename

Eg:

$ cat lab

linux

os

dld

$ pr –f lab
2) head command
This command is used to displays the first few lines from the top of a file.
Syntax:
$head [-option] filename
Eg:
$ head –2 lab
linux

os

- It is used to display the two lines from top of the file lab.
3) tail command

This command is used to display few lines from the last line of a file.

Syntax:

$tail [-option] filename

Eg:

$ tail –2 lab

os

dld

- It is used to display the last two line from the file file1.

4) cut command

This command is used to removes sections from each line of files.

Syntax:

$cut [-option] filename

$ cut -c3 lab

-It is used to cut the third character from the file lab.
5) paste command

This command is used to merge the contents of more than one file into a
single file.

Syntax:

$ paste filename1 filename2

Eg:

$cat file1

Good

Bad

$cat file2

Morning

thing

$paste file1 file2

Good morning

Bad thing

6) nl command

This command is used to give line number to the file.

Syntax:

$nl filename

Eg:

$ nl file1

1 Hello

2 Gud morning

-It is used to give line number to the file.


7) Sort command

This command is used to sort the file content in either ascending or


descending order.

Syntax:

$sort -b filename

-Used to sorting the file content in ascending order.

$sort -r filename

-Used to sorting the file content in descending order.

8) grep Command

To search a particular character pattern in one or more files.

Syntax:

$grep [pattern] filename1 filename2

Eg:

$ cat lab

linux
os
dld

$ grep “li” lab

linux

- To display the line which has the word ‘li’ from the file lab.

$ grep “[a-z]*” lab

linux

os

dld

- To display the line which has the lowercase letters a-z from the file
lab.
9) egrep Command

This command is used to search a multiple Pattern.

Syntax:

$egrep ‘Word 1 | Word 2’ File name

Eg:

$egrep “li | o” lab

linux

os

10) fgrep Command

This command is used to Obtain patterns from two (or) more files.

Syntax

$fgrep ‘Word 1 | Word 2’ Filename1 Filename2

11) uniq Command

This command is used to displays the lines by eliminating duplicates.

Syntax:

$uniq Filename

Eg:

$ uniq -d file1

→ It is used to display the repeated lines from the file file1.

$ uniq -u file1

→ It is used to display the non-repeated lines from the file file1.


COMMUNICATION COMMANDS:

1) write
This Command is used used to send message.

Syntax:

$write gpt

Message from [email protected] on pts/2 at 15:02…

Welcome to linux lab

EOF

2)wall

– used to send a message to all users.

Syntax:

$wall username

Eg:

$wall

hai to all

Broadcast message from gpt (pts/2) (Mon Aug 27 15:12:50 2016):

hai to all

Result:

Thus, the various commands for simple filter were verified successfully.

You might also like