0% found this document useful (0 votes)
5 views11 pages

Basic Unix Commands Overview

The document outlines a laboratory assignment focused on basic Unix commands for file and directory management. It includes a list of commands such as who, date, mkdir, and grep, along with their functionalities. Additionally, it provides practical tasks requiring the application of these commands to create, manipulate, and display files and directories.

Uploaded by

lg.deba123
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)
5 views11 pages

Basic Unix Commands Overview

The document outlines a laboratory assignment focused on basic Unix commands for file and directory management. It includes a list of commands such as who, date, mkdir, and grep, along with their functionalities. Additionally, it provides practical tasks requiring the application of these commands to create, manipulate, and display files and directories.

Uploaded by

lg.deba123
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

Laboratory Assignment 1

AIM : Basic Commands in Unix Operating System.


Objective of this Assignment:
To study the basic commands such as who, who am i, date, cal, pwd, man, mkdir,
cd, rmdir, cat, mv, cp, rm, wc, sort, head, tail, cmp, diff, ls, chmod, grep, echo for
accessing files and directories.

Answer:-
1. who – Displays all users currently logged into the system, showing their terminal
and login time.

2. whoami – Shows the username of the user currently using the terminal.

3. date – Prints the current system date and time; can display custom formats.

4. cal – Displays a calendar for the current month or a specified month/year.

5. pwd – Shows the full path of the current working directory.


6. man – Opens the manual page of a command, detailing its usage, options, and
examples.

7. mkdir – Creates a new directory; use -p to create nested directories.

8. cd – Changes the current directory to the specified path.

9. rmdir – Removes an empty directory; use rm -r for non-empty directories.

10. cat – Displays contents of a file, concatenates multiple files, or creates new
files.
11. mv – Moves files or directories to another location or renames them.

12. cp – Copies files or directories; use -r to copy directories recursively.

13. rm – Deletes files or directories; -r removes directories with contents.

14. wc – Counts lines, words, and characters in a file; options -l, -w, -c specify
counts.

15. sort – Sorts lines of a file alphabetically or numerically; supports reverse and
unique sorting.
16. head – Displays the first N lines of a file (default 10); useful for previewing
content.

17. tail – Displays the last N lines of a file (default 10); -f option allows live
monitoring.

18. cmp – Compares two files byte by byte and reports the first difference.
19. diff – Compares two files line by line and shows differences in a readable
format.

20. ls – Lists files and directories in the current location; -l shows details, -a shows
hidden files.

21. chmod – Changes file or directory permissions for owner, group, and others.

22. grep – Searches for specific patterns or text in files; supports case-insensitive
and recursive search.

23. echo – Prints text or variable values to the terminal; used in scripts and output
redirection.
Question:-
1. Write the commands to create the following directory hirarchy: -> DOS_Regdno
→DOSass1→dir1

2. Write the commands to create another directory with name dir2 in directory DOSass1
and make dir2 as the current working directory.

[Link] the command to delete the directory dir2 , when DOS_Regdno will be the current
working directory.
4. Write the command to create a file named as file1 using cat command inside dir1. Write
your name, regdno, branch, semester and section in file1. Then display the content of the
file.

5. Write the command to create a file named as file2 using cat command inside dir1. Write
your semester wise SGPA in file2.

6. Create a file named as file3 storing content of file1 merged with content of file2.

[Link] the command to rename file2 as markinfo.


[Link] the command to copy the content of file1 to reginfo.

[Link] the command to display the inode values of file1,markinfo, reginfo.

[Link] the command to delete file1.

[Link] the command to count the number of lines, words, characters in markinfo.

[Link] the command to create a file named as Personalinfo inside dir1. Write your name,
regdno, address in the file.

13. Write the command to display the content of markinfo in reverse order.
[Link] the output of the following command:
cmp reginfo personalinfo
diff reginfo personalinfo

15. Write a command to count the number of files in the current working directory and
display that number.

16. Write a command to include all the file names present in a current working directory in a
file named as filelist without causing filelist to be included in the names.

17. Write a command to give write permission to all the users of file reginfo.

[Link] a command to discard write permission from group users group users of file
reginfo.
[Link] the command to set rwx permissions for all the users of file reginfo.

[Link] between following commands:


date; pwd
date; pwd | wc -l
(date; pwd) | wc -l

[Link] the output of the following commmands:


echo ***
echo '***'
echo \***
echo \*\*\*
echo */*
echo Don't do this
echo “Don't do this” (Quotes of one kind protect quotes of other kind)
echo Hello # world
echo “ Hello # world”
echo ' Hello # world'
echo date
echo 'date'
echo “date”
echo `date`

You might also like