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

OS_Lab_Assignment_III_PartB_QA

This document is a lab assignment for the MCA 2nd Semester at Gurunanak Institute of Technology, focusing on Unix commands. It includes a series of questions and answers related to file management, directory operations, and system commands. The assignment covers various tasks such as creating directories, displaying information, and manipulating files using command-line instructions.
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 views3 pages

OS_Lab_Assignment_III_PartB_QA

This document is a lab assignment for the MCA 2nd Semester at Gurunanak Institute of Technology, focusing on Unix commands. It includes a series of questions and answers related to file management, directory operations, and system commands. The assignment covers various tasks such as creating directories, displaying information, and manipulating files using command-line instructions.
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/ 3

GURUNANAK INSTITUTE OF TECHNOLOGY

MCA 2nd Semester 2024-2025 - OS Lab (Unix)

Lab Assignment - III (Part B: Questions and Answers)

Q1. 1. Make a Directory and make it current Directory


mkdir mydir
cd mydir

Q2. 2. Show Present Working Directory


pwd

Q3. 3. Show the calendar of the 9th month of the year 2009.
cal 09 2009

Q4. 4. Display current date in the format "MM/DD/YY"


date +%m/%d/%y

Q5. 5. Display a full weekday name, full month name, day of the year, hour
date '+%A, %B %d, %j, %H:%M'

Q6. 6. Create a file to store information about your college. Display the content of file. Show only first
4 lines of the file. Show also only last 3 lines of the file.
echo 'Your College Info' > college.txt
cat college.txt
head -n 4 college.txt
tail -n 3 college.txt

Q7. 7. To append one file to another i.e. to copy the content of file1 to file2 (at the end of file2).
cat file1 >> file2

Q8. 8. Create file3 with the content of file1 & file2


cat file1 file2 > file3

Q9. 9. Remove a file/directory


rm filename
rmdir dirname

Q10. 10. Change file attributes


chmod 755 filename

Q11. 11. Rename a file and a directory.


mv oldfile newfile
mv olddir newdir

Q12. 12. Sort a file in descending order.


sort -r filename

Q13. 13. List all directories only


ls -d */
Q14. 14. List files in long form
ls -l

Q15. 15. List files sorted by last modified time


ls -lt

Q16. 16. List all files with single character or double character extension.
ls *.? *.??

Q17. 17. In a file perform (i) Line count (ii) Word count (iii) Character count
wc -l filename
wc -w filename
wc -c filename

Q18. 18. List files which start with d or o and with t or x


ls | grep -E '^[do]' | grep -E '[tx]$'

Q19. 19. List all files, which are not started with t but s.
ls | grep -v '^t' | grep '^s'

Q20. 20. Change the content of a file in upper case only.


tr 'a-z' 'A-Z' < file.txt

Q21. 21. Mount the floppy & CD-Rom drive


# Depends on OS. Example:
sudo mount /dev/fd0 /mnt/floppy
sudo mount /dev/cdrom /mnt/cdrom

Q22. Copy a file to a floppy


cp file.txt /mnt/floppy

Q23. Copy a file from floppy to your own directory


cp /mnt/floppy/file.txt ~/

Q24. 22. Create a file using vi editor and perform given actions
vi file.txt
# Use vi commands:
# i (insert), :w (save), :set number, o (new line), x (delete char), dd (delete line), u
(undo), /search, :s/old/new/
# Practice required in vi editor.

Q25. 23. Compare two files


diff file1 file2

Q26. 24. Find the Common of two files


comm -12 <(sort file1) <(sort file2)

Q27. 31. Find the type of file


file filename

Q28. 32. Create one hidden file and show all the hidden files.
touch .hiddenfile
ls -a

Q29. 33. Create file1, file2 and file3 using a single command.
touch file1 file2 file3

Q30. 34. Find out who's logged on


who

Q31. 35. Know your terminal


tty

You might also like