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

1.create A Directory Structure in Your Home Directory As Shown in The Diagram. Mkdir - P OFFICE/ (ADMIN/ (BMS, TMS), HR, FINANCE/ (BILLS, PAYROLL) )

The document outlines various commands to create a directory structure, copy and move files between directories, change permissions, compare and search file contents, and display top scorers from a scores file. Key steps include creating an OFFICE directory structure with sub-directories, copying files between directories, renaming files, changing permissions on the ADMIN directory, comparing and searching contents of files, and displaying top 3 scorers from a scores.txt file.

Uploaded by

Lakshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views2 pages

1.create A Directory Structure in Your Home Directory As Shown in The Diagram. Mkdir - P OFFICE/ (ADMIN/ (BMS, TMS), HR, FINANCE/ (BILLS, PAYROLL) )

The document outlines various commands to create a directory structure, copy and move files between directories, change permissions, compare and search file contents, and display top scorers from a scores file. Key steps include creating an OFFICE directory structure with sub-directories, copying files between directories, renaming files, changing permissions on the ADMIN directory, comparing and searching contents of files, and displaying top 3 scorers from a scores.txt file.

Uploaded by

Lakshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.Create a directory structure in your home directory as shown in the diagram.

mkdir -p OFFICE/{ADMIN/{BMS,TMS},HR,FINANCE/{BILLS,PAYROLL}}

2.Find the name of the directory you are currently placed.


$ pwd

3.Display the system date


$date

4.Create three empty files in your home directory with the names file1, file2 and file3.

touch file1 file2 file3;

5.Copy the file file1to the sub-directory HR under OFFICE directory.

cp file1.txt /home/user/OFFICE/HR

6.Rename the file file1 to hrfile.txt

mv /home/user/OFFICE/HR file1.txt /home/user/OFFICE/HR hrfile.txt

7.Copy the file file2 and file3 to the sub-directory BILLS under the sub-directory FINANCE under
OFFICE directory.

Cp file2.txt file 3.txt /home/user/OFFICE/FINANCE/BILLS

8.Rename file2 to billpaid.txt and file3 to billdue.txt

mv file2.txt billpaid.txt

mv file3.txt billdue.txt

9.Change the permissions of the ADMIN directory as below


Owner – All permissions
Group – Read and Execute permissions
Others – Read permission

chmod u=rwx,g=rx,o=r

10.Copy the directory HR to another directory with name HR_new

cp -r /home/user/OFFICE/HR HR_new

11. Copy the file inside the directory HR to another directory with name TEMPDIR.

cp /home/user/OFFICE/HR hrfile.txt /home/user/TEMPDIR

12.Delete the file inside the directory HR_New and then delete the directory HR_new

rm /home/user/OFFICE/HR/HR_new/hrfile.txt
rmdir /home/user/OFFICE/HR/HR_new

13.Delete the directory TEMPDIR at one go.


mkdir/home/user/TEMPDIR

14. List all the files in your home directory with all the attributes.

$lsattr

15.List all the text files in your home directory.

$ls *.txt

16.List the users currently logged in.

$w

17. Compare the file sample.txt inside the directory ADMIN with the file hrfile.txt inside the directory
HR.

$cmp /home/user/OFFICE/ADMIN/sample.txt /home/user/OFFICE/HR/HR_new/hrfile.txt

18.List the common lines between the two files mentioned in the previous question.

$com -12 /home/user/OFFICE/ADMIN/sample.txt /home/user/OFFICE/HR/HR_new/hrfile.txt

19. Display the lines which starts with the word “This” in the file sample.txt inside the directory
ADMIN.

Grep “^This” 12 /home/user/OFFICE/ADMIN/sample.txt

20. Display the count of lines having the word “sample” in the file sample.txt. The search should be
case-insensitive.

grep sample /home/user/OFFICE/ADMIN/sample.txt |wc-l

21. Find all the empty files inside the directory OFFICE and delete them.

find /home/user/OFFICE -type d -empty -delete

22. Create a file called scores.txt in your home directory with the following content

Roll No|Name|Score
1|Raghu|80
2|Hari|50
3|Ram|80
4|Asha|40
5|Radha|60
Display the name of the top 3 scorers from the data stored in the file scores.txt.

You might also like