0% found this document useful (0 votes)
97 views

Lab Manual FOR Unix Operating System: Ms. A.K. Ingale

Here are the commands to perform the tasks mentioned in the problem statement: 1. command1 < file1 > file2 2. ls 2> error 3. ls -l | sort -k 6M > result.txt 4. ls | head -n 10 > myfile 5. ls > result.txt 2>&1 6. touch filename.txt 7. a) grep "word" filename.txt b) sed -i '$a\'$p' filename.txt c) sed -i 's/word1/word2/g' filename.txt d) vi filename.txt This covers the basic file redirection and editing commands in Linux as requested. Let
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Lab Manual FOR Unix Operating System: Ms. A.K. Ingale

Here are the commands to perform the tasks mentioned in the problem statement: 1. command1 < file1 > file2 2. ls 2> error 3. ls -l | sort -k 6M > result.txt 4. ls | head -n 10 > myfile 5. ls > result.txt 2>&1 6. touch filename.txt 7. a) grep "word" filename.txt b) sed -i '$a\'$p' filename.txt c) sed -i 's/word1/word2/g' filename.txt d) vi filename.txt This covers the basic file redirection and editing commands in Linux as requested. Let
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

LAB MANUAL

FOR

Unix Operating System

Prepared By
Ms. A.K. Ingale

Academic Year
2020-21
EXPERIMENT NO 1
Title: Introduction to Linux
Aim: Study the basic of linux OS

Theory:

About Linux

Linux is a free, open-source operating system. All of DigitalOcean’s offered operating


systems are Linux distributions. Linux has been under active development since 1991. It has
evolved to be versatile and is used all over the world, from web servers to cellphones.
DigitalOcean offers Linux distributions on droplets because Linux is free and easy to use.
However, newcomers to Linux may find it difficult to approach the structure of an unfamiliar
operating system. This guide gently introduces key terminal skills and equips newcomers to
learn more about Linux.

The Terminal
For most of the time you access a cloud server, you’ll be doing it through a terminal shell.
The shell allows you to execute commands on the droplet.

All administrative tasks can be accomplished through the terminal. This includes file
manipulation, package installation, and user management.

The terminal is interactive. You specify commands to run. The terminal outputs the results of
those commands. Executing any command is done by typing it and pressing Enter.

Navigation
Linux filesystems are based on a directory tree. This means that you can create directories (or
“folders”) inside other directories, and files can exist in any directory.

To see what directory you are currently active in:

pwd
This stands for “print working directory”, and will print the path to your current directory.
The output can look similar to this:

/home/foo
This means that your current active directory is foo, which is inside home, which lives in the
root directory, /.

To see other files and directories that exist in your current working directory:

ls
This will give you a list of names of files and directories. To navigate into a directory, use its
name:

cd <name of directory>
This will change your new current working directory to the directory you specified. You can
see this with pwd.

Additionally, you can specify .. to change to the directory one level up in your path. To get
back to your original directory:

cd ..
We can also create new directories in our current working directory. For example, to create a
new directory called bar:

mkdir bar
Then we can <pre>cd</pre> into bar if we want. We can also delete bar if we no longer find
it useful:

rm -d bar
<pre>rm -d</pre> will only delete empty directories.

Problem Statements:
Obtain the following results

(i) To print the name of operating system

(ii) To print the login name

(iii) To print the host name

2. Find out the users who are currently logged in and find the particular user too.

3. Display the calendar for

(i) Jan 2000

(ii) Feb 1999

(iii) 9th month of the year 7 A.D

(iv) For the current month

(v) Current Date Day Abbreviation , Month Abbreviation along with year
4. Display the time in 12-Hour and 24 Hour Notations.

5. Display the Current Date and Current Time.

6. Display the message “GOOD MORNING” in enlarged characters.


EXPERIMENT NO 2
Title: Managing Files from the Command Line
Aim: To execute the commands to handle the files.

Theory:

The Filesystem Hierarchy Standard

Nearly all Linux distributions are compliant with a universal standard for filesystem directory
structure.

The FHS defines clearly determined directores for different purposes.

The symbol / is used to indicate the root directory in the filesystem hierarchy defined by the
FHS.

When a user logs in to the shell, they’ll be brought to their own user directory in /home.

The FHS defines /home as containing the home directories for regular users. (root has its own
home directory in /root, also specified by the FHS.)

Because default, common-sense locations are provided for many different kinds of files,
organisation of files for different purposes is simplified.

