1 | Track 2 |
---|
2 | PacNOG 10 |
---|
3 | |
---|
4 | Initial Ubuntu System Administration |
---|
5 | ------------------------------------ |
---|
6 | |
---|
7 | Notes |
---|
8 | ------ |
---|
9 | |
---|
10 | * Commands preceded with "$" imply that you should execute the command as |
---|
11 | a general user - not as root. |
---|
12 | * Commands preceded with "#" imply that you should be working as root using |
---|
13 | "sudo" |
---|
14 | * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") |
---|
15 | imply that you are executing commands on remote equipment, or within |
---|
16 | another program. |
---|
17 | |
---|
18 | 1. Find out what's installed |
---|
19 | ------------------------- |
---|
20 | |
---|
21 | Log on to your machine using SSH as the user specified in class. |
---|
22 | |
---|
23 | Once you are logged in, take a look at all the packages installed on your |
---|
24 | system: |
---|
25 | |
---|
26 | $ dpkg --get-selections |
---|
27 | |
---|
28 | All installed packages fly by on the screen. Let's slow that down: |
---|
29 | |
---|
30 | $ dpkg --get-selections | less |
---|
31 | |
---|
32 | The "less" command lets you quickly search text. Is the "openssh-server" server |
---|
33 | installed on your machines? (It should be if you are logged in :) |
---|
34 | |
---|
35 | Type "/openssh" and press <ENTER> |
---|
36 | |
---|
37 | You should see something like: |
---|
38 | |
---|
39 | openssh-client install |
---|
40 | openssh-server install |
---|
41 | |
---|
42 | with the "openssh" text highlighted. Press "q" to exit the less screen. |
---|
43 | |
---|
44 | Another way to see packages is: |
---|
45 | |
---|
46 | $ dpkg --list | less |
---|
47 | |
---|
48 | Try it! |
---|
49 | |
---|
50 | |
---|
51 | OK, what version of "openssh-server" is installed? |
---|
52 | |
---|
53 | $ apt-cache policy openssh-server |
---|
54 | |
---|
55 | Or, you could also say: |
---|
56 | |
---|
57 | $ dpkg --list openssh-server |
---|
58 | |
---|
59 | |
---|
60 | 2. Find out if a package is available to be installed |
---|
61 | -------------------------------------------------- |
---|
62 | |
---|
63 | You have a local cache of all packages available to be installed from the Ubuntu |
---|
64 | package repositories. You can search this cache using the "apt-cache" command. Before |
---|
65 | you can use apt-cache the first time you need to update your local cache. Let's do this |
---|
66 | now (we did this for you when setting up your machine): |
---|
67 | |
---|
68 | $ sudo apt-get update |
---|
69 | |
---|
70 | Once this completes we can search for available packages. Let's see if the "ipcalc" |
---|
71 | package is available in our Ubuntu repositories: |
---|
72 | |
---|
73 | $ apt-cache search ipcalc |
---|
74 | |
---|
75 | It looks like there are three packages matching the name "ipcalc". Try typing: |
---|
76 | |
---|
77 | $ sudo apt-get install ipcalc |
---|
78 | [sudo] password for sysadm: .... <- your password |
---|
79 | |
---|
80 | $ ipcalc 67.218.55.0/26 |
---|
81 | |
---|
82 | This is very useful! We'll talk more about what all this means later today. |
---|
83 | |
---|
84 | |
---|
85 | 3. Stopping and starting services |
---|
86 | ------------------------------ |
---|
87 | |
---|
88 | The scripts to run services on your machine are located in /etc/init.d/. By default, |
---|
89 | when Ubuntu installs a package the startup scripts for the package are run and the |
---|
90 | package is configured to automatically run at system startup. |
---|
91 | |
---|
92 | Try viewing the status of the ssh server, stopping and starting the server and |
---|
93 | reloading the server's configuration file (/etc/ssh/sshd_config): |
---|
94 | |
---|
95 | The control script for ssh is here: |
---|
96 | |
---|
97 | /etc/init.d/ssh |
---|
98 | |
---|
99 | ... but it is more common in modern Linux to use the "service" command to control |
---|
100 | services: |
---|
101 | |
---|
102 | $ service ssh help |
---|
103 | |
---|
104 | You are shown the commands you can perform on the ssh service. |
---|
105 | |
---|
106 | Try to view the status of the ssh server: |
---|
107 | |
---|
108 | $ sudo service ssh status |
---|
109 | |
---|
110 | Now, stop, start, restart the server and reload it's configuration file, using the |
---|
111 | commands that "service ssh help" has returned: |
---|
112 | |
---|
113 | $ sudo service ssh ... |
---|
114 | |
---|
115 | |
---|
116 | 4. Turning a service off |
---|
117 | --------------------- |
---|
118 | |
---|
119 | If, for some reason, you decide that a currently running service should be turned off |
---|
120 | permanently, but that the software should not be removed, then you need to use the |
---|
121 | update-rc.d utility. |
---|
122 | |
---|
123 | To stop ssh permanently you would do: |
---|
124 | |
---|
125 | $ sudo update-rc.d ssh disable |
---|
126 | |
---|
127 | Oops! But, we need ssh. Let's re-enable the server: |
---|
128 | |
---|
129 | $ sudo update-rc.d ssh enable |
---|
130 | |
---|
131 | Type man update-rc.d for more details on how this works. |
---|
132 | |
---|
133 | Be sure you re-enable ssh! To check that ssh is running, try and start a new |
---|
134 | SSH connectio from your laptop to your PC - can you log in ? |
---|
135 | |
---|
136 | |
---|
137 | 5. Automatically updating your software |
---|
138 | ------------------------------------ |
---|
139 | |
---|
140 | If you want Ubuntu to automatically update software on your machine as soon as new versions |
---|
141 | are available, there is a special package called "unattended-upgrades". |
---|
142 | |
---|
143 | Please don't install this package yet. There are both pluses and minuses to |
---|
144 | automatically upgrading a server. |
---|
145 | |
---|
146 | Alternatively you can do: |
---|
147 | |
---|
148 | $ sudo apt-get install apticron |
---|
149 | |
---|
150 | to install a package that will email an administrator information about any packages on |
---|
151 | the system that need updated as well as a summary of changes in each package. |
---|
152 | |
---|
153 | Once the package is installed you edit: |
---|
154 | |
---|
155 | /etc/apticron/apticron.conf |
---|
156 | |
---|
157 | and set the EMAIL variable to the address of the person who should receive this information. |
---|
158 | Very often this is the root user, but it could be another user, like yourself. |
---|
159 | |
---|
160 | EMAIL="sysadm@localhost" |
---|
161 | |
---|
162 | "root@localhost" often points to another user, and this user account may point to whoever |
---|
163 | is currently doing system administration on your machine. |
---|
164 | |
---|
165 | Go ahead and install apticron and update the apticron.conf file to point EMAIL to sysadm@localhost. |
---|
166 | |
---|
167 | NOTE! This package installs the Postfix MTA. This is fine in this case, but could be an issue if |
---|
168 | you had a different MTA installed and configured on your system. |
---|
169 | |
---|
170 | During installation you will be asked "What type of site" to configure for Postfix. Choose the |
---|
171 | default highlighted option of "Internet site" - In addition your machines FQDN (Fully |
---|
172 | Qualified Domain Name) will be requested. What is shown should be correct, so just choose OK |
---|
173 | to continue when prompted. |
---|