Assignments1 - getting started

Jump to: navigation, search


Networking, TCP/IP protocol

It is very important that you understand how TCP/IP protocol works and how you classify IP-addresses.

We will talk more about different protocols later. But it is very important to know that the protocols are standardized.

There are two organizations that are responsible for the standardization: Internet Engineering Task Force (IETF) and the Internet Society (ISOC).

These two organizations provide documents that describe exactly how a protocol works. These documents are called RFC, Request for Comments.

In the beginning of 70th and 80th company like IBM, Apple, Novell and some other used different communication protocols to connect machines to each other.

IBM used Token ring, Apple used AppleTalk and Novell used IPX.

This situation was bad because it was extremely expensive to maintain all these protocols that weren't compatible to each other and the hardware were very expensive.

In the 90th these companies came to the conclusion that it was better to cooperate and use one standard, the TCP/IP protocol.

One of the best document that describes TCP/IP is the RFC1180 document: ‎File:Rfc1180.pdf

Don't forget to read it, it contains valuable information.

Ubuntu server 14.04.4 LTS

To begin with download the Ubuntu Linux distribution server edition version 14.04.1 LTS from

Note: The latest version at this moment is 16.04.1 LTS but we will use 14.04.1 LTS.

You will download an ISO-image.

Install VirtualBox

VirtualBox is a virtualization application that allows you to install virtual machines in your computer.

VirtualBox is free.

Note: When you create a new virtual machine you can select the type of network you want to use, NAT or Bridge.

NAT: Network Address Translation means, in this case, that you will use IP-addresses that VirtualBox creates internally, for example

Bridge: This means that you will use an IP adress that your home network will provide, for example

Install Ubuntu servers

Install a server with the following property:

Hostname will be ubuntu01.

The IP addresses will be selected for you from DHCP.

Under the installation select default values.

Under the installation select OpenSSH server in the meny.

You will use SSH (Secure Shell) to remote login to the linux machine that you will install.

Secure Shell means that the communication between your computer and the Linux server is encrypted.

Under the installation create the user user01 with the password passwd123.


If you are using Windows:

To be able to remote login to the Linux machines you need to download and install PuTTY.

PuTTY is a free and open-source terminal emulator, serial console and network file transfer application.

Download PuTTY from and Install it.

Login to the server

From PuTTY remote login to ubuntu01 machine. You need to know the ip address of ubuntu01. How do you find it?

Login with the user that you created under the installation.

As default it is not allowed to login as root user.

root user is equivalent to Administrator user in Windows. As root you can do anything and you can damage the system if you don't know what you are doing!

To become root and have root privileges execute the following command:

sudo su

Another way is to use sudo. It allows you to execute commands with root privilege.

Create a user

As root create the user user02 in ubuntu01 machine:

adduser user02

Now you have two 3 users in the system.

Which are these users?

Testing some commands

Now it's time to test some commands.

If you want to know more about a specific command you can use Google or the command:

man <command>

The command man stands for manual.

The following main areas will be covered:

  • Multi User
  • Multitasking
  • File system
  • Network

Multi user

Go back to the user that you logged in type:


This will exit the root session and go back to user01 session.


Try the command who. Type:


What do you see?

Are you alone in the system?

From PuTTY login to ubuntu01 with the user user02.

Test again the who command.

What do you see?

In addition, it shows something other than just user info. What does it show?


Each user has a userid and a groupid. Type:


What do you see?




What do you see?


Also each user has its own home directory. Type:

ls -l /home

What do you see?

The command ls lists the content of a directory. It has many flags.

To know more type:

man ls


In addition to a multi-user Linux is also a multitasked system.

What does multitasking mean?


A process is a program in execution.

A process has different states. Do you remembers which states?


To get information about processes running on the system you can use the command ps.


ps -ef

A list of all the processes that are active in the system are printed.


If the terminal window is too small, you can use "| more" then you can step forward.

Reduce the terminal window.


ps -ef | more.

The character "|" is called pipe.
A pipe is a form of redirection that is used in Linux and other Unix-like operating systems to send the output of one program to another program for further processing.

In this case you send the output of ps -ef to more.


To know which processes belong to a particular user.


ps -ef | grep <username>

<username> is a username.

What does grep do?

When the process are listed there are some columns. What information do they contain?


Choose a process that belongs to the root user.


ps -ef | grep root

Try to kill the process by the kill command.


Kill <pid> 

"Pid" is the process id you want to kill.

What happens?



ping localhost > /dev/null &

This command will redirect the output of "ping localhost" to /dev/null. /dev/null is a special device in Linux.
You can discard everything to it and it will suck it up, it's like the black hole in the universe.

"&" sign means that a process running in the background.



ps -ef | grep ping

What is the process id?

You can write localhost as a an IP address. What is it?

Now kill the process. We don't need it anymore.



pstree -pG

A tree structure of all processes visible. The root of the tree is called init.

What is the pid?


In addition, there is the command jobs that shows the processes running in the background.


ping localhost > /dev/null &