Permissions

On a system with multiple user accounts, determining who is allowed to interact with what
files is important.

Linux supports unix-style filesystem permissions, which restricts who can read and write
certain files.

Problem Statements:
1. Using a single command change from current directory to home directory.
2. Remove a directory using absolute pathname.
3. Create empty files myfile and yourfile under Present Working Directory.
4. Edit the content of myfile
5. Copy the contents of myfile into yourfile
6. Remove the file myfile
7. Create a hard link for yourfile
8. List the content of the present directory
9. Create the directory “test “ under current directory and move myfile and yourfile
into it
10. Remove the directory test along with the files in it using single command.
11. Rename the myfile to currentfile.
12. Write the command to create alias name for a file.
13. Is there any command available to get back a deleted file?
14. Can you remove a directory with files by using a single command.
15. Create a new file system by using mkfs command.
EXPERIMENT NO 3
Title: Documentation in Linux
Aim: To understand the use of man and info command.

Theory:

Understanding the Purpose of man Pages

Linux man pages can be an extremely helpful resource, but you must understand their
purpose and limitations. Unlike the help systems in some OSs, Linux man pages are not
supposed to be tutorial in nature; they’re intended as quick references to help somebody
who’s already at least somewhat familiar with a command, confi guration fi le, or other OS
feature.

Locating man Pages by Section Number

the man utility returns the entry in the section based on a search order typically specified by
the SECTION setting in the /etc/man_db.conf or the /etc/manpath.config configuration fi le
(depending on your distribution). You can override this behaviour by passing a section
number before the keyword. For instance, typing man passwd returns information from
manual section 1 on the passwd command, but typing man 5 passwd returns information
from manual section 5 on the /etc/passwd fie format

Problem Statements:
Getting Help Using man Pages

1. Log in to the computer in text mode or open a terminal window.


2. Type man less . This action opens the man page for the less pager.
3. Read the first screen of text. When you finish reading the last word at the bottom of the screen, press the
spacebar key. This moves the display to the next page, so that you can continue reading.
4. Press the up-arrow key. This moves the display up a single line, which is useful if you need to reread
just a few words from the end of the last page.
5. Press the down-arrow key. As you might expect, this moves the display down by one line.
6. Press the Esc key followed by the V key. This moves the display back one page.
7. Press Shift+G to move to the end of the man page.
8. Press the G key ( without using the Shift key) to move back to the start of the man page.
9. Type /OPTIONS to locate the Options section. Chances are that your first hits will be to references to
this section, rather than to the Options section itself.
10. Repeatedly press the N key until you find the Options section.
11. Press the Q key to quit from less , and therefore from reading the man page.
Getting Help Using info Pages
1. Log in to the computer in text mode or open a terminal window.
2. Type info info . You should see the top node for the info documentation appear.
3. Read the main page, using the arrow keys or the Page Down key to view the entire page.
4. Using the arrow keys, select the link to the Expert Info node near the bottom of the main page.
5. Press the Enter key to view the Expert Info node.
6. Press the U key to browse up one level—back to the main node.
7. Browse to the Advanced node.
8. Press the N key to go on to the next node on the current level, which in fact is the Expert Info node.
9. Press the Q key to exit from the info reader.
EXPERIMENT NO 4
Title: Creating, Viewing, and Editing Text Files
Aim: To understand file redirecting and editing text files commands.

Theory:

Redirection is a feature in Linux such that when executing a command, you can change the
standard input/output devices. The basic workflow of any Linux command is that it takes an
input and give an output.

The standard input (stdin) device is the keyboard.


The standard output (stdout) device is the screen.
With redirection, the above standard input/output
Error Redirection
Whenever you execute a program/command at the terminal, 3 files are always open, viz.,
standard input, standard output, standard error.

These files are always present whenever a program is run. As explained before a file
descriptor, is associated with each of these files.
File File Descriptor

Standard Input STDIN 0

Standard Output STDOUT 1

Standard Error STDERR 2

By default, error stream is displayed on the screen. Error redirection is routing the errors to a
file other than the screen.
Problem Statements:

