Linux Day 2
Assignment
List any two methods of creating files on Linux.
Ans: By using the touch command. Ex: touch filename
By using vi editor. Ex: vi filename
What is the command to create a directory on Linux.
Ans: mkdir command. Ex: mkdir directory-name
What does ls -lart does. Explain each of the option lart
Ans: "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.
What is the command to recursively copy all the files from /dir1/ to /dir5/
Ans: cp -r dir1/* dir5/
What are two way to modify permissions on a file.
Ans: absolute mode, octal notation, symbolic notation
If you want to update permissions on a file so that only owner and group have read and execute permissions. What is the command to be used.
Ans: chmod 550 file_name
How do you get last five lines from a log file. Give the command to be used.
Ans: tail -5 filename
If you need to continuous list last 10 lines from a file, what option is to be used.
Ans: tail -<> or tail -f -n 10 filename.log
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.
Ans: By using pipe command(|)
cal | tail -n 2
Count the number of lines present in the output of cal command. Display only number of lines on screen.
Ans: cal | wc -l