1
00:00:00,850 --> 00:00:01,270
Hello.

2
00:00:01,270 --> 00:00:02,920
Welcome to another lecture of our course.

3
00:00:02,920 --> 00:00:09,610
In this lecture you will learn about how to handle, create, modify and delete files so the shell provides

4
00:00:09,610 --> 00:00:12,850
many file manipulation commands on the Linux file system.

5
00:00:12,850 --> 00:00:18,970
This lecture we will walk through the basic commands and the basic shell commands you need to handle

6
00:00:18,970 --> 00:00:19,510
files.

7
00:00:19,510 --> 00:00:20,740
So let's get started.

8
00:00:20,740 --> 00:00:21,490
My name is Stefan.

9
00:00:21,490 --> 00:00:23,470
Welcome to another lecture of our course.

10
00:00:34,960 --> 00:00:40,180
Every once in a while you run into a situation where you need to create an empty file.

11
00:00:40,210 --> 00:00:47,080
For example, sometimes applications accept a log file to be present before they can write to it.

12
00:00:47,110 --> 00:00:53,290
In these situations, you can use the touch command to easily create an empty file.

13
00:00:53,290 --> 00:00:59,020
In order to do that, for example, touch and my test file here.

14
00:00:59,020 --> 00:01:01,840
And as you can see here, we create a touch my test file.

15
00:01:01,840 --> 00:01:06,700
So the touch command creates the new file.

16
00:01:06,700 --> 00:01:12,310
You specify and assigns your username as the file owner like this.

17
00:01:12,310 --> 00:01:17,110
So as you can see, my username is the file owner and my machine is Kali here.

18
00:01:17,680 --> 00:01:26,980
So notice in this example that the file size is zero because the touch command just created an empty

19
00:01:27,010 --> 00:01:31,210
file so that touch command can also be used to change modification time.

20
00:01:31,210 --> 00:01:34,580
So this is done without changing the file contents.

21
00:01:34,580 --> 00:01:44,150
So we will do for example, and as you can see here, 313 and and as you can see, this is 313 now.

22
00:01:44,150 --> 00:01:51,740
So let's create again and my test file two and here LSL Clear.

23
00:01:52,070 --> 00:01:57,350
LSL And as you can see here, these have different times.

24
00:01:57,350 --> 00:02:00,350
They also created a time frames so.

25
00:02:04,620 --> 00:02:05,040
Yeah.

26
00:02:05,040 --> 00:02:12,870
And actually, if you if you want to update this file like this so you can also write test file, write

27
00:02:12,870 --> 00:02:15,030
the same name and.

28
00:02:16,230 --> 00:02:20,490
And as you can see here, we updated file time here.

29
00:02:20,490 --> 00:02:26,460
So creating empty files and altering file temp steps is not something you will do on a Linux system

30
00:02:26,460 --> 00:02:27,030
daily.

31
00:02:27,060 --> 00:02:32,420
However, copying files is an action you will do often while using Shell.

32
00:02:32,430 --> 00:02:35,070
So let's get started with copying files here.

33
00:02:35,070 --> 00:02:40,050
So copying files and directories from one location in the file system to another is a common practice

34
00:02:40,050 --> 00:02:41,850
for system administrators.

35
00:02:41,850 --> 00:02:44,760
So the CP command provides this feature.

36
00:02:44,760 --> 00:02:46,470
It is most basic form.

37
00:02:46,470 --> 00:02:52,160
The CP command uses two parameters, so two parameters.

38
00:02:52,170 --> 00:02:54,750
The first parameter is that CP.

39
00:02:56,230 --> 00:02:58,130
Is the source object.

40
00:02:58,130 --> 00:03:02,030
So in this case, we're going to firstly assign source.

41
00:03:02,630 --> 00:03:06,110
And after that, we will enter the destination.

42
00:03:06,930 --> 00:03:08,400
Destination.

43
00:03:13,080 --> 00:03:23,790
So here, when both source and destinations are parameters or file names, the CP command copies the

44
00:03:23,790 --> 00:03:27,060
source file to a new destination file.