1. Redirect the output from one file to the input of another file
2. list directories and store both error and standard output into a file error
3. Sort the output of ls command output as per the months and save the output in the
file result.txt
4. Show the first ten entries of the ls command output in a file myfile
5. Write the command to display the output of ls command on the screen and also save
the output in a file result.txt.
6. Create a empty text file
7. Edit the file and enter the data into the file
a. Search for a particular word in the file
b. Copy the entire line and past it into the last line of the file.
c. Search and replace a particular word in a text file
d. Edit the the last word of each line in the file without using arrow key
8. Open the text file in read only format
EXPERIMENT NO 5
Title: Managing Local Linux Users and Groups
Aim: To understand Managing Local Linux Users and Groups commands.

Theory:

Problem Statements:
1. Login as a normal user
2. Create file test
3. Find the permissions of file test
4. Change the ownership of the file to usr1
5. Find the current umask setting
6. Change the umask setting
7. Create file test1
8. Find out the difference
9. Switch to Super User Account
10. Change group of file test
11. Change ownership and group of file test1 with a single command
12. Change the ownership of all the files in user1’s home directory with a single command
13. Create a file abc and turn the execute bit on
14. Set setuid permission on the file abc
15. Determine if the setuid permission is enabled on the file abc
16. Create a directory testdir
17. Set setgid permission on the testdir
Logout and login as user1
19. Create a file testfile in testdir
20. Verify the ownership and the group of the testfile
21. Switch to Superuser account
22. Create a public directory dir1
23. Set stickybit (save text attribute) on dir1
24. Logout and login as a normal user user1
25. Create a file userfile1 in dir1
26. Login as a different user user2
27. Try to edit or remove the file
28. Temporarily disable user logins
29. Login as root and create groups as dba with id 501 & stud with id 555
30. Create the following list of users
31. User name UID GID Working Shell Secondary Comments Group
Mac1 501 501 Bourne shell 555 Mac1 user
Mac2 502 501 C shell NULL Mac2user
Mac3 503 501 BASH Shell 555 Mac3 user
User1 504 555 Bourne shell NULL User1 user
User2 505 555 Bash Shell NULL User2 user
Shut ?????? ??????? ?????? NULL Shutdown the system
using the user id shut
32. Examine the content of the /etc/passwd file.
33. Examine the content of the /etc/shadow file. Name the text that is found in the second
field for the users created.
34. Set password for the users mac1, mac2, mac3 & shut.
35. Select user2 from the list of users. Change the passwd aging information for user2 so that
it matches the following information.
Max inactive 2 days
Expiry 4 days
Now change the system date increase by 5 days
36. Logout of login session. Attempt to log as user2. What happens?
37. Change the shell for the user2 to Bourne shell.
38. Delete user2 including his home directory and his comments.
39. Lock the user1 with the help of a single command.
EXPERIMENT NO 6
Title: Controlling Access to Files with Linux File System Permissions

Aim: To understand and learn about File Permissions in linux

Theory:

There are three types of file permissions in UNIX

 Read (r) — Permission to Read the file


 Write (w) — Permission to Modify the file
 Execute (x) — Permission to Execute/Run the file

The users are classified in UGO

 U ~> User (e.g. root, john, jack)

 G ~> Group (e.g. sudo, admin, docker)

 O ~> Others (Non-owner and non-group members)

On detailed directory listing, one can see the file permissions

Example:
-rwxrwxrwx 1 student admins 7083 Jun 11 23:22 test.txt-rw-r--r-- 1 root root 0 Sep 12 12:40
code.c

The first file in the example can be read like:

User (U), group (G) and others (O) can read, write and execute the test.txt file

Commands in focus:

 chown — To change the owner and group

 chmod — To change file permissions

Setuid bit
The setuid bit indicates that when running the executable, it will set its permissions to that of

its owner, instead of setting it to the user who launched it. It can be identified from “s” symbol

before UGO set

For example:
srw-r — r — 1 root root 0 Sep 12 12:40 welcome

The ‘welcome’ binary will always run with root privileges.


