- All right. Let's start.
And let me do mkdir -p /tmp/files/pictures
so that we have this destination directory.
And now, I can use find files smaller than 1,000 bytes.
It might be a good idea to go in the main page of find
and to search for the -size option to figure out
how to use it precisely.
And there, we can see the size option
as a plus n, a minus n, and an n.
So that is for greater than, less than, or exactly.
And also, if you use a size option,
you should know how exactly to specify it.
And it might be a little bit surprising,
but the default is if you do specify a number,
then you will search for files based
on a size in 512-byte blocks.
So don't specify just 1000.
You need to specify 1000c.
c is for bytes.
So based on that, I think we can do it.
And we are going to do sudo find.
Why sudo?
For the simple reason that I want to include files
that are not readable for ordinary users as well.
So sudo find /etc/ -size -1000c.
And that is what we are going to exec.
So exec cp {} to refer to the result of the find command
/tmp/files/pictures.
And of course, we need to close it
with a backslash and semicolon.
So here we go.
It's asking for the sudo password.
And CP is complaining that we did not specify the -r option
so it's omitting directories,
but this is what we needed to do.
And a quick ls -(laughs) /tmp/files/ pictures will show us
that indeed it has done it
and it has done it successfully.
Right. The next thing that we are going to do
we are going to the tmp/files directory
because we needed to create a symbolic link.
So ln -s var /var.
Is that the right way of doing it?
No. That's not the right way of doing it for two reasons.
Reason number one, it failed to create symbolic link var/var
so it's confused about what we want to create.
That's a permission denied.
So permission denied.
That is what we fixed with sudo
but then we need to specify the right way.
And the right way is that I want to create a symbolic link
to the var directory,
and the resulting symbolic link is the name var.
So this is the command that we need.
And if you do an ls -ld on ... Oops, an ls -ld on var,
I need a relative file name here, not an absolute file name.
Then we can see that this is a symbolic link pointing
to the var directory.
And hey, everybody, in this assignment,
it comes automatically, but don't forget that symbolic links
needs to contain an absolute file name.
Then we are going to create an archive.
So let's do sudo again, sudo tar czvf,
and the file we create is home.tgz
and we create the archive of the home directory.
That should be doing it.
And about the extension tgz, it's another commonly-seen
extension for archives that have been made with tar
and compressed with the gz utility.
So if I'm using ls -l, then we can see the home.tgz has been
created successfully with the size of 95 megabytes in total.
And if I want to extract that, well,
I can use mkdir /tmp/archive to first create directory.
And then we can use sudo tar xvf of home.tgz.
And we extract it using -C to /tmp/archive.
The -C make sure that we move into that directly
to put it right there.
And, oh boy, we are getting a problem.
What is going wrong?
Well, what is going wrong is a so-called typo.
Do you see that, sudo tar zvf?
That's wrong. That should be xvf.
And that is doing so much better.
Let's do a final check.
If I'm using ls on /tmp/archive, then what do we see?
We see the contents of the home directory.
And if I would use the tree command,
then the tree command is showing the tree view
and this is really the home directory.
That's what we needed.
And with that, we are done.