OS Lab 4 (Revised)
OS Lab 4 (Revised)
This lab will introduce the basic concept of Text Processing Tools and Basic System Configuration
Tools in Linux to you.
Activity Outcomes:
This lab teaches you the following topics:
1. An introduction to some of the most useful text-processing utilities
2. Using Linux's graphical and text-based configuration tools to manage networking, printing and
date/time settings
Pipelines
The ability of commands to read data from standard input and send to standard output is
utilized by a shell feature called pipelines. Using the pipe operator “|” (vertical bar), the
standard output of one command can be piped into the standard input of another:
For example, we can use less to display, page-by-page, the output of any command that sends
its results to standard output:
$ls -l /usr/bin | less
Filters
Pipelines are often used to perform complex operations on data. It is possible to put several
commands together into a pipeline. Frequently, the commands used this way are referred to as
filters. Filters take input, change it somehow and then output it. The first one we will try is
sort.
Sort
Imagine we wanted to make a combined list of all of the executable programs in /bin and
/usr/bin, put them in sorted order and view it:
$ls /bin /usr/bin | sort | less
Since we specified two directories (/bin and /usr/bin), the output of ls would have
consisted of two sorted lists, one for each directory. By including sort in our pipeline,
we changed the data to produce a single, sorted list.
Networking
There are number of commands that can be used to configure and control networking
including commands used to monitor networks and those used to transfer files. In this lab, we
will also see the above-mentioned commands. In addition, we are going to explore the ssh
program that is used to perform remote logins.
$ date
Sample outputs:
Sample outputs:
2019-01-21 01:30:50.608410+05:30
To change both the date and time, use the following syntax:
# timedatectl set-time YYYY-MM-DD HH:MM:SS
Where,
1. HH : An hour.
2. MM : A minute.
3. SS : A second, all typed in two-digit form.
4. YYYY: A four-digit year.
5. MM : A two-digit month.
6. DD: A two-digit day of the month.
For example, set the date ’23rd Nov 2015′ and time to ‘8:10:40 am’, enter:
# timedatectl set-time '2015-11-23 08:10:40'
# date
Lab Activities
Activity 1:
This activity is related to file permission. Perform the following tasks
Solution:
0. Touch /test/testfile.txt
1. Less testfile.txt
2. wc testfile.txt
3. grep testfile.txt
4. head -n 3 testfile.txt
5. tail -n 3 testfile.txt
Activity 2:
Perform the following tasks
1. Find all the files with extension txt in the /test directory
2. Find the first line of the list of files in the /test directory
3. Find the last line of the list of files in the /test directory
4. Produce and view a single sorted list of files by combining two directories: /Desktop and /bin
Solution
Activity 3:
Perform the following tasks
1. Examine the network using Ping command and view the performance statistics
Solution
1. ping localhost