Problem Statements:
1. Find all world-readable files.
2. Find all world-writable files.
3. Create a new directory /work/sample. Set its permissions such that only the user can
read.
4. Change the group of the shell binary to the ‘admin’ group.
5. Change the owner of the shell binary to the ‘student’ user.
6. Find all binaries for which the setuid bit is set.
7. Set setuid bit for /bin/bash. Change to user student (using switch user or su) and see if
root access can be achieved (without exiting back to).
8. Change the permission set of /work/readme.txt so that only the user (owner) can
read,write, and execute it. Use absolute mode.
9. Change the permission set of /work/readme.txt so that any user can read it, the group
can read/write to it and the user (owner) can read/write/execute it. Use absolute mode.
10. Change the permission set of /bin/bash so that only the user (owner) can read/write/
execute, group, and any user can execute it. However, whenever anyone executes it, it
should run with the privileges of the owner user. Use absolute mode.
11. Change the permission set of /work/readme.txt so that only the user (owner) can read,
write, and execute it. Use symbolic mode.
12. Change the permission set of /work/readme.txt so that any user can read it, the group
can read/write to it and the user (owner) can read/write/execute it. Use symbolic
mode.
13. Change the permission set of /work/readme.txt so that only the user (owner) can
read/write/ execute, group, and any user can execute it. However, whenever anyone
executes it, it should run with the privileges of the group. Use absolute mode.
14. Change the permission set of /work/readme.txt so that only the owner can rename or
delete this file while maintaining the existing permissions. Use absolute mode.

Note solution :
(Hint : https://blog.pentesteracademy.com/practice-linux-permissions-basics-with-13-
easy-questions-part-i-75aeaf299ebf
https://blog.pentesteracademy.com/practice-linux-permissions-basics-with-7-
activities-part-ii-3c6a212e64b9)
EXPERIMENT NO 7
Title: Manage Basic Storage

Aim: To understand and learn about Manage Basic Storage in linux

Theory:

There are many tools available to manage storage in Linux. However, only a handful are used
for day-to-day maintenance and administration. In this guide, we will cover some of the most
commonly used utilities for managing mount points, storage devices, and filesystems.

Finding Storage Capacity and Usage with df

Often, the most important information you will want to find out about the storage on your
system is the capacity and current utilization of the connected storage devices.

To check how much storage space is available in total and to see the current utilization of
your drives, use the df utility. By default, this outputs the measurements in 1K blocks, which
isn’t usually too useful. Add the -h flag to output in human-readable units:

df -h

Copy

Output

Filesystem Size Used Avail Use% Mounted on

udev 238M 0 238M 0% /dev

tmpfs 49M 624K 49M 2% /run

/dev/vda1 20G 1.1G 18G 6% /

tmpfs 245M 0 245M 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 245M 0 245M 0% /sys/fs/cgroup

tmpfs 49M 0 49M 0% /run/user/1000

/dev/sda1 99G 60M 94G 1% /mnt/data


As you can see, the /dev/vda1 partition, which is mounted at /, is 6% full and has 18G of
available space, while the /dev/sda1 partition, which is mounted at /mnt/data is empty and has
94G of available space. The other entries use tmpfs or devtmpfs filesystems, which is volatile
memory used as if it were permanent storage.

Finding Information about Block Devices with lsblk

A block device is a generic term for a storage device that reads or writes in blocks of a
specific size. This term applies to almost every type of non-volatile storage, including hard
disk drives (HDDs), solid state drives (SSDs), flash memory, etc. The block device is the
physical device where the filesystem is written. The filesystem, in turn, dictates how data and
files are stored.

Working with Filesystem Mounts

Before you can use a new disk, you typically have to partition it, format it with a filesystem,
and then mount the drive or partitions. Partitioning and formatting are usually one time
procedures, so we won’t discuss them here. 

Using the mount Command

The most basic way to use mount is to pass in a formatted device or partition and the mount
point where it is to be attached:

sudo mount /dev/sda1 /mnt

Copy

The mount point, the final parameter which specifies where in the file hierarchy the new
filesystem should be attached, should almost always be an empty directory.

Problem Statements:

1. Identify the available memory in the system.


2. Display the list of devices connected to your system including the physical
names and its instance number.
3. Identify the number of hard disks connected to the system.
4. Format a floppy and create a UFS file system in the floppy.
5. get information about the disk topology (hint use lsblk)
6. Create a file under the user’s home directory in the name of
quota.user(linux).
7. Change the ownership of the file.
8. Make an entry in usrquota in the /etc/fstab.
9. Create a file under user home direcoty in the name of quotas. (Sun
Solaris)
10. Change the ownership of the file.
11. Make an entry in rq in the /etc/vfstab.
12. Turnon the quotas by using quotaon command.
13. Assign the quota for user by using edquota command.
14. Check the quota for the file system.
15. Turn off the quota.
16. Create a directory called /kishore directory as the mount point for the file
system that has been just created.
17. Mount the new file system to the /kishore directory.
18. Add a line to /etc/fstab to make the mount for /kishore and test what
happens when the system is booted.
19. Reboot the system. Verify if /kishore is mounted or not.
20. Share a file system called /home/kishore permanently
21. Check if the file system is shared or not.
22. Mount the remote file system by using the mount command.
23. Mount the remote file system permanently
EXPERIMENT NO 8
Title: Managing Red Hat Enterprise Linux Networking
Aim: To understand and learn about Managing Red Hat Enterprise Linux Networking

