0% found this document useful (0 votes)
32 views2 pages

UNIX Practice Questions

The document contains a series of UNIX practice questions covering basic system commands, pipeline commands, file copying, moving/renaming, deletion commands, calculator commands using 'bc', and directory navigation and creation. Each section includes specific tasks that require writing commands to perform various operations in a UNIX environment. The questions are designed to test and enhance the user's proficiency with UNIX command-line operations.
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)
32 views2 pages

UNIX Practice Questions

The document contains a series of UNIX practice questions covering basic system commands, pipeline commands, file copying, moving/renaming, deletion commands, calculator commands using 'bc', and directory navigation and creation. Each section includes specific tasks that require writing commands to perform various operations in a UNIX environment. The questions are designed to test and enhance the user's proficiency with UNIX command-line operations.
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

UNIX Practice Questions

Basic System Commands


1. Write a command to print the full path of the directory you are currently working in.
2. Write a command to display the list of all users currently logged into the system.
3. Write a command to print the username of the person currently logged in.
4. Write a command to display the current system date and time.
5. Write a command to display only the current year using formatting options of the date
command.
6. Write a command to show the calendar of the present month.
7. Show the calendar for August 2028.
8. Write a command to display the calendar for the entire year 2027.

Pipeline Commands
9. Write a command using a pipeline to list all files in the current directory and count how
many entries are there.
10. Display the contents of [Link] and count how many lines it contains using a
pipeline .
11. View a large file named [Link] page by page and also count the total number of
words in it using a pipeline .
12. Check how many files are there in a directory and show the number. Use pipeline for
the task.
13. Display [Link] page by page and count how many lines are in the file using a
pipeline .

File Copying Commands


14. Create a file named [Link] and write 20 lines in it. Write a command to copy it to a
new file called [Link] in the same directory.
15. Assume a directory /home/student/docs exists. Copy [Link] from the current
directory into that directory.
16. Copy [Link] , [Link] , and [Link] into a directory named archive .
17. There is a directory named project. Write a command to copy the entire directory
(including subdirectories and files) into /backup .
18. Copy [Link] to data_backup.txt but prompt before overwriting if the file already
exists.
File Moving/Renaming Commands
19. Rename [Link] to [Link] using the mv command.
20. Move [Link] from the current directory to /home/user/pictures .
21. Copy [Link] to [Link] only if [Link] is newer than [Link] .
22. Move [Link] to report_final.txt , but keep a backup of the existing destination
file if it already exists.

File Deletion Commands


23. Write a command to delete a file named [Link] .
24. Delete [Link] , [Link] , and [Link] using a single command.
25. Delete [Link] but ask for confirmation before removing it.
26. Delete [Link] without showing any warning or confirmation.
27. Delete an empty directory named backup .
28. Delete a directory named project along with all files and subdirectories inside it.
29. Delete a directory testdir and all its contents, but ask before each deletion.
30. Delete empty directories named dir1 , dir2 , and dir3 in one command.

Calculator Commands bc
31. Use bc to calculate the result of: 25 + 37
32. Use bc to divide 10 by 3 and display the result up to 2 decimal places.
33. Use bc to calculate 5 raised to the power 3.
34. Use bc to find the square root of 144.
35. Use bc to evaluate the expression: (8 + 2) × 5 – 6

Directory Navigation and Creation


36. Write a command to create a directory named projects.
37. Create a directory structure college/bca/semester1 in a single command.
38. Write a command to move into the directory /home/user/docs .
39. You are inside /home/user/docs/reports . Write a command to move one level up.
40. Create a directory named practice and then move into it using commands.

You might also like