What do you see?

Do not forget to kill the process running in the background.

File system

In Linux file system (EXT4) the directories are ordered in a tree-like structure.


Subdirectories of the root directory

Directories and their content

Common programs, shared by the system, the system administrator and the users.

The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.

Contains references to all the CPU peripheral hardware, which are represented as files with special properties.

Most important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows

Home directories of the common users.

(on some distributions) Information for booting. Do not remove!

Library files, includes files for all kinds of programs needed by the system and the users.

Every partition has a lost+found in its upper directory. Files that were saved during failures are here.

For miscellaneous purposes.

Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.

Standard mount point for entire remote file systems

Typically contains extra and third party software.

A virtual file system containing information about system resources.

The administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user.

Programs for use by the system and the system administrator.

Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!

Programs, libraries, documentation etc. for all user-related programs.

Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.


To know where you are in the file system type:


Where are you in the filesystem?

What does pwd means?


The file system in a Linux system is mounted automatically at boot-time and unmounted at shut down.

To access another device for example a hard drive or CD-ROMs they must be mounted. In Windows we don't need to mount devices.

To see which devices are mounted in the system type:


What do you see?


To see the disk size on all devices type:

df -h

What do you see?

What does the flag h?

What is used and available in the device /dev/sda1?

Note: Make sure that the root partition (/) is never full!!


Create an empty file called file.txt. Type:

touch file.txt


The ls command displays the contents of a directory. Type:


What do see?



ls -l

What is the size of the file you created, file.txt?



echo "this is a test" > file.txt

The character ">" redirect the output of the command "echo" to file.txt.

To see the contents of the file type:

more file.txt

Alternatives to the more command are cat or less

What are the differences?


ls -l

What is the size of the file?


To know the type of a file type:

file file.txt

What is the type?


To empty the file.txt type:

cat /dev/null > file.txt

Do you remember what is special with /dev/null?

What happens?

And now type:

ls -l file.txt

What do you see?

Now type:

more file.txt

What do you see?


ls command has many options.

If you want to sort the files by date ascendent which flag you use then?

For this you can list the content in the directory /tmp.

Tip: run "man ls"


The following commands manage files and directories are often used:

  • mkdir - create directory
  • rmdir - remove directory
  • cp - copy files
  • rm - remove files
  • cd - change directory
  • mv - move files, rename files

Which flag is used with rm to remove a non-empty directory?


Security has a great importance in Linux and therefore it is possible for each user to protect folders and their contents from being read or destroyed by unauthorized persons.

There are four types of users in Linux:

  • User - u (user)
  • Group - g (group)
  • Others - o (other)
  • All - a (user + group + other)


  • Read - r (read)
  • Write: a - w (write)
  • Run - x (execute)


  • + Add rights
  • - Remove right

To change how to access a file or directory the chmod command is used.

What does chmod means?

For example to give write access for a user to the file file.txt type:

chmod u+w file.txt

Now type:

ls -l

What do you see?


Give everyone permission to run the file file.txt.


chmod a+x file.txt

Now type:

ls -l

What do see?


Take away from the group and the rest of the world the right to read and write to the file file.txt.


chmod go-rw file.txt

Now type type:

ls -l

What do you see?


Which combination do you use to accomplish this?:

-rwxrwxrwx 1 user1 user1 15 Oct 13 23:10 file.txt


There is a faster way to change the access permissions, by using integers.

I works like this:


What you see in the picture are different parts of access permission of a file or a directory.

Each part has three bits that you can set independently. For example if you want to give the read+write+execute access to user+group type:

chmod 770 file.txt

Where does integer 7 come from?

read+write+execute access to user+group means that the bits are set as follow: 111 | 111 | 0 = (2^2 + 2^1 + 2^0) | (2^2 + 2^1 + 2^0) | 0 = 7 | 7 | 0

Which combination do you use to accomplish this?:

-rw-rw-r-- 1 user1 user1 15 Oct 13 23:10 file.txt

What is the equivalent to ugo + rwx in integers?


You can also use the chmod to a folder.

Create a directory with the name secret by typing:

mkdir secret

Under the directory secret create a file and put some information in it.

If you want to prevent others from accessing the folder type:

chmod go-rwx secret

Login with the user user02 to ubuntu01 and try to list the content of the directory secret.

What happens?


All Linux/UNIX systems are network-based system.

The following parameters must be configured on Linux to be able to connect to the network:

  • IP address
  • Subnet Mask
  • Default gateway
  • DNS address

IP addresses can be either dynamic or static.

What is the difference between dynamic and static?




What do you see?


What has your computer's IP address and subnet mask?



netstat -rn

What is the default gateway?

There is another command that provides the same information. What is it?

Retrieving system information

In Linux, there is a directory called /proc.

In /proc there is information about all the processes running on the system and much more.


ls -l /proc

What do you see?


From /proc, get information of the following items:

  • CPU
  • memory

There's another command called uname.

What does this command?


Personal tools
MediaWiki Appliance - Powered by TurnKey Linux