1
00:00:00,000 --> 00:00:01,170
Today, we're going to go over

2
00:00:01,170 --> 00:00:03,480
Assuming Superuser Privileges.

3
00:00:03,480 --> 00:00:06,300
Now, in IT security it's best practice

4
00:00:06,300 --> 00:00:08,790
to give users the least amount of privilege.

5
00:00:08,790 --> 00:00:13,263
With Linux the root administrator has ultimate power.

6
00:00:14,190 --> 00:00:16,860
It can execute any function on any file.

7
00:00:16,860 --> 00:00:19,200
Now, that's not best practice.

8
00:00:19,200 --> 00:00:22,830
So, the best thing to do whenever you log on to any system,

9
00:00:22,830 --> 00:00:25,140
is log into a standard user account,

10
00:00:25,140 --> 00:00:28,020
and then elevate your privileges as necessary.

11
00:00:28,020 --> 00:00:30,600
Now, one great way of accomplishing this,

12
00:00:30,600 --> 00:00:32,369
is using the pseudo command.

13
00:00:32,369 --> 00:00:35,070
Being root should be used sparingly,

14
00:00:35,070 --> 00:00:38,700
because again, anything you type can be executed.

15
00:00:38,700 --> 00:00:39,870
And there's some functions

16
00:00:39,870 --> 00:00:41,610
and there's some commands that you can do,

17
00:00:41,610 --> 00:00:44,460
to create inadvertent causes to the systems,

18
00:00:44,460 --> 00:00:47,430
that could be devastating and irreversible.

19
00:00:47,430 --> 00:00:48,840
So we want to make sure that we're using

20
00:00:48,840 --> 00:00:51,510
these commands very sparingly,

21
00:00:51,510 --> 00:00:52,560
and with forethought.

22
00:00:53,400 --> 00:00:54,233
All right.

23
00:00:54,233 --> 00:00:55,066
First things first.

24
00:00:55,066 --> 00:00:57,273
We're going to log in as a root user.

25
00:00:58,800 --> 00:01:00,600
Going to prompt us for a password here.

26
00:01:02,970 --> 00:01:07,080
And now we're executing as the root privileged user.

27
00:01:07,080 --> 00:01:09,270
Now, another way of doing this,

28
00:01:09,270 --> 00:01:11,910
if you want to exit out of here, log out.

29
00:01:11,910 --> 00:01:16,910
Is to just do su - without any options after the dash.

30
00:01:18,090 --> 00:01:19,980
It assumes that you want to do root.

31
00:01:19,980 --> 00:01:21,240
So that's just a faster way to do it,

32
00:01:21,240 --> 00:01:22,703
if you want to do it that way.

33
00:01:24,000 --> 00:01:27,420
Now, we're going to use the ID command to verify our privilege.

34
00:01:27,420 --> 00:01:30,330
Now for a super user or a root,

35
00:01:30,330 --> 00:01:33,240
the user ID, UID is always zero.

36
00:01:33,240 --> 00:01:36,420
So that's one quick way to know exactly who you are,

37
00:01:36,420 --> 00:01:38,760
if you're going to use this ID command.

38
00:01:38,760 --> 00:01:39,593
I want to make sure,

39
00:01:39,593 --> 00:01:41,190
we're going to check our present working directory.

40
00:01:41,190 --> 00:01:42,023
All right.

41
00:01:42,023 --> 00:01:43,410
Typically once you switch to user

42
00:01:43,410 --> 00:01:45,930
you're executing out of the root directory.

43
00:01:45,930 --> 00:01:47,733
So, something to keep note of.

44
00:01:48,570 --> 00:01:52,080
Now, the pseudo files allows us to

45
00:01:52,080 --> 00:01:55,920
tailor the type of privileges an account can have.

46
00:01:55,920 --> 00:01:58,470
Typically you can use Vim or Nano

47
00:01:58,470 --> 00:02:00,150
for any type of text editing.

48
00:02:00,150 --> 00:02:02,280
But specifically for sudoers,

49
00:02:02,280 --> 00:02:04,020
just to make sure there's no errors,

50
00:02:04,020 --> 00:02:06,963
you can only use the Visudo.

