Basic packages

Here are a few useful software and common usages that you might need to install. but, before, the golden procedure of servers:

update&&upgrade

update the repositories of the system

$sudo apt update

upgrade the installed packages

$sudo apt upgrade

I'd like to find something on the server...

You could use the find core program, which is very powerful, but there is an easier option:

locate is a package that creates a database of all the system's files.

$sudo apt install locate $sudo updatedb

Let's say you found the command you were looking for and you typed it correctly in your command line. Now, you don't exactly remember it, but you remember you did it before. The power of the server can be yours, too! You can reverse-search back in the history of the command line with a simple:

$Ctrl-R

or, you can also list the whole history of the command line, of the user you're currently connected to, by typing

$history

the server has a quite good memory, isn't it?

Share a command line

Expert or not, it's very useful the sharing of a command line. You can see the commands that other colleagues are typing, real-time, and vice-versa: it can be a powerful learning-teaching experience. Here too, there are different option, our choice is tmux

$sudo apt install tmux

Panos amd K. connect to Lennon from different locations. They want to share the same terminal. Panos create a new session by typing:

$tmux new -s SESSION_NAME

K. attach to the newly-created session by typing

$tmux attach-session -t SESSION_NAME

P.S.: Replace SESSION_NAME variable with the name of your session ;)

tmux-fifi-session

connect to the server - SSH

We were connected to Lennon from different location. But how it is possible?

SSH (Secure SHell) is the preferred protocol to connect to the server. The easiest way to make it available to SSH connection is to install an SSH service.

$ sudo apt install openssh-server

Of course, you need to have to SSH enabled also on the computer/device you're connecting from!

For enabling SSH service on the server, enable and start it:

$ sudo systemctl enable ssh

$ sudo systemctl start ssh

Important: connecting from inside the network one needs to use the local IP, from outside the router external IP. You cannot access the local server with the "external" domain name, but only with the local IP.

Unless you need to add it to the "hosts" file (TODO). In GNU/Linux is usually located in /etc/hosts.

N.B.: This hack will work until you're connected to the same network of the router. From outside, you'll have to comment the line, otherwise you will not able to connect to the server!

N.B.: hosts file can be used also for avoiding connection to specific resources/websites! A Linux hosts file guide

Or, even better, unless you have correctly configured the redirection of port on the router the server is connected to.

Secure the secure connection

  • Change the SSH port in the router settings to be different than the default
  • Change the "external requested" port for the SSH service
  • Then you can connect from the outside with

ssh -p NEW_PORT_NUMBER USER@SERVERNAME