33% found this document useful (3 votes)
365 views

Basic Linux1

This document provides instructions for basic file manipulation tasks using Linux commands like cp, mv, and cat. It contains 8 questions that ask the user to copy, rename, concatenate, and list files and directories using these commands in a practice directory structure under /home/caine. The questions cover tasks like copying files between directories with and without renaming, renaming files within directories, concatenating files, and listing files that match certain patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
33% found this document useful (3 votes)
365 views

Basic Linux1

This document provides instructions for basic file manipulation tasks using Linux commands like cp, mv, and cat. It contains 8 questions that ask the user to copy, rename, concatenate, and list files and directories using these commands in a practice directory structure under /home/caine. The questions cover tasks like copying files between directories with and without renaming, renaming files within directories, concatenating files, and listing files that match certain patterns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Instructor Luong Duy Hieu – Contact: [email protected].

vn

BASIC LINUX
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
Create directory:

cd /home
mkdir caine
cd caine
mkdir test1 mydir1 data
touch lines words info
cd test1
touch file1 file2 file3 file4
cd ../mydir1
touch info1 info2
cd ../data
touch data1 data2
1. COPY file1 from test1 to data. Keep the name as file1.

04.02e-BM/DH/HDCV/FU 1/2 1/2


Cp home/caine/test1/file1 home/caine/data
2. COPY file2 from test1 to data. Change the name as you copy the file to the new name of
filecopy1
cp home/caine/test1/file2 home/caine/data/copy1
3. Rename info1 to newinfo1. Do not move it out of mydir1 ?
Mv home/caine/mydir1/info1 
home/caine/mydir1/newinfo1
4. Change directory into mydir1, and then copy "lines" into the current directory.
Cd home/caine/mydir1
cp ­r ../lines .
5. Still in mydir1, concatinate info2 and lines, saving the output as "joined".?

Cat info2 lines > joined
6. Still in mydir1, concatinate info2 and lines and file1 from test1, saving the output as
"joined2".?
Cat info2 lines ../file1/test1 > joined2
7. Make a new direction in /home/caine called "etccopy". Now copy from /etc to your new
directory all the files which begin with a "u" and end with ".conf". Only copy from /etc and not
from any sub-directories?

Cd home/caine
mkdir etccopy
Cp /etc/[u]*[.conf] etccopy
8. List all the file and directory names in /etc which have 1 or more numbers in their name.
Remember to use "-d" in the ls command, and do not decend into subdirectories (i.e. no
recursion). 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.

Cd /etc/
ls ­d *[0­9]* >> /home/caine/digit

04.02e-BM/DH/HDCV/FU 1/2 2/2

You might also like