0% found this document useful (0 votes)
65 views

Lab 1 Unix Himanshu Amity

This document provides instructions for completing various tasks in UNIX/Linux using common commands like uname, date, cal, mkdir, rmdir, cp, mv, ln etc. It involves obtaining system information, creating and manipulating directories and files, comparing and linking files.

Uploaded by

hk993986
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)
65 views

Lab 1 Unix Himanshu Amity

This document provides instructions for completing various tasks in UNIX/Linux using common commands like uname, date, cal, mkdir, rmdir, cp, mv, ln etc. It involves obtaining system information, creating and manipulating directories and files, comparing and linking files.

Uploaded by

hk993986
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/ 6

Lab Exercises for UNIX

Lab 1

1. Obtain the following results

(i) To print the name of operating system

himanshuamity@golusharma-VirtualBox:~$ uname

Linux

(ii) To print the login name

himanshuamity@golusharma-VirtualBox:~$ logname

himanshuamity

(iii) To print the host name

himanshuamity@golusharma-VirtualBox:~$ hostname

golusharma-VirtualBox

2. Find out the users who are currently logged in and find the particular user too.

himanshuamity@golusharma-VirtualBox:~$ who

himanshuamity tty2 2023-09-21 22:20 (tty2)

3. Display the calendar for

(i) Jan 2000

himanshuamity@golusharma-VirtualBox:~$ cal jan 2000

January 2000

Su Mo Tu We Th Fr Sa

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
(ii) Feb 1999

himanshuamity@golusharma-VirtualBox:~$ cal feb 1999

February 1999

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

(iii) 9 th month of the year 7 A.D

himanshuamity@golusharma-VirtualBox:~$ cal sep 7

September 7

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

(iv) For the current month

himanshuamity@golusharma-VirtualBox:~$ cal

September 2023

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

(v) Current Date Day Abbreviation , Month Abbreviation along with year

himanshuamity@golusharma-VirtualBox:~$ date '+%d/%m/%y'

21/09/23
4. Display the time in 12-Hour and 24 Hour Notations.himanshuamity@golusharma-VirtualBox:~$ date '+24Hour:%T 12
Hour:w%1:%M;%S'

24Hour:22:36:18 12 Hour:w%1:36;18

5. Display the Current Date and Current Time.

himanshuamity@golusharma-VirtualBox:~$ date '+24currentdate: %D %N TIME: %T'

24currentdate: 09/21/23 276413510 TIME: 22:41:07

6. Display the message “GOOD MORNING” in enlarged characters.

7. Display the name of your home directory.

himanshuamity@golusharma-VirtualBox:~$ pwd

/home/himanshuamity

8. Create a directory SAMPLE under your home directory.

himanshuamity@golusharma-VirtualBox:~$ mkdir SAMPLE

9. Create a sub-directory by name TRIAL under SAMPLE.

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ mkdir TRIAL

10. Change to SAMPLE.

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ cd sample

11. Change to your home directory.

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ cd

12. Change from home directory to TRIAL by using absolute and relative pathname.

himanshuamity@golusharma-VirtualBox:~$ cd $home/TRIAL

13. Remove directory TRIAL.

himanshuamity@golusharma-VirtualBox:~$ cd SAMPLE

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ rmdir TRIAL


14. Create a directory TEST using absolute pathname.

himanshuamity@golusharma-VirtualBox:~$ mkdir ./SAMPLE/TRIAL

15. Using a single command change from current directory to home directory.

himanshuamity@golusharma-VirtualBox:~$ cd/SAMPLE/TRIAL

16. Remove a directory using absolute pathname.

himanshuamity@golusharma-VirtualBox:~$ rmdir ./SAMPLE/TRIAL

17. Create files myfile and yourfile under Present Working Directory.

himanshuamity@golusharma-VirtualBox:~$ cat>myfile

himanshuamity@golusharma-VirtualBox:~$ cat>yourfile

18. Display the files myfile and yourfile.

himanshuamity@golusharma-VirtualBox:~$ cat myfile

This is myfile

himanshuamity@golusharma-VirtualBox:~$ cat yourfile

This is your file

19. Append more lines in the myfile and yourfile files.

himanshuamity@golusharma-VirtualBox:~$ cat >> myfile

Add

^d

himanshuamity@golusharma-VirtualBox:~$ cat >> yourfile

Add

^d

20. How will you create a hidden file?.

himanshuamity@golusharma-VirtualBox:~$ cat>.hide

hidden

^d

21. Copy myfile file to emp.

himanshuamity@golusharma-VirtualBox:~$ copy myfile emp


22. Write the command to create alias name for a file.

himanshuamity@golusharma-VirtualBox:~$ ln yourfile aliasname

23. Move yourfile file to dept.

himanshuamity@golusharma-VirtualBox:~$ mv yourfile aliasname~

24. Copy emp file and dept file to TRIAL directory

himanshuamity@golusharma-VirtualBox:~$ cp emp dept../ TRIAL

25. if you compare a file with itself.

himanshuamity@golusharma-VirtualBox:~$ if there is no difference no output

26. Compare myfile file and emp file.

himanshuamity@golusharma-VirtualBox:~$ cmp myfile emp

27. Append two more lines in emp file existing in TRIAL directory.

himanshuamity@golusharma-VirtualBox:~$ cd/SAMPLE/TRIAL

cat>>emp

28. Compare employee file with emp file in TRIAL directory.

himanshuamity@golusharma-VirtualBox:~$ cmp employee emp

cmp: employee: Is a directory

29. Find the difference between the above file.

himanshuamity@golusharma-VirtualBox:~$ diff employee emp

30. Remove the files in the TRIAL directory.

himanshuamity@golusharma-VirtualBox:~/SAMPLE/TRIAL$ rm *

31. Can you remove a directory with files by using a single command.

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ rm -r TRIAL

32. Is there any command available to get back a deleted file?

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ undelete (TRIAL)


33. Rename TRIAL as DATA.

himanshuamity@golusharma-VirtualBox:~/SAMPLE$ rename TRIAL DATA

34. Copy DATA to another directory by name TRIAL.

himanshuamity@golusharma-VirtualBox:~$ cp DATA/same/TRIAl

35. Create a file called dummy in TRIAL and link it to another file by name star.

himanshuamity@golusharma-VirtualBox:~$ ln TRIAL star

36. Link the dummy file in TRIAL to another file by name power in DATA.

himanshuamity@golusharma-VirtualBox:~$ ln -s/SAMPLE/TRIAL/DATA/filename

You might also like