Linux-Day2-Assignment
1. List any two methods of creating files on Linux.
Ans: a. touch
b. cat
2. What is the command to create a directory on Linux?
Ans: mkdir
3. What does ls -lart does? Explain each of the options lart.
Ans:
ls -lart ==> lists all the hidden files in reverse sorting with time(newest first) in long list format
ls – list directory contents
l - use a long listing format
a - do not ignore entries starting with .
r - reverse order while sorting
t - sort by time, newest first; see --time
4. What is the command to recursively copy all the files from /dir1/ to /dir5/
Ans: cp -r dir1 dir5
5. What are two ways to modify permissions on a file?
Ans:
1) Absolute Mode - Use numbers to represent file permissions (the method most commonly used to set permissions). When you change permissions by using the absolute mode, represent permissions for each triplet by an octal mode number.
Ex: chmod 775 filename
2) Symbolic Mode - Use combinations of letters and symbols to add or remove permissions.
Ex: chmod u=x filename
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?
Ans: chmod 550 filename
7. How do you get the last five lines from a log file? Give the command to be used.
Ans: tail -5 logfile
8. If you need to continuously list the last 10 lines from a file, what option is to be used? tail -<>
Ans: tail filename
9. How do you pass the output of one command to the other? Write a command to display the last 2 files from the cal command on the screen.
Ans: cal | tail -2
10. Count the number of lines present in the output of the cal command. Display only the number of lines on the screen.
Ans: Cal | wc - l