51
00:02:08,789 --> 00:02:12,480
So, we're going to use testadmin in this example.

52
00:02:12,480 --> 00:02:14,543
So we're going to switch to him really quick.

53
00:02:19,008 --> 00:02:20,850
Now we're going to try to run this command

54
00:02:20,850 --> 00:02:22,083
the shut down command,

55
00:02:24,630 --> 00:02:26,830
just to see the effects of the sudoers file.

56
00:02:27,810 --> 00:02:28,643
Try to reboot,

57
00:02:28,643 --> 00:02:31,233
that's what the -r stands for, in 15 minutes.

58
00:02:36,300 --> 00:02:37,133
Now we see the output,

59
00:02:37,133 --> 00:02:40,470
it says the "testadmin is not in the sudoers file.

60
00:02:40,470 --> 00:02:42,420
This incident will be reported."

61
00:02:42,420 --> 00:02:45,600
So that means this user does not have the correct privileges

62
00:02:45,600 --> 00:02:47,820
to execute this to command.

63
00:02:47,820 --> 00:02:49,833
So what we're going to do is modify this.

64
00:02:52,890 --> 00:02:54,440
We're going to switch to the root.

65
00:02:58,170 --> 00:02:59,470
And now let's use the

66
00:03:01,063 --> 00:03:01,896
Visudo.

67
00:03:01,896 --> 00:03:05,580
This gets us into the sudoers file so we can edit it.

68
00:03:05,580 --> 00:03:06,780
We can go to the bottom,

69
00:03:11,010 --> 00:03:13,890
and use the end key.

70
00:03:13,890 --> 00:03:15,510
It's at the end of the line.

71
00:03:15,510 --> 00:03:17,313
And now we're going to go use O,

72
00:03:18,150 --> 00:03:20,100
to start the insertion.

73
00:03:20,100 --> 00:03:20,950
We use testadmin.

74
00:03:23,550 --> 00:03:24,480
And we're going to allow,

75
00:03:24,480 --> 00:03:26,193
that's what this ALL stands for,

76
00:03:27,450 --> 00:03:30,063
all provisions.

77
00:03:31,230 --> 00:03:32,430
And just for convenience,

78
00:03:32,430 --> 00:03:34,200
we're going to add the NOPASSWD.

79
00:03:34,200 --> 00:03:37,470
Cause typically every time you use the sudo command

80
00:03:37,470 --> 00:03:41,130
it requires you to enter your password.

81
00:03:41,130 --> 00:03:42,750
This is not recommended,

82
00:03:42,750 --> 00:03:45,690
but for the sake of this example

83
00:03:45,690 --> 00:03:47,730
it makes things a lot easier,

84
00:03:47,730 --> 00:03:49,050
or more efficient.

85
00:03:49,050 --> 00:03:51,033
But for security it's a no go.

86
00:03:53,010 --> 00:03:54,303
Okay here.

87
00:03:56,850 --> 00:03:57,933
Right, quit.

88
00:04:00,210 --> 00:04:02,943
Now let's switch it back to at testadmin again,

89
00:04:05,490 --> 00:04:07,133
and let's try to run that command.

90
00:04:13,986 --> 00:04:16,736
And this is reboot in 15 minutes.

91
00:04:17,850 --> 00:04:21,329
Now we see we're able to successfully execute that command.

92
00:04:21,329 --> 00:04:23,460
So the sudoer file again,

93
00:04:23,460 --> 00:04:26,100
allows us to add users to their file.

94
00:04:26,100 --> 00:04:27,300
So the system knows,

95
00:04:27,300 --> 00:04:29,853
hey they can perform root level privileges.

96
00:04:31,350 --> 00:04:33,420
And of course you can tailor which privileges

97
00:04:33,420 --> 00:04:34,740
and which commands to be executed.

98
00:04:34,740 --> 00:04:37,893
But for the example we just set it to all privileges.

99
00:04:40,170 --> 00:04:41,820
All right, I'll exit out of this.

100
00:04:42,720 --> 00:04:46,293
And so now we want to actually cancel this reboot,

101
00:04:49,440 --> 00:04:50,273
c.

102
00:04:51,570 --> 00:04:53,470
So now that was successfully canceled.

