# linux day -2 assignment

**1 . List any two methods of creating files on Linux**

1.) By using the touch command ex: touch filename

2.) By using vi editor

ex: vi filename

**2 . What is the command to create a directory on Linux.**

the command to create a directory on linux

by using mkdir command

example: mkdir directory-name

**3 . What does ls  -lart does. Explain each of the option lart**

ls": This is the basic command to list files and directories in a directory.

"-l": This flag is used to display the listing in a long format, providing detailed information about files and directories, such as permissions, ownership, size, and timestamps.

"-a": This flag is used to show hidden files and directories (those starting with a dot).

"-r": This flag is used to reverse the order of listing, showing files in reverse order.

"-t": This flag is used to sort the listing by modification time, showing the most recently modified files first.

**4 . What is the command to recursively copy all the files from /dir1/ to /dir5/**

cp -r dir1/\* dir5/

**5 . What are two way to modify permissions on a file.**

* absolute mode
    
* octal notation
    
* symbolic notation
    

**6 . If you want to update permissions on a file so that only the owner and group have read and execute permissions. What is the command to be used.**

chmod 550 file\_name

To give the owner full permissions and others only read and execute permissions: chmod 755 directoryname

To give the user write permission on a file: chmod u+w filename

**7 . How do you get last five lines from a log file. Give the command to be used.**

the command to be used as

tail -n 5 filename

**8 . If you need to continuous list last 10 lines from a file, what option is to be used. tail  -&lt;&gt;**

command is used

tail - f -n 10 filename.log

**9 . How do you pass the output of one command to the other. Write a command to display last 2 files from the cal command on the screen.**

cal | tail -n 2

**10 . Count the number of lines present in the output of cal command. Display only number of lines on screen.**

cal | wc -l
