Agenda: intro-ubuntu-exercises.txt

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