-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperate Running Systems
207 lines (93 loc) · 4.43 KB
/
Operate Running Systems
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Exercise: 1
Working with systemd and targets
1 . - Install the httpd package.
-]$ sudo yum install httpd -y
2 . - View all active targets on the system.
-]$ systemctl list-units --type=target
3 . - View all targets installed on the disk.
-]$ systemctl list-units --type target --all
4 . - Display the current default target.
-]$ systemctl get-default
5. - Change the default target to the multi-user target if the multi-user target is available.
-]# systemctl set-default multi-user.target
6 . - View all available systemd configuration units.
-]$ systemctl -t help
7 . - Find the status of the sshd service.
-]$ systemctl status httpd.service
8 . - List all active service unit configuration files.
-]$ systemctl --type=service
9 . - Determine if the httpd service is active.
-]$ systemctl is-active httpd
10 . - Determine if the httpd service is enabled, and, if it is not, enable it.
-]$ systemctl is-enabled httpd
11 . - View enabled and disabled settings for all units of the type "service".
-]$ systectl list-unit-files --type=service --all
12 . - List all service unit configuration files, whether they are active or not.
-]$ systemctl list-units --all
-]$ systemctl list-units --type=service --all
==================================================================
PGREP, PKILL, KILL AND JOBS
1. As the root user, create a job running in the background of your current terminal. Execute the following script for that program process to be created:
-]$ (while true; do echo "My program" > ~/output.file; done) &
2. View the current jobs running in the background of your terminal.
-]$ jobs -l
3. Stop the process from running, without killing the process, using the kill command.
-]$ kill -19 1449
||or||
-]$ kill -SIGSTOP %1 (%1 is the job number, if the job was 2 it would be %2)
4. View the stopped jobs in the background.
-]$ jobs -l
5. Start the process again using the kill command.
-]$ kill -18 1449
||or||
-]$ kill -SIGCONT %1
6. Kill the process without allowing any blocking of the kill command.
-]$ kill -9 1449
======================================================================
TEST 2
1. Download and install the httpd service.
-]$ sudo yum install httpd
2. Start the httpd service (or ensure that it is running).
-]$ systemctl start httpd.service
3. As the root user, grep for all processes that are running as the root user and display the process names.
-]$ pgrep -u root -l
4. As the user user, start the vi program at the terminal.
-]$ vi
5. As the root user, in your second terminal window, grep for all processes running under the user "user" and include the process names.
-]$ pgrep -u user -l
6. As the root user, grep for the "httpd" process.
-]$ pgrep httpd
7. As the root user, kill all of the "user" user's processes and boot that user from the system.
-]$ pgrep -u user
-]$ pkill -u user ssh
=========================================================
NICE, RECINE AND PS
1 . - Ensure that you have the httpd package installed on the system.
-]$ yum info httpd
2 . - Ensure the httpd service is not running.
-]$ systemctp stutus httpd
3 . - Start the httpd service with the most favorable nice possible.
-]$ nice -n -20 httpd
4 . - View the current nice of the httpd service using the ps command and grep command together.
-]$ ps axo pid,comm,nice | grep httpd
5 . - Renice all httpd processes and set the nice level to 0.
-]$ renice -n 0 $(pgrep httpd)
=========================================================
MONITORING AND CALCULATING CPU LOAD AVERAGES
1 . - View the system uptime and load average.
-]$ uptime
2 . - View the system uptime and load average in such a way that it also shows what users are logged in
to the system and what the user is doing.
-]$ w
3 . - Using the proc file system and wc, display the number of processors your system has.
This is important to calculate the load average of the system.
-]$ lscpu
|| or ||
-]$ cat /proc/cpuinfo
4 . - Calculate the 1, 5, and 15 minute CPU load averages for the system
-]$ uptime
09:42:20 up 16:21, 3 users, load average: 1.04, 0.72, 0.35
Per CPU load average calculation formula: load average / # of cpu
Per CPU load average calculation 1 Minute load average: 1.04 / 2 = 52%
Per CPU load average calculation 5 Minute load average: .72 / 2 = 36%
Per CPU load average calculation 15 Minute load average: .35 / 2 = 17.5%