If you are using Windows, the default console of your VM software will be very small and unfriendly to use for most people. No, I don’t know why they make VM software like that. The Linux console has no requirements that make VM software developers do that.
If you are on a Mac, the default VM console is better, but you can use the Mac terminal application to get an even more friendly tool.
If you are on Windows, you can use powershell to run ssh or you may want to install and use a terminal emulator program such as putty.
Whatever terminal program you are using, you will start it and connect to your VM using ssh. Before we can connect with ssh, we need ssh running on the server and to know the address to connect to. The VM software will not tell us our address, so we should log in at least once to the VM in order to find it. If you missed installing the ssh service in the previous lab, run the following commands from the console of your VM to ensure the ssh service is installed, and then display your server’s current ip addresses.
sudo apt update
sudo apt install openssh-server
hostname -I
Now you can connect to your VM using a remote terminal.
hostname -I
command on the console of your VM.
ssh ubuntu@<ip-address-of-your-vm>
yes
.Windows versions a few years old or more do not include a client program for secure command line access to remote systems. There are multiple options for this but all of them will have to be downloaded and installed. I personally recommend the putty program which has been around a long time, and is simple to install and use. If you already have the putty program and the puttygen program installed and are familiar with them, or have another ssh client program with key generation capabilities already installed that you are familiar with, feel free to to use that and skip the installation steps and got straight to connecting to the lab Linux server. If you do not have putty and puttygen installed, or an alternative to them, follow all the steps to install and start using putty.
hostname -I
command we ran on the VM console in the box for hostname or IP address. We will not save a profile at this time, because the IP address for our lab Linux server will be changing in the next lab. Once we change it in the next lab, we will not be changing it again, and you can save a profile at that time.yes
.All of the remaining commands in this lab are to be run on your lab Linux server, in the remote access terminal window. Install the system resource monitoring tools and user programs that we will be using, which may not already be installed. The following commands can be used to install this software:
sudo apt update
sudo apt install sysstat memstat sl fortune cowsay tree glances htop
Set up the default home directory contents for new users that get created on this system. Make the following directories in /etc/skel
:
Create a text file called /etc/skel/.bash_login
with commands in it to add the games and personal bin to the user’s PATH, and run fortune through cowsay on every login:
export PATH=$PATH:/usr/games:~/bin
[ -f ~/.bashrc ] && . ~/.bashrc
fortune|cowsay
Example commands to make those directories and create that file:
sudo mkdir /etc/skel/{bin,Documents,Downloads,Pictures,public_html}
cat >~/.bash_login <<EOF
export PATH=$PATH:/usr/games:~/bin
[ -f ~/.bashrc ] && . ~/.bashrc
fortune|cowsay
EOF
sudo cp ~/.bash_login /etc/skel
Next we will create a personal account to use. It will be created using your own name. Do not use special characters such as dashes, spaces, or apostrophes. The full name can be mixed case (e.g. First Last), but use only lower case when entering your username for the account. The account username must be your first name. Refer to the Ubuntu Server Guide if necessary for more information on managing user accounts.
sudo adduser firstname
Add your user account to the sudo group, so you can use sudo
from it. The command will look similar to this:
sudo usermod -a -G sudo firstname
Set a secure password onto your account using passwd firstname
. For the remaining labs this semester, log onto your server using the account you just created. Log out of the ubuntu account, and log onto your new personal account.
Verify you can run the following commands:
memstat
sl
fortune
iostat
sudo ss -tlpn
Use the df -h
command to see how much free space you have on your server. Review the descriptive first paragraph of the man page for each of the commands on the slides from the presentation. Try each of the id, who, w, last, du, mount, lshw, lspci, lsusb, lscpu, ps, vmstat, prtstat, netstat, top, dpkg commands on your VM.
Download the server-check.sh
script from github and run it for the first lab.
sudo /root/server-check.sh -l 1 firstname lastname studentnumber