How to install Ubuntu Server (22.04 LTS)
How to install Ubuntu Server (22.04 LTS)
Shutdown/Restart
// Shutdown and Restart(-r) the machine
$ sudo shutdown -r now
// Same as above
$ sudo reboot
// Shutdown and halt(-h) or power down the machine "now"
$ sudo shutdown -h now
Tar
// Create target path, if necessary (target path shall exist)
$ mkdir <target-path>
// Extract(x) into current directory, z(zip), f(filename), v(verbose).
$ cd <target-path>
$ tar xzfv <tarball>
// or specifying target path via -C
$ tar xzfv <tarball> -C <target-path>
Remote Access
// Remote login client to OpenSSH (Secure SHell) server
$ ssh <user>@<host>
// OpenSSH Secure file CoPy
$ scp <source> <target> // <user>@<host>:<files>
Shutdown/Restart Server
To shutdown the machine via a terminal (remotely thru SSH, or local system console):
// Shutdown and restart(-r)
$ sudo shutdown -r now
// Reboot (same as above)
$ sudo reboot
// Shutdown the machine, halt(-h) and "power down" after shutdown
$ sudo shutdown -h now
You can also shutdown the server remotely via Webmin (Goto "System" ⇒ "Bootup and
Shutdown" ⇒ "Shutdown System" or "Reboot System").
[TODO]
Webmin
References:
1. Webmin mother site @ http://www.webmin.com.
2. Michał Karzyński, "Webmin Administrator's Cookbook", Packt Publishing, 2014.
Installing Webmin
To install webmin:
1. Read the instructions in http://www.webmin.com/deb.html. Follow the section
"Using the Webmin APT repository". Webmin is written in perl, which shall be
automatically installed.
2. login to Webmin using URL https://hostname:10000, via a web browser. You need
to login with root user or an account with sudo privilege.
Webmin logs all the actions performed by users through it for auditing and security.
• You can view all the action logs via "Webmin" ⇒ "Webmin Actions Log".
• You can inspect the currently open sessions via "Webmin" ⇒ "Webmin Users" ⇒
"View Login Sessions" ⇒ Select "View Logs" for a particular "Session ID".
Note: To run the applet, you need to add the Webmin's URL to the "Exception site list" under
"Control Panel" ⇒ "Java".
Text Login (Others ⇒ Text Login) and SSH login (Others ⇒ SSH Login)
You can log in to the system via "Text Login" or "SSH Login". "Text Login" uses a component
called Ajaxterm, while "SSH Login" uses a Java applet.
Managing Users/Groups
You can create/delete/Edit users and groups via menu "System" ⇒ "Users and Groups".
You can also create users in batch, via "System" ⇒ "Users and Groups" ⇒ "Run batch file".
To enable email alert: Goto "Others" ⇒ "System and Server Status" ⇒ "Scheduled Monitoring"
⇒ In "Scheduled checking enabled", select to "yes" ⇒ Set "Send email when" to "When a
service goes down" ⇒ ... ⇒ "Save".
Similarly, to monitor whether a remote serve is up, choose "Remote Ping" and set "Host to
ping" to the IP address or hostname.
To display the scheduled commands: goto "System" ⇒ "Scheduled Commands". You can also
cancel a scheduled command.
Webmin issues the following Unix at commands:
$ su run-as-username
# cd run-in-directory
# echo 'command' | at -m date-time
// The at command wraps the commands into a script and stores in /var/
spool/cron/atjobs/.
// The atd (at daemon) run the script at the specified date-time.
Schedule a Command to run regularly (with cron)
Goto "System" ⇒ "Scheduled Cron Jobs" ⇒ "Create a new Scheduled cron job" ⇒ Set the
username in "Execute cron job as" ⇒ Set "Yes" to "Active" ⇒ Type the command in
"Command" ⇒ Set the schedule ⇒ "Save".
Webmin adds the task to crontab (cron table in /var/spool/cron/crontabs). The cron daemon
then executes the task at the regular schedule.
To disable services at boot, goto "System" ⇒ "Bootup and Shutdown" ⇒ Select the service ⇒
Click "Disable Now on Boot".
Note: After OS boots, it starts a process called init, which executes the service initialization
scripts under /etc/init.d directory.
To disable root login over SSH, goto Servers ⇒ SSH Server ⇒ Authentication ⇒ Allow login by
root ⇒ No.
Webmin edits the SSH configuration file /etc/ssh/sshd_config by setting
the PermitRootLogin to no; and restart SSH Server via "sudo service ssh restart" or "sudo
/etc/init.d/sshd restart".
Note: By default, the root account password is actually locked in Ubuntu.
Managing Samba
Samba is a File Sharing service for Windows clients. It uses TCP ports 137, 139, 445 and UDP
ports 137-139, which shall be unlock if firewall is enabled. It uses Unix
services nmb, smb and winbind, which shall be started at boot time.
Configuring Samba
Firstly, check if Samba module is enable under Webmin. Goto "Servers" ⇒ Look for "Samba
Windows File Sharing". Otherwise, enable Samba module from the "Un-used Modules".
Next, setup the server to be visible on the network. Goto "Servers" ⇒ "Samba Windows File
Sharing" ⇒ "Windows Networking" ⇒ Set "Workgroup" to WORKGROUP or workshop name in
your organization ⇒ Set "Server description" to the name for which your server to be visible
in the network; or "%h" for the server's default hostname.
To share the home directory: Goto "Servers" ⇒ "Samba Windows File Sharing" ⇒ "Create new
shares" ⇒ In "Share name", select "Home Directories Share". Click "Security and Access
Control" ⇒ Set "Writable" to "Yes". In "Authentication" set to "revalidate user".
[TODO]
If Firewall is enabled, you need to permit incoming connection for HTTP (default on TCP port
80) and HTTPS (default on TCP port 443).
Apache Configuration
The Apache configuration is divided into 3 sections: global settings, default server and virtual
hosts. If a request matches one of the virtual hosts, it will be handled by the matched virtual
host; otherwise, it will be processed by the default server.
// Without regex
Redirect 301 /test/ "http://example.com/test/"
Webmin activate SSL by adding the following directive to the virtual host:
SSLEngine on
SSLCertificateFile /etc/apache2/cert.pem
SSLCertificateKeyFile /etc/apache2/key.pem
[TODO]
Usermin
Usermin (@ http://www.webmin.com/usermin.html) is a web-based user interface for Unix-
like systems. It is a simplified version of Webmin, meant for regular users (instead of system
administrator for webmin) for tasks such as reading mail, configuring mail forwarding, and
setting up SSH (Secure Shell).
Mail Server
[TODO]