Theory:

A system administrator’s routine tasks include configuring, maintaining, troubleshooting, and


managing servers and networks within data centers. There are numerous tools and utilities in
Linux designed for the administrative purposes.

ifconfig Command

ifconfig is a command line interface tool for network interface configuration and also used to
initialize an interfaces at system boot time. Once a server is up and running, it can be used to
assign an IP Address to an interface and enable or disable the interface on demand.
It is also used to view the status IP Address, Hardware / MAC address, as well as MTU
(Maximum Transmission Unit) size of the currently active interfaces. ifconfig is thus useful
for debugging or performing system tuning.

To list all interfaces which are currently available, whether up or down, use the -a flag.

$ ifconfig -a

To assign an IP address to an interface, use the following command.

$ sudo ifconfig eth0 192.168.56.5 netmask 255.255.255.0

To activate an network interface, type.

IP Command

ip command is another useful command line utility for displaying and manipulating routing,
network devices, interfaces. It is a replacement for ifconfig and many other networking
commands
o temporarily assign IP Address to a specific network interface (eth0), type.
$ sudo ip addr add 192.168.56.1 dev eth0

To remove an assigned IP address from an network interface (eth0), type.

$ sudo ip addr del 192.168.56.15/24 dev eth0

ifup, ifdown, and ifquery command

ifup command actives a network interface, making it available to transfer and receive data.

$ sudo ifup eth0

ifdown command disables a network interface, keeping it in a state where it cannot transfer


or receive data.

$ sudo ifdown eth0

ifquery command used to parse the network interface configuration, enabling you to receive
answers to query about how it is currently configured.

$ sudo ifquery eth0

Ethtool Command

ethtool is a command line utility for querying and modifying network interface controller
parameters and device drivers. The example below shows the usage of ethtool and a
command to view the parameters for the network interface.
Ping Command

ping (Packet INternet Groper) is a utility normally used for testing connectivity between
two systems on a network (Local Area Network (LAN) or Wide Area Network (WAN)). It
use ICMP (Internet Control Message Protocol) to communicate to nodes on a network.
To test connectivity to another node, simply provide its IP or host name, for example.
$ ping 192.168.0.103

PING 192.168.0.103 (192.168.0.103) 56(84) bytes of data.

You can also tell ping to exit after a specified number of ECHO_REQUEST packets, using
the -c flag as shown.

Route Command

route is a command line utility for displaying or manipulating the IP routing table of a Linux
system. It is mainly used to configure static routes to specific hosts or networks via an
interface.
You can view Kernel IP routing table by typing.

$ route

Destination Gateway Genmask Flags Metric Ref Use Iface


default gateway 0.0.0.0 UG 100 0 0 enp0s3

There are numerous commands you can use to configure routing. Here are some useful ones:

Add a default gateway to the routing table.

$ sudo route add default gw <gateway-ip>

Add a network route to the routing table.

$ sudo route add -net <network ip/cidr> gw <gateway ip> <interface>

Problem Statements:

1. Add a route to the 192.0.2.0/24 network that uses the gateway running on 198.51.100.1
2. Use the hostname command to determine your hostname
3. Determine your IP and MAC addresses( ifconfig)
4. display all your network interfaces(hint: ip a)
5. Run nmcli d show and record the output
6. Use the arp command to determine if your neighbour's IP address is listed. If not, ping your
neighbour's IP address and then run the arp command again. (Alternatively, you can use
arping.)
7. Use the tcpdump command to analyze network traffic. Watch the network traffic for a few
minutes then summarize what you have seen. For example, in the Terminal window, if your
Ethernet card is called eth1, run sudo tcpdump -i eth1 (The sudo command is required
because tcpdump requires administrator privileges.) Then, start Firefox and log on to
Blackboard, for example.
8. Use the tracepath or traceroute command to find a route to various hosts on the Internet.
For example, tracepath ritindia.edu

