If you can see this check that

Main Page

Essential Basic Centos


Basic File Control

User:
Password:

Objectives

This practical covers:

cp
mv
cat
less
more
tail
head
wc
chmod
pipes and redirection
basic permissions
Filename wildcards.

To reset all the check buttons from a previous attempt click here

Question 1: Create demo account

To follow along with the examples shown here using the virtual machines is it safer to use an account other than the administration account (root). By pressing the button below a new account is created called "demo", password is also "demo". Log in using this account and you cannot do any damage. If you mess the account up and want to start again, just press the button again.

Once created, you can log into this account using telnet or ssh, logging into the hostname linuxzoo.net. Remember the username is demo and the password is demo. And remember, you cannot break anything using this account! The account begins with an empty directory, so dont be shocked that "ls" shows nothing...

MAKE SURE YOU USE THE USER demo. If you do this with "root" or another account, you will be marked wrong. If you start with the wrong user, make sure you delete any files you created wrongly before changing to demo.

Tests - not attempted
Create an account called demo, password demo UNTESTED

Question 2: cp,mv, and cat

This question covers basic file manipulation. To begin this question use the first button to set up a small file and directory tree in /home/demo. The resulting tree looks like:

/
+--- home
     |
     +--- demo
          |
          +--- test1
          |    +--- file1
          |    +--- file2
          |    +--- file3
          |    +--- file4
          |
          +--- mydir1
          |    +--- info1
          |    +--- info2
          |
          +--- data
          |    +--- data1
          |    +--- data2
          |
          +--- lines
          +--- words
          +--- info

You only have to press the button to create this tree. You do not create this structure yourself. It is completely automatic. If you lose this structure or accidentally delete it then you can press the button again to restore the struture.

Tests - not attempted
Setup complete UNTESTED

COPY file1 from test1 to data. Keep the name as file1.

Tests - not attempted
File1 still in test1 UNTESTED
File1 is identical in test1 and data UNTESTED

COPY file2 from test1 to data. Change the name as you copy the file to the new name of filecopy1.

Tests - not attempted
File2 still in test1 UNTESTED
File2 in test1 is identical to filecopy1 UNTESTED

Rename info1 to newinfo1. Do not move it out of mydir1.

Tests - not attempted
info1 is gone UNTESTED
mydir1 is present and ok UNTESTED

Change directory into mydir1, and then copy "lines" into the current directory.

Tests - not attempted
lines still ok UNTESTED
lines copied ok UNTESTED

Still in mydir1, concatinate info2 and lines, saving the output as "joined".

Tests - not attempted
Concat successful UNTESTED

Still in mydir1, concatinate info2 and lines and file1 from test1, saving the output as "joined2".

Tests - not attempted
Concat successful UNTESTED

Make a new directory in /home/demo called "etccopy". Now copy all of the files which begin with a "u" and end with ".conf" from /etc to your new directory. Only copy from /etc and not from any sub-directories (i.e. not recursively).

Tests - not attempted
/home/demo/etccopy exists UNTESTED
files copied UNTESTED

List all the file and directory names in /etc which have 1 or more numbers in their name. Do not descend into subdirectories (i.e. no recursion). Remember to use "-d" in the ls command. Save this list in demo's home directory as a file called "digit". Do the "ls" command when CDed to /etc, thus your names avoid having "/etc/" stuck in front of them.

Tests - not attempted
/home/demo/digit exists UNTESTED
files listed UNTESTED

Redo the previous question, except this time repeat the exercise when CDed in /home/demo. Save the output in digit2. "digit" and "digit2" should be identical, except in "digit2" all the filenames will begin "/etc/".

Tests - not attempted
/home/demo/digit2 exists UNTESTED
files listed UNTESTED

Question 3: Head and Tail

In this question you will be practicing with the head and tail command. Remember these commands take a parameter (starting with a minus) which indicates how many lines from the head or tail to print to the screen.

As an example consider:

head -1 /etc/passwd

The above command will give one line from the head (start) of the file /etc/password.

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"?

Line 10 from end shows:

The question uses the structure created at the start of question 1, so press that button again if you are returning and discover that tree is missing.

Tests - not attempted
Line identified UNTESTED

What 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.

Line 5000 from start shows:

Tests - not attempted
Word 5000 identified UNTESTED

If you do an "ls" in /etc, what is the 100th filename?

File 100 in /etc:

Tests - not attempted
File 100 identified UNTESTED

If you do an "ls" in /etc, what is the 100th filename from the END?

File 100 from last in /etc:

Tests - not attempted
File 100 from end identified UNTESTED

Using 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...

Tests - not attempted
/home/demo/120 exists UNTESTED
120 correct UNTESTED

In 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).

Number of characters on concat 167:

Tests - not attempted
Character count UNTESTED

Question 4: Permissions and chmod

In this question you are reqired to demonstrate your knowledge of symbolic and numeric permissions, both in reading current settings and in setting permissions for existing files.

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

Symbolic permissions:

Tests - not attempted
Correct permissions UNTESTED

What is this permission if it was encoded in numeric (octal) notation? Use the form 0666.

Numeric permissions:

Tests - not attempted
Correct permissions UNTESTED

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.

Tests - not attempted
info permissions ok UNTESTED

Do the follow question in your head. Do not actually do this to the info file.

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.

Numeric permissions:

Tests - not attempted
Correct Numeric Permissions UNTESTED

Now in Linuxzoo, take away write permissions for other on the info file.

Tests - not attempted
info permissions ok UNTESTED

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.

Tests - not attempted
info permissions ok UNTESTED

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?
Allowed Access:

Tests - not attempted
Correct Permission UNTESTED

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?
Allowed Access:

Tests - not attempted
Correct Permission UNTESTED

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?
Allowed Access:

Tests - not attempted
Correct Permission UNTESTED

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!

Tests - not attempted
Changed correctly UNTESTED

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.

Tests - not attempted
Changed correctly UNTESTED


Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
Caine 13.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Registry | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2024 Edinburgh Napier University