Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

University of Central

Punjab
(Faculty of Information Technology)

Course: CSNC 2411


Computer Communications and Networks
(Lab)

Lab 1

Overview of Basic Linux Commands, Process


Management, and Network Management
Lab Manual 01
Objectives
 Linux commands related to directory structure and file manipulation
 Process and network management commands
 How to compile C code in Linux
 Endianness in systems

Reference Material

General commands for opening terminal


1. To open the terminal you will either open it using GUI or press “Ctrl+Alt+T”.
2. To open two windows in the same terminal you will use “Ctrl+Shift+T”.
3. To copy something from your terminal you will use “Ctrl+Shift+C”.
4. To paste something in the Terminal you will press “Ctrl+Shift+V”.
5. To terminate any running program you will use “Ctrl+C” or “Ctrl+Z”.

Play with Folders


1. The “ls” command is used for viewing files, folders and directories
2. To move the file from one directory to another we can used “mv” command
mv Path_Of_Source_folder <space> Path_Of_Destination_Folder
Example: move a file “mycode.c” from folder “Desktop/MyCode/” to “Desktop”
“mv Desktop/MyCode/mycode.c Desktop”
3. Can create a directory using command “mkdir” command.
Example: syntax for creating a testdirectory is “mkdir testdirectory”
4. To remove any directory use “rmdir”. Example” “rmdir testdirectory”
5. “man” command is used to show information related to any command; e.g, “man cd”

Compilation of C code
1. Save your C file with *.c extension; e.g, MyCode.c
2. To compile any C file you should be in the same directory as your code. Write “cd
<directory_name>” to change to the directory; e.g, cd Desktop. To go directly into home
directory we simply write “cd ~”. To go one step up in the hierarchy of directories we write
“cd ..”.
3. To compile your file using gcc compiler you first have to go to the directory where the file is
placed and then you will write the following:
gcc <file_name>.c –o <executable_fileName>
4. If there is any error in your code then compiler will tell you those errors and you will correct
them. If there is no error, you will see an executable created in the same directory having a
diamond like shape. Then you will run your executable by issuing the following command in
the directory where your executable is placed:
./<executable_fileName>
Example: ./IamExeFile
5. Make sure that you write the correct file name, otherwise you will get an error. You can use
TAB after writing two to three letters of the file name, and it will auto complete the file name
for you.

Endianness
In computing, “endianness” refers to the order of bytes (or sometimes bits) within a binary
representation of a number. It can also be used more generally to refer to the internal ordering of
any representation, such as the digits in a numeral system.
Little and Big endian are two ways of storing multibyte data-types (int, float, etc). In little endian
machines, last byte of binary representation of the multibyte data-type is stored first. On the
other hand, in big endian machines, first byte of binary representation of the multibyte data-type
is stored first.

Lab Tasks

Task 1. Find out the purpose of the following commands and execute them on your system with
different parameters. [5 marks]

ls, cd, pwd, mkdir, rmdir, rm, cp, mv, touch

Task 2. In the table below you are given various network commands. Run the commands in the
Linux terminal and interpret the results. You are also required to attach screenshots of
the results obtained after you run the commands. [7 marks]

top The top program provides a dynamic real-time view of a running top
system. It can display system summary information as well as a list of
tasks currently being managed by the Linux kernel.

ps ps displays status of a selection of the active processes. ps

kill pid Kill is used to send a signal to a process, where pid stands for process id kill –SIGKILL pid

Default syntax for this is kill [-signal number or name)] pid

On your terminal to see the list of available signals, use Kill -L

A PID of -1 is special; it indicates all processes except the kill


process itself and init. It will terminate all programs and log off.
BEWARE!

chmod This command is used to grant or revert read, write, and execute
permissions from a user, group or others. Following are the symbolic
representations of three different roles:

You can check the details by typing:

man chmod
chmod 400 lab1.txt

Check what happened to your file.

Now write

chmod 700 lab1.txt

What happened to your file?

ifconfig ifconfig is used to configure the kernel-resident network interfaces. ifconfig

If no arguments are given, ifconfig displays the status of the currently


active interfaces. If a single interface argument is given, it displays the ifconfig -a
status of the given interface only; if a single -a argument is given, it
displays the status of all interfaces, even those that are down.
Otherwise, it configures an interface. ifconfig eth0

 Default Gateway Functionality


 System IP address
 System Physical Address (MAC address)

traceroute traceroute prints the route that packets take to a network host. traceroute
gives an insight to the entire path that a packet travels through, names
and identity of routers and devices in your path, network latency (the
time taken to send and receive data to each devices on the path). It’s a
tool that can be used to verify the path that your data will take to reach
its destination, without actually sending your data.

Write on your terminal

traceroute ucp.edu.pk
ping Ping is a command that is used to check the connection and latency rate
between two computers in a network. One network pings another in
order to exchange data packets (Response) to calculate the latency and
exchange rate.

Syntax for ping is:

ping [other network’s ID (Domain/IP Address)]

You might also like