BasicShell
Question 3: Head and Tail
What is the first line printed if you tail the last 10 lines of the file "lines"... i.e. what is the line 10 lines from the end of "lines"?
tail -n 10 linesWhat is the word which appears on line 5000 of the file "words". Use a pipe with head and tail to make life easy... The test is CASE SENSITIVE.
head -n 5000 wordsIf you do an "ls" in /etc, what is the 100th filename?
ls /etc/ | head -100
gssIf you do an "ls" in /etc, what is the 100th filename from the END?
ls /etc/ | tail -100
pnm2ppa.confUsing head and tail, store the filenames printed on lines 120 to 150 inclusive when doing an ls in "/etc". Save the names in a file called /home/demo/120. Hint: there are 31 lines from 120 to 150 inclusive...
# Hint: there are 31 lines from 120 to 150 inclusive...
ls -d * | head -150 | tail -31 > /home/demo/120
cat /home/demo/120 | wc -lIn the concatination of file1, file2, file3, and file4 in test1, how many characters are there on line 167? Hint: use the wc command to count the characters (thus include the newline character).
cat * | head -167
echo 'mail:x:12:postfix' | wc -c
18Question 4: Permissions and chmod
What is the current symbolic permissions on "info" in /home/demo? Use the format "-rwxrwxrwx". Do not include any extended permissions if any are present
What is this permission if it was encoded in numeric (octal) notation? Use the form 0666.
Change the permissions on info so that user demo can read, write, and execute, group tutorial can read and execute, and other can write and execute.
Assume you now have to set the file info using numeric notation. Preserving all permissions except group, what would be the numeric notation for giving group just execute permissions? Again use the format 0777.
Now in Linuxzoo, take away write permissions for other on the info file.
Change the permissions again of info so that anyone in group tutorial can read the file but not write or execute it. Leave the other permissions unchanged.
Given a file owned by "gordon" in group "users", and a numeric permission code of 0654, what would user "demo" of group "demo" be allowed to do?
Given a file owned by "gordon" in group "demo", and a numeric permission code of 0654, what would user "demo" of group "demo" be allowed to do?
Given a file owned by "demo" in group "users", and a symbolic permission code of "-rw-rwx--x, what would user "demo" of group "demo" be allowed to do?
Adjust the info file once more so that a user "gordon" in group "tutorial" would only be allowed to write and execute the file info. Again do not change any other file permissions other than that required to answer this question. It might be an idea to note the current permissions just in case you have to try again!
Adjust the permissions on info once again, so that group would have the octal permission 4, and the owner would have the symbolic permission of "rw", and others would have permissions to read only.
Last updated