If you can see this check that

Main Page

Copying and head/tail


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: 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/caine. The resulting tree looks like:

/
+--- home
     |
     +--- caine
          |
          +--- 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/caine 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.

Tests - not attempted
/home/caine/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 caine'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/caine/digit exists UNTESTED
files listed UNTESTED

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

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

Question 2: 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/caine/120. Hint: there are 31 lines from 120 to 150 inclusive...

Tests - not attempted
/home/caine/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


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 9.0: Essentials | Basic | Search | SysIntro | 5a | 5b | 5c | 6 | 7a | 7b | 8a | 8b | Browser
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 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions
Site Links:XMLZoo ActiveSQL ProgZoo SQLZoo

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