45
00:03:27,820 --> 00:03:34,420
So the new file acts like a brand new file and with an updated modification time.

46
00:03:34,420 --> 00:03:37,230
So for example, let's do following here.

47
00:03:37,240 --> 00:03:40,380
LSL And here we have my test file.

48
00:03:40,390 --> 00:03:40,990
My test file.

49
00:03:41,170 --> 00:03:48,700
So let's copy my test file to the same location, but change the name to test here.

50
00:03:48,700 --> 00:03:50,710
Test file.

51
00:03:50,710 --> 00:03:53,490
Yeah, test file and let's do it.

52
00:03:53,500 --> 00:03:57,280
So we're going to do in order to do that, we're going to do my test file.

53
00:03:57,310 --> 00:03:59,950
Firstly, we're going to enter the source here.

54
00:03:59,950 --> 00:04:05,770
So my test file and after that we're going to enter the destination.

55
00:04:05,770 --> 00:04:08,380
And as you can see, the destination is going to be this.

56
00:04:08,380 --> 00:04:11,020
So destination is going to be test file.

57
00:04:11,740 --> 00:04:19,930
And here, oops, clear and L and here, as you can see here.

58
00:04:21,340 --> 00:04:22,930
We have a test file.

59
00:04:22,930 --> 00:04:27,730
The new with the new timestamp 315.

60
00:04:28,030 --> 00:04:33,790
But here, as you can see here, whenever we copied this, this also created a new timestamp.

61
00:04:33,790 --> 00:04:40,180
But the as you can see here, but the size and their contents should be the same.

62
00:04:40,180 --> 00:04:41,740
So the new.

63
00:04:43,210 --> 00:04:50,410
This file shows a different modification time than our previous test file.

64
00:04:50,410 --> 00:04:57,520
So if a destination file already exists, the CP command may not prompt you to this fact, so it is

65
00:04:57,520 --> 00:05:00,910
best to add the E option here.

66
00:05:00,910 --> 00:05:07,990
So e option to force the shell to ask whether you want to overwrite a file or not.

67
00:05:07,990 --> 00:05:10,930
So we will do that like this.

68
00:05:11,050 --> 00:05:18,640
RLS or cp here parameter as e here and overwrite test file.

69
00:05:18,640 --> 00:05:19,360
Yes.

70
00:05:19,360 --> 00:05:20,320
Or E here.

71
00:05:20,320 --> 00:05:24,310
And as you can see here L here you can also here.

72
00:05:24,340 --> 00:05:25,450
Let's see.

73
00:05:25,450 --> 00:05:32,860
And as you can see here, we override override on the test file and the timestamp and file contents

74
00:05:32,860 --> 00:05:36,550
should be updated with new file here.

75
00:05:36,550 --> 00:05:39,610
So if you don't answer the you here.

76
00:05:39,610 --> 00:05:45,740
So here, here, the file copy doesn't process and you can also enter the n here.

77
00:05:45,740 --> 00:05:47,150
So for no.

78
00:05:47,150 --> 00:05:56,360
So you can also copy a file into a pre-existing directory like this will be choosing the absolute directory.

79
00:05:56,480 --> 00:05:57,680
So cp.

80
00:05:58,710 --> 00:05:59,400
Or clear.

81
00:05:59,400 --> 00:06:02,090
Firstly, so cp e.

82
00:06:03,330 --> 00:06:05,220
Uh, for example, my test file.

83
00:06:05,220 --> 00:06:13,530
My test file, and we're going to do to my home, Carly And after that we will copy to, for example,

84
00:06:13,530 --> 00:06:15,840
templates or yeah, downloads.

85
00:06:16,320 --> 00:06:19,440
And here, let's see the two downloads.

86
00:06:19,800 --> 00:06:20,220
Oops.

87
00:06:20,280 --> 00:06:22,590
See the two downloads here.

88
00:06:22,590 --> 00:06:27,360
As you can see here we have a new file, my test file here.

89
00:06:27,510 --> 00:06:34,830
So the new file is now under the downloads directory using the same file name as the original.