(http://technology.niagarac.on.ca/courses/ctec1767/lab9/ctec1767-2017WS-lab9-Linux.pdf)
EXPERIMENT NO 9
Title: Archiving and Copying Files between Systems
Aim: To understand and learn about Archiving and Copying Files between Systems in linux

Theory:

tar and gzip provide a standard interface for creating archives and compressing files on
Linux. These utilities take a large number of files, save them together in an archive, and
compresses the archive to save space. tar does not compress files by itself. Used in
conjunction with gzip, an archived file can be compressed to reduce disk space. The resulting
archived file has the file extension, tar.gz and is sometimes called a “tarball”.

The flags used in these example stand for:

-c: Create a new archive in the form of a tar file.


-v: Verbose flag, outputs a log after running the command.
-z: Zips or unzips using  gzip.
-x: Extract a file from the archive.
-f: Define STDOUT as the filename, or uses the next parameter.

Common Options for Archiving

Additional flags used with the tar command are:

Flag Function

-A Append tar files to an existing archive.

-d Show differences between an archive and a local filesystem.

-delete Delete from the archive.


Flag Function

-r Append files to the end of an archive.

-t List the contents of an archive.

-u Append but don’t overwrite the current archive.

These are the basics for working within the command line. Be sure to check the man
pages man tar  for a more detailed listing of possible flags when compressing and
extracting files

Problem Statements:
1. Create three sample directories with some files to use with the tar command.
2. Use the tar command to backup all three directories into single tar file.
3. Use the tar command to verify that the files are on the tape and in a single tar
file.
4. Use the tar command to backup the sample directories into four different
files.
5. Verify the number of tar files using the tar command.
6. Backup a directory using cpio.
7. Restore the files which are backuped in the floppy.
8. Back up a floppy to a floppy using dd.
9. Restore from floppy to home directory using dd.
EXPERIMENT NO 10
Title: Installing and Updating Software Packages

Aim: To understand and learn about Installing and Updating Software Packages

Theory:

One of the most difficult things to get used to in the Linux world is installing new software
packages. In the world of Windows, every program comes with a Setup.exe program that
asks you some very easy questions and takes care of the job for you. While Linux software
can be almost that easy to install, you will sometimes find software that seems to fight every
step of the way. I can’t cover all the problems you might run into, but I’ll try to give you the
basics and a few pointers to help get you over the rough spots.

Software tends to come in “packages”. In the Windows world a package is a Setup.exe or


a program.zip file. On a Mac a package is a program.dmg or a program.sit file. In the Linux
world, there are several kinds of packages, and each distribution has its own preferred
package format.

The standard Linux package format (according to the Linux Standard Base) is RPM. RPM
is a packaging system originally developed by Red Hat and widely used in the Linux
community. Distributions using it include Fedora, Mandriva, Red Hat (naturally), and SUSE.
An RPM package file normally will be named something like program-version-other.rpm

Another popular package format is DEB, the Debian software package. Debian packages and
the Advanced Packaging Tool (APT) were the first to introduce several advanced features
that are now common, such as automatic dependency resolution and signed packages. Debian
packages are used by Debian GNU/Linux (naturally), and distributions based on it, including
Ubuntu, Knoppix, and Mepis. A Debian package file normally will be named something
like program-version-other.deb

Debian, Ubuntu: APT

There is a broad array of tools for working with DEB packages, but the one you will
commonly use is apt-get, arguably the easiest of Linux package management tools. apt-get is
so easy because it not only keeps track of what packages are installed, but also what other
packages are available. It will even download them from the Internet for you (if properly
configured).

apt-get install ${packagename}

To remove software is just as easy.


apt-get remove ${packagename}

Although the repositories that contain installable packages might live on the Internet or on a
disc somewhere, APT keeps a local database on your hard drive with a list of all available
packages and where to find them. This database needs to be explicitly updated. To update the
APT database:

apt-get update

A common idiom is to update your package database, and then upgrade all the packages that
have patches or security updates to install. The following command will do this all at once.

apt-get update; apt-get upgrade

For a more indepth apt-get tutorial and other resources, see Managing Software with APT
and dpkg.

Fedora, Red Hat: yum

yum does for RPM packages roughly what apt-get does for Debian packages. Like apt-
get, yum can download and install packages from a configured repository.

yum install ${packagename}

To remove software is just as easy.

yum remove ${packagename}

yum does not keep a local copy of your package database by default, so normally there is no
need to update it. To install all available security patches and bug fixes, use this command:

yum update

You can also explicitly update a single package with:

yum update ${packagename}


For a more indepth yum tutorial and other resources, see Managing Software with yum and
rpm.

Mandriva: urpm

Mandriva Linux (formerly Mandrake and Connectiva) has a toolset similar to APT
called urpmi. To install software:

urpmi ${packagename}

To remove software:

urpme ${packagename}

To update the local package database:

urpmi.update -a

To install security updates and bug fixes:

urpmi --auto-select

For a more indepth yum tutorial and other resources, see Managing Software with urpm.

Tar Balls

No, this is not a naughty term! A tar ball is a (usually compressed) archive of files, similar to
a Zip file on Windows or a Sit on the Mac. Tar balls come in files that end in .tar, .tar.gz, .tgz,
or something along these lines. To unpack a tar ball, use this command.

tar -xzvf ${filename}.tar.gz

The parameters are x to extract files, z to filter through gzip for decompression (leave this off
if the file does not have a gz extension), v for verbose mode so you can tell what’s going
on, f indicating there will be a filename to follow. You may want to create an alias called
“untar” that feeds in these options if you have a hard time remembering command line
options as I do.

This command will not install the software, it will only extract the archived files. It is your
job then to find the README file or INSTALL file and read its instructions for installation.
If the archive contains binaries there will usually be a setup script (often called install.sh) that
you must execute as SuperUser.

Very often, software delivered in tar balls is not in executable form, but in source code,
which must first be compiled before it can be installed. For more details on this,
see Installing Software from Source Code.

Other Systems

Some other Linux distributions have their own way of managing packages, notably SUSE.
SUSE uses RPM as its native package format, but has its own high level tool to manage
system software installation.

SUSE Linux uses a tool called yast (which allegedly is an acronym for Yet Another Setup
Tool) to perform all kinds of system administration tasks, including installing sof

Problem Statements:
1. On serverb configure a software repository to obtain updates. Name the
repository as errata and configure the repository in
the /etc/yum.repos.d/errata.repo file. It should access
http://content.example.com/rhel8.0/x86_64/rhcsa-practice/errata. Do not
check GPG signatures.
2. On serverb, install new package xsane-gimp and the Apache HTTP Server
module from the 2.4 stream and the common profile.
3. For security reasons, serverb should not be able to send anything to print.
Achieve this by removing the cups package. Exit from the root account.
4. The start script downloads the rhcsa-script-1.0.0-1.noarch.rpm package in
the /home/student directory on serverb. Confirm that the package rhcsa-
script-1.0.0-1.noarch.rpm is available on serverb. Install the package. You will
need to gain superuser privileges to install the package. Verify that the
package is installed. Exit from serverb.

SOLUTION

1. On serverb configure a software repository to obtain updates. Name the


repository as errata and configure the repository in
the /etc/yum.repos.d/errata.repo file. It should access
http://content.example.com/rhel8.0/x86_64/rhcsa-practice/errata. Do not
check GPG signatures.

1.1. From workstation use the ssh command to log in to serverb as the student
user.
1.2. Use the su - command to switch to the root user. The password is redhat.

1.3. Create the file /etc/yum.repos.d/errata.repo with the following content

2. On serverb, install new package xsane-gimp and the Apache HTTP Server


module from the 2.4 stream and the common profile.

2.1. Use the yum list command to list the available packages for xsane-gimp.

2.2. Install the latest version of the xsane-gimp package using the yum
install command.

2.3. List available modules and streams. Look for the httpd module. Use
the yum install command to install the httpd module with the 2.4 stream and
the common profile.
3. For security reasons, serverb should not be able to send anything to print.
Achieve this by removing the cups package. Exit from the root account. 3.1.
Use the yum list command to list the installed cups package.

3.2. Use the yum remove command to remove the cups package.

3.3. Exit from the root account.

4. The start script downloads the rhcsa-script-1.0.0-1.noarch.rpm package in


the /home/ student directory on serverb. Confirm that the package rhcsa-
script-1.0.0-1.noarch.rpm is available on serverb. Install the package. You will
need to gain superuser privileges to install the package. Verify that the
package is installed. Exit from serverb. 4.1. Use the rpm command to confirm
that the rhcsa-script-1.0.0-1.noarch.rpm package is available on serverb by
viewing the package information.

4.2. Use the sudo yum localinstall command to install the rhcsa-script-1.0.0-


1.noarch.rpm package. The password is student.
 

4.3. Use the rpm command to verify that the package is installed.

4.4. Exit from serverb

You might also like