Professional Documents
Culture Documents
Procedure:
1.
2.
3.
1. Syntax:
$ pwd
Description:
2. Syntax:
$ mkdir dirname
Description:
3. Syntax:
$ rmdir dirname
Description:
4. Syntax:
$ cd
Description:
This command is used to change the current working directory.
5. Syntax:
$ clear
Description:
1. Syntax:
$ cat > filename
Description:
2. Syntax:
$ cat filename
Description:
3. Syntax:
$ cat >> filename
Description:
4. Syntax:
$ cp file1 file2
Description:
This command is used to copy the contents of one file to another file.
5. Syntax:
$ rm filename
Description:
This command is used to remove the file.
6. Syntax:
$ mv file1 file2
Description:
This command is used to move the file from one place to another. It removes the
specified file from the original location.
7. Syntax:
$ ls
8. Syntax:
$ wc filename
Description:
This command is used to count the number of words, lines and characters in the file.
9. Syntax:
$ id
Description:
This command is used to prints user and groups (UID and GID) of the current user.
10. Syntax:
$w
Description:
This command is used to check which users are logged in to the system and what
command they are executing at that particular time. It also shows the uptime, number of users
logged in and load average of the system.
1. Syntax:
$ date
Description:
This command is used to display the current date with day, month & time.
2. Syntax:
$ echo text
Description:
3. Syntax:
$ cal month or year
Description:
4. Syntax:
$ bc
Description:
5. Syntax:
$ who
Description:
This command is used to display the data about all the users who are currently logged into the
system.
6. Syntax:
$ who am i
Description:
This command identifies the user and lists the user name, terminal line, the date and time of
login.
7. Syntax:
$ tty
Description:
tty - teletype. It is used to know the terminal name that we are using.
8. Syntax:
$ passwd
Description:
FILTER COMMANDS:
1. Syntax:
$ head filename
Description:
2. Syntax:
$ tail filename
Description:
This command is used to display the last 10 lines of a file from end.
3. Syntax:
$ grep pattern file(s)
Description:
grep – Global Regular Expression and Print. It is used to search and print specified patterns
from a file.
4. Syntax:
$ sort filename
Description:
Description:
6. Syntax:
$ du
Description:
RESULT:
i. To study the difference between Bourne Shell and BASH shell. Summarize the ideas of
Device drivers of Unix and Windows.
ii. Create a directory named “Drive1”. In this directory create few numbers of files named
File1, File2, File3, etc., Use a shell command to display all the files you have created
inside this directory.
Solution:
$ ls
file1 file2 file3 file4
iii. A user created a file named “Large” which more numbers of lines. He founds difficult to
access the head and tail of the contents of that particular file. So, help him out to find the
head and tail of the file using any shell commands.
Solution:
$ head gaint
Hari
Hiranyagarbha
Hrishikesh
Jagadguru
Jagadisha
Jagannath
Janardhana
Jayantah
Jyotiraaditya
Kamalnath
Kamalnayan
Kamsantak
Kanjalochana
$ tail gaint
Jagadguru
Jagadisha
Jagannath
Janardhana
Jayantah
Jyotiraaditya
Kamalnath
Kamalnayan
Kamsantak
Kanjalochana
iv. Display the following details of the system uid, gid, groups, number of users,
authenticated users, local accounts using any shell commands.
Solution:
$ who am i
v. Display the list of shell command to display numbers of words, lines, and characters
counts of file content.
Solution:
$ wc -c text
36 text
$ wc -l text
2 text
$ wc -w text
2text
vi. Create a file, then sort it in the ascending order. Now number each line in the ascending
order such way all content of the files should start with a number. Finally, display the file
content.
Solution:
$ sort gaint
Apple
Ball
Cat
Dog
Elephant
vii. Create two directories named “dir1”and “newdir” separately. Change the path of
directory from “dir1” to “newdir”. Concatenate a file called “Wishes”. This file should
display your best friend’s birthday dates.
Solution:
$ pwd
/home/Sumathy
Sumathy@DESKTOP-0T3UVR2 ~
$ mkdir file1
Sumathy@DESKTOP-0T3UVR2 ~
$ mkdir file2
Sumathy@DESKTOP-0T3UVR2 ~
$ mkdir file3
Sumathy@DESKTOP-0T3UVR2 ~
$ mkdir file4
Sumathy@DESKTOP-0T3UVR2 ~
$ ls
file1 file2 file3 file4
viii. An anonymous user who tries to copy the file content from the Unix shell. He tries to
copies directly from the source file content. Is it possible for him to copy the file content
and delete the source file content?
Solution:
$ cat > cool
$ mv best cool
$ cat cool
12453365
abcsdefghijklmnopqrstuvwxz
$ cat best
cat: best: No such file or directory
ix. Concatenate a file named “OS”. Use “grep” command to search and display the specific
text from the “OS” file. Finally, show us the numbers of texts counts.
Solution:
$ wc -c text
36 text
$ wc -l text
2 text
$ wc -w text
2text