1
00:00:00,001 --> 00:00:05,003
(upbeat music)

2
00:00:05,003 --> 00:00:07,002
- [Instructor] Let's do a couple challenges related

3
00:00:07,002 --> 00:00:10,001
to system calls to get a little better idea

4
00:00:10,001 --> 00:00:12,002
about their usage.

5
00:00:12,002 --> 00:00:16,007
So we want to use the strace command again, right?

6
00:00:16,007 --> 00:00:19,004
That's all about system calls.

7
00:00:19,004 --> 00:00:22,004
So use the man page for strace

8
00:00:22,004 --> 00:00:27,003
and search for it for a summary option that shows a count

9
00:00:27,003 --> 00:00:30,004
of the number of times each system call

10
00:00:30,004 --> 00:00:32,009
was called by a process.

11
00:00:32,009 --> 00:00:36,000
And then try that out when you run the date command

12
00:00:36,000 --> 00:00:40,005
to find out which system call was called the most number

13
00:00:40,005 --> 00:00:43,005
of times when you ran date.

14
00:00:43,005 --> 00:00:45,008
Second challenge, and this one's a little tricky,

15
00:00:45,008 --> 00:00:47,003
is using strace,

16
00:00:47,003 --> 00:00:50,008
can you figure out which system call is used

17
00:00:50,008 --> 00:00:53,000
to change directory?

18
00:00:53,000 --> 00:00:57,006
And then the last one, this one's also a little bit tricky.

19
00:00:57,006 --> 00:00:59,003
Create a one line shell script

20
00:00:59,003 --> 00:01:03,000
that just does date space greater than /def/null.

21
00:01:03,000 --> 00:01:07,004
Then use strace with the minus F option,

22
00:01:07,004 --> 00:01:12,000
which will follow processes as they get started.

23
00:01:12,000 --> 00:01:14,007
And the minus O option

24
00:01:14,007 --> 00:01:17,003
where you give a file name which gets created

25
00:01:17,003 --> 00:01:20,000
and the trace goes into that file,

26
00:01:20,000 --> 00:01:23,002
and then use that to follow the new processes

27
00:01:23,002 --> 00:01:25,003
and all the output and so forth.

28
00:01:25,003 --> 00:01:30,002
When you run your script with the bash command

29
00:01:30,002 --> 00:01:33,006
to run date and redirect the output to /def/null.

30
00:01:33,006 --> 00:01:36,008
The idea is we want to find out

31
00:01:36,008 --> 00:01:40,006
is it the date process that opens /def/null,

32
00:01:40,006 --> 00:01:44,008
or is it the Bash process that opens /def/null

33
00:01:44,008 --> 00:01:49,009
before the Bash process starts up the date command?

34
00:01:49,009 --> 00:01:51,000
Good luck.

