Step Seven • Remote login & updates

13. Remote login, changing directories

  1. Terminal: log in as user
  2. Switch to superuser mode
  3. Changing directories

14. Continued configuration

  1. Edit hosts

15. Updates and upgrades for Debian

  1. Antivirus updates
  2. Update Debian
  3. Upgrade Debian
13. Remote login as user and superuser, changing directories

13a. Log in as user

You can now log in to your webserver from another computer using ssh. On a Linux system or Mac you use Terminal, an application which is already there.

On a Windows PC you can use a little program called  - + PuTTY.  -

Download PuTTY. It's icon will be on your desktop:

Putty icon

Doubleclick on it. You'll get this screen:

Putty screen

Enter your new server's IP address in the Host Name field. This will be your equivalent for 192.168.178.99.

IP address

Click Open. You'll get a security alert:

Alert

If you trust yourself, click Yes. You'll see a screen resembling Terminal:

Like Terminal

Enter your user name:

User name

You'll be asked for your password. Enter it (it won't be shown):

Enter password

Now you're logged in as user:

Logged in as user

Let's log in as superuser. Type su and ...

... hit Enter. You'll be asked for the superuser password.

Password

The password won't be shown while you're typing it. Hit Enter. Now you're logged in as superuser:

Logged in as superuser

You can now proceed to 13c. Changing directories.

Close X

Start Terminal on your other computer. You'll see something which is called the bash/shell command line and looks like this:

Terminal

Type ssh, followed by your webserver's IP address, for example 192.168.178.99, followed by -l and your username, like newuser. In short, type your equivalent of:

ssh 192.168.178.99 -l newuser.

Make sure to replace all data by your own.

Username

Hit Enter and you'll be asked whether you are sure:

ssh

Yes, you are sure. Type: yes and...

Yes

... hit Enter.

Now you're invited to type the user password:

Password

Type your password for newuser (you won't see it appear while you type) and hit Enter.

You're logged in as a regular user:

Logged in

13b. Switch to superuser mode

You don't want to be just a regular user with limited permissions. We've still got a lot of installing to do and for that you must be a superuser. Type su and...

su

... hit Enter. And guess what? Now they want you to give your superuser password. Type it and...

Password

... hit Enter. As a superuser you'll now see the new, third line here:

Superuser

Once you've got superuser permissions, you can screw up your whole system, so don't do anything if you don't know precisely what you're doing.

13c. Changing directories

The above section /home/newuser indicates that your current directory is newuser, which is located inside the directory home. Just for fun, let's switch to the root (/) directory. In Terminal you change directories by typing cd followed by a path like /etc or /home or / (for root).

In order to change to the root directory, type cd [space] / like:

cd

... and hit Enter. Now you're in the root directory:

Root

As you can see, the path is only / so that means the current directory is root.

TIP 1 In order to reach files in a different directory you can always stay where you are as long as you include the path to a file in the command. For example, below we'll edit a file inside the etc directory ‘without being there’, so in the command we'll include the path /etc/.

TIP 2 For help with coding, click the vi & shell panel at the top right of this page.

14. Continued configuration

14a. Edit hosts

We've got to tell the hosts file about the configuration of our system. The hosts file is located in the etc directory. We'll tell our vi editor to follow the path for getting there and opening hosts. Type:

vi /etc/hosts

Hosts

... and hit Enter. In vi this is what hosts looks like:

Hosts

Hit the i on your keyboard and watch -- INSERT -- appear on the bottom line:

Insert

You can start editing now. The top lines currently are:

127.0.0.1 localhost  
127.0.0.1 server01.yourdomain.com server01

Change these lines to make them look something like the lines below, making sure to replace the sample IP 192.168.178.99 by your Linux server's own correct IP address:

127.0.0.1 localhost.localdomain localhost
192.168.178.99 server01.yourdomain.com server01

When you're done ...

Save

... save the file by hitting Esc and typing :wq and then hitting Enter.

Now add your domain to the hostname file. In Terminal type your equivalent of:

echo server01.yourdomain.com > /etc/hostname

Echo

... and hit Enter.

In order to make this change take effect immediately, type:

/etc/init.d/hostname.sh start

Start

Let's check what we've done here. We'll run two commands. Both times you must get the same result, being your equivalent of server01.yourdomain.com.

In Terminal, type: hostname

Hostname

... and hit Enter. You should see your own equivalent for server01.yourdomain.com:

Check

If you don't get your own server's hostname and domain name, repeat the previous steps until you get it right.

Time for the second check. In Terminal, type: hostname -f

Hostname -f

... and hit Enter. You should see your own equivalent for server01.yourdomain.com:

Check

Again, if you don't see your own server's hostname and domain name, repeat the previous steps until you get it right.

15. Updates and upgrades for Debian

15a. Antivirus updates

The Debian package includes the open source ClamAV virus scanner. For correct regular updates you should edit the file sources.list. In Terminal, run vi /etc/apt/sources.list

Edit

TIP Run means: type a command and hit Enter.

In the file that opens take a look at the line:

deb-src http://volatile.debian.org/debian-volatile lenny/volatile main

Closing line

Start editing the file (hit i on your keyboard) and add the following code at the end of that line:

contrib non-free

... to make it look like:

Edit

Save and quit by hitting: Esc + :wq + Enter.

ClamAV is ready to be updated now.

15b. Update Debian

Update your freshly installed Debian system. Run: apt-get update

Update

When the update is ready, you'll see something like:

Done

15c. Upgrade Debian

Upgrade Debian. Run: apt-get upgrade

Upgrade

When the upgrade is ready, the system will give you the number of changes (in this example none):

Done

Go to the next page to continue building your webserver.

Drag this box to where you want it
vi | shell
command action command action
su become superuser rm foo delete file foo
ls show files & directories rmdir foo delete directory foo
ls -a show invisible items too rm -rf foo delete dir foo + content
ls -l show long names chmod change permissions
ls -la show long and invisible chmod 755 foo set 755 for foo
cd change directories vi /etc/foo open file foo in vi
cd / go to root directory apt-get install get and install application
cd /etc go to etc via root tar -xzvf extract zip file
cd /tmp go to temp via root exit finish Terminal session
/etc/init.d/restart apache2 restart the Apache server
/etc/init.d/status apache2 show if the Apache server is running
shutdown -h now shutdown the system immediately
shutdown -r shutdown and reboot the system
vi | shell
<= keyboard hits => action
  i   insert (start editing)
  arrows   move around
  backspace   delete to the left
  delete   delete to the right
  esc   stop editing
esc :w enter stop editing, save changes and keep vi open
esc :wq enter stop editing, save changes and exit vi
esc :q enter stop editing, exit vi without saving

Assistance

vi & shell

Arrow

Contact