Lab 1
Lab 1
Lab 1
Punjab
(Faculty of Information Technology)
Lab 1
Reference Material
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]
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.
kill pid Kill is used to send a signal to a process, where pid stands for process id kill –SIGKILL pid
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:
man chmod
chmod 400 lab1.txt
Now write
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.
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.