Osa Lab Manual
Osa Lab Manual
Osa Lab Manual
Graded Exercise
IV Semester
Computer Science
Certificate
Register Number :
Institution :
This is certified to be the bonafide work of the student in the Operating System and
Course Coordinator
Examiner Signature
1.
2.
List of Experiments
5 Process Synchronization
6 Memory Management
7 Shell Programming
9 Network Management
10 User Authentication
13 Storage Management
An Operating system (OS) is system software that manages computer hardware, software
resources, and provides common services for computer programs. In other words, an Operating
System (OS) is software that acts as an interface between computer hardware components and the
user.
1. Types of OS installation
Attended installation:
An installation process usually needs a user who attends it to make choices, such as
accepting or declining an end-user license agreement (EULA), specifying preferences
such as the installation location, supplying passwords or assisting in product activation.
In graphical environments, installers that offer a wizard-based interface are common.
Attended installers may ask users to help mitigate the errors.
o For example, if the disk in which the computer program is being installed was
full, the installer may ask the user to specify another target path or clear enough
space in the disk.
Silent installation:
An installation that does not display messages or windows during its progress.
"Silent installation" is NOT the same as "unattended installation". [All silent installations
are unattended but not all unattended installations are silent.]
In bigger organizations where thousands of users work, deploying the applications
becomes a typical task and for that reason silent installation is performed so that the
application is installed in background without affecting the work of user.
Unattended installation:
An installation that is performed without user interaction during its progress or with no
user present at all.
One of the reasons to use this approach is to automate the installation of a large number
of systems.
An unattended installation either does not require the user to supply anything or has
received all necessary input prior to the start of installation. Such input may be in the
form of command line switches or an answer file, a file that contains all the necessary
parameters.
o For example, if the installation medium was faulty, the installer should fail the
installation, as there is no user to fix the fault or replace the medium. Unattended
installers may record errors in a computer log for later review.
Headless installation:
Installation performed without using a computer monitor connected.
In attended forms of headless installation, another machine connects to the target
machine (for example, via a local area network) and takes over the display output.
Since a headless installation does not need a user at the location of the target computer,
unattended headless installers may be used to install a program on multiple machines at
the same time.
Clean installation:
A clean installation is one that is done in the absence of any interfering elements such as
old versions of the computer program being installed or leftovers from a previous
installation.
The clean installation of an operating system is an installation in which the target disk
partition is erased before installation.
Since the interfering elements are absent, a clean installation may succeed where an
unclean installation may fail or may take significantly longer.
Network installation:
Network installation (netinstall), is an installation of a program from a shared network resource
that may be done by installing a minimal system before proceeding to download further packages
over the network.
This may simply be a copy of the original media but software publishers which offer site licenses
for institutional customers may provide a version intended for installation over a network.
=== * ===
2. Boot methods
Booting is the process of starting a computer as initiated via hardware such as a button or by a
software command.
Types of Booting:
Warm Booting: The Warm Booting is that in which system starts from the starting or
from initial state means.
o In the Warm Booting the system will be started from its beginning state means,
first, the user will press the Power Button, then this will read all the instructions
from the ROM and the Operating System will be automatically gets loaded into
the System (RAM).
Cold Booting: The Cold Booting is that in which System automatically starts when the
system is in a running state.
o For example, due to Light Fluctuation, the system will automatically restarts. In
this, chances of damaging of system are more. The system will now be start from
its initial state, so some files may be damaged because they are not properly
stored into the system.
=== * ===
3. File System and Formatting:
File System:
A file system is a process of managing how and where data on a storage disk, which is
also referred to as file management or FS.
It is a logical disk component that compresses files separated into groups, which is
known as directories.
The file system enables user to view a file in the current directory as files are often
managed in a hierarchy.
It is abstract to a human user and related to a computer; hence, it manages a disk's
internal operations.
NTFS is the most common file system in modern times (Windows OS).
Without file management, it would be impossible for a file with the same name to exist
and also impossible to remove installed programs and recover specific files.
Formatting:
Formatting is a process of preparing the storage device to store the data. Formatting storage
device will erase the earlier contents of the device.
=== * ===
Virtual Box:
VirtualBox is a cross-platform virtualization application. It installs on existing operating
systems and also it extends the capabilities of the existing computer so that it can run
multiple operating systems (it means, inside multiple virtual machines) at the same
time.
Host operating system (host OS): the operating system of the physical
computer on which VirtualBox was installed.
Guest operating system (guest OS): the operating system that is running
inside the virtual machine.
Virtual machine (VM). When running, a VM is the special environment that
VirtualBox creates for guest operating system.
1. Installation steps
• Double click or right click on the Oracle VM Virtual Box Executable file.
• Then “Custom setup with all the features of VM” screen appears Click next.
• Next “Select the way you want features to be installed” Screen appears
Click next.
3. Then select the desired memory size “1024MB” and click on “Next” button.
4. And next select “Create Virtual Hard Disk now” and Click on “Create” button.
7. Enter the name of Virtual Hard disk then select the size of hard disk as
per requirement (10GB) and click “Create” button.
8. Now go to “Settings”.
10. Select “Disk” icon and choose the “Choose/Create a virtual optical disk
file” then select the “Ubuntu ISO file” that you already downloaded. Then
click on “OK” button.
11. Then click on the “Start” button and carry on with the installation process of
ubuntu.
Operating System and Administration - 20CS42P - 16
-
Department of Computer Science and Engineering
12. Once the OS is installed you can use the OS in Virtual Machine any time.
ls (list)
=== * ===
pwd (Present Working Directory)
Will give the present working directory path information
Example 1 : pwd
=== * ===
mkdir (Make Directory)
mkdir will create a new directory (folder)
Syntax: mkdir directoryname(folder name)
Example 1: mkdir polytechnic // will create directory with name polytechnic
=== * ===
cd (Change Directory)
cd is used to Change Directory
Change to home direcotory
o cd // Change to default home directory
o cd ~ // Change to default home directory
The vi editor has three modes of operation viz. the command mode, the insert mode, and the ex-
command mode.
1) Command mode
In this mode, all the keys work as commands. These keys are used for inserting, appending, deleting,
opening new lines, moving the cursor over the paragraphs and sentences, etc. In this mode, the keys are
not displayed but each key performs an operation.
By default the vi editor is in command mode, hence we cannot type text in command mode. In order to
write programs or text in the vi editors, we need to switch to the insert mode which can be done by
pressing the escape button.
2) Insert mode
In this mode, we can insert, append, edit or replace texts. We can switch from the command mode to
Insert mode by pressing the escape button and then pressing I or A to enter into insert mode.
3) Ex command mode
This mode is used for entering commands at the bottom line of the vi editor called a command line. To
switch to Ex command mode press the escape key then type: (colon). In order to save the contents and
quit from the vi editor press wq after the : (colon). i.e :wq.
To create a sample file in editor open terminal and type vi in prompt type command
And give appropriate permission to the file and run command to view output
=== * ===
rm (Remove File)
Will remove (delete) the files
Syntax: rm FileName
o rm path/Filename
Example:
o rm a.txt // Assume a.txt is present in current directory
=== * ===
cp (Copy)
Used to create a copy of a existing file.
Copy an existing file in current directory to another file in the current directory. Make
sure that the file to be copied must be exists in specified location.
Syntax: cp file1 file2
cp path1/file1 path2/file2 // creates copy of file1 in current directory or in specified
directory
cp a.txt b.txt (Make sure file a.txt exists in current directory)
o new file b.txt is created and contents of b.txt is same as a.txt
=== * ===
mv (Move)
Used to rename the file (in other words, used to move the files from one location to
another location)
It can be used to rename the Directory (Folder) also.
Example 1:
o mv OldFileName NewFileName
=== * ===
Pipes: The pipe command lets user sends the output of one command to another. Piping, as the
term suggests, can redirect the standard output, input, or error of one process to another for
further processing.
=== * ===
more
It is a filter for paging through text one screenfull at a time.
o more filename
Press Space bar / Return Key to read the remaining parts of the file.
Press q to quit viewing contents
less
It is used to viewing the files instead of opening the file.Similar to more command
but it allows backward as well as forward movement.
Example:
less test.sh
cmp (Compare)
compare two files byte by byte
Syntax: cmp [ file1] [file2]
File Permissions
There are three users in linux namely owner(u), group(g), others(o).
o Note: For all users can be identified with letter a
All three uses will have three possible permissions namely read(r), write(w), execute(e)
Numbers assigned for permissions are read(4), write(2), execute(1)
Examples
add execution permission to group and other users for file output.pdf
o chmod go+x output.pdf
o ls output.pdf -l
o -rwxrwxr-x 1 admincs admincs 1.9M Mar 28 08:45 output.pdf
Example 2:
o chmod 777 output.pdf will set all permissions to all users
o chmod 765 output.pdf will set rwxrw-r-x to users
o chmod 654 output.pdf will set rw-r-xr-- to users
=== * ===
Decompressing files
To decompress we write,
gunzip k.c.gz
Syntax:
sort filename
uniq
uniq filter removes duplicate lines from a sorted file. It is often seen in a pipe coupled
with sort.
uniq [filename]
removes the duplicates lines as well as displys frequency of duplicate lines.
== * ===
cut
A tool for extracting fields from files.
Important options are -d, which specifies delimiter to separate fields, -f which indicates
field numbers
Example 1: cut –c 1-2 headtail.txt
grep
A multi-purpose file search tool that uses Regular Expressions. (Global Regular
Expression Pring).
o grep pattern [FileName...]
o
wc
wc gives a "word count" on a file or I/O stream:
Syntax: wc -lwc FileName
Operating System and Administration - 20CS42P - 29 -
Department of Computer Science and Engineering
Example:
o wc headtail.txt
=
== * ===
Process
Starting a Process
Foreground Processes
Every process by default runs in Foreground (which means the output is printed on the
screen.) The best example for the foreground process is the ls command which prints the
output on the screen by listing the files and directories.
When a program is running in the foreground, user cannot start another process without
completing the previous process. [ It is because of this reason foreground process is
considered a time-consuming process.]
Background Processes
When a process starts running and it is not visible on the screen it is called a background
process.
User can simultaneously run ‘n’ number of commands in the background process.
To enable the background process, provide ampersand symbol (&) at the end of the command.
They run in the background and usually do not need user input. For example
Antivirus.
Example : ls &
sleep
command is used to create a dummy job. A dummy job helps in delaying the
Operating System and Administration - 20CS42P - 31 -
Department of Computer Science and Engineering
Jobs
The jobs command will list all jobs on the system; active, stopped, or
otherwise.
ps
The default output of ps is a simple list of the processes running in current terminal.
Example: ps
PID TTY TIME CMD
23989 pts/0 00:00:00 bash
24148 pts/0 00:00:00 ps
Example 1:
bg: background
bg used to place foreground jobs in background. [used to send a process running in the
foreground to the background in the current shell.]
Syntax: bg [ job_spec]
Example: sleep 500 is a command which is used to create a dummy job which runs for
500 seconds.
o Use jobs command to list all jobs
o Create a process using sleep command, get job id as 1
o Put that process in background using id
$ jobs // Display current jobs running and displayed nothing
$ sleep 500 // Create one job, which sleeps for 500 seconds.
^z // Terminate the job by pressing Ctrl + z
o [1]+ Stopped sleep 500
$ jobs // Display current jobs running and displayed one job stopped
o [1]+ Stopped sleep 500
$ bg %1 // Refer the process by job number place it in background
o [1]+ sleep 500 &
$ jobs // Display current jobs running and displayed one job which is running.
[1]+ Running sleep 500
=== * ===
fg: forground
bg is a command that moves a background process on current Linux shell to the
foreground.
Syntax: bg [ job_spec]
Place the jobs identified by each job_spec in the foreground, making it the current job.
Example: sleep 500 is a command which is used to create a dummy job which runs for 500
seconds.
$ jobs
$ sleep 500
^z
o [1]+ Stopped sleep 500
$ jobs
o [1]+ Stopped sleep 500
$ bg %1
o [1]+ sleep 500 &
$ jobs
Operating System and Administration - 20CS42P - 35 -
Department of Computer Science and Engineering
=== * ===
nohup
The nohup command is one way of blocking the SIGHUP signal and allowing processes to
complete even after logging out from the terminal/shell.
SIGHUP (Signal Hang UP) is a signal that terminates a Linux process when its controlling
terminal is closed. The syntax for using the nohup command is:
To run a command using nohup without any arguments, simply follow the syntax:
nohup [command]
=== * ===
Stopping a process
kill
This command terminates running processes on a Linux machine.
To use these utilities you need to know the PID (process id) of the process you
want to kill
Syntax –
kill PID
To find the PID of a process simply type
pkill
command used to send signal to kill process by process name.
while issuing pkill, make sure that selected process name is the correct process to be
stopped, verify it by its full path by issuing pgrep –f processname.
Syntax: pkill -f ProcessName
=== * ===
nice
nice command in Linux helps in execution of a program/process with modified
scheduling priority.
It launches a process with a user-defined scheduling priority.
Linux Kernel schedules the process and allocates CPU time accordingly for each of them.
The kernel stores a great deal of information about processes including process priority
which is simply the scheduling priority attached to a process.
Processes with a higher priority will be executed before those with a lower priority, while
processes with the same priority are scheduled one after the next, repeatedly.
There are a total of 140 priorities and two distinct priority ranges implemented in Linux.
The first one is a nice value (niceness) which ranges from -20 (highest priority value) to
19 (lowest priority value) and the default is 0.
The other is the real-time priority, which ranges from 1 to 99 by default, then 100 to 139
are meant for user-space.
Operating System and Administration - 20CS42P - 37 -
Department of Computer Science and Engineering
Syntax
nice [OPTION] [COMMAND [ARG]...]
nice -5 wc –l &
top
The top command has been around a long time and is very useful for viewing details of
running processes and quickly identifying issues such as memory hogs.
Its default view is shown below. Example 1: top
The cron can be defined as a software utility that is provided by a Linux-like OS that operates
the scheduled operation on a predetermined period. It's a daemon process and executes as
a background process. It performs the described tasks at a predefined period when a
condition or event is encountered without user intervention.
The crontab ("cron table") is a list of commands for executing the scheduled operations at a
particular time. It permits the user for adding, removing, or modifying the scheduled
operations.
The syntax of the crontab command contains six parts separated by a space in which the first
five parts illustrate the time to execute the operation and the last part illustrates the command.
1. crontab -e
Simple Example:
Example 2:
To run a job at 4.35 pm edit crontab
at
at command is a command-line utility that is used to schedule a command to be
executed at a particular time in the future.
Jobs created with at command are executed only once.
The at command can be used to execute any program or mail at any time in the future.
It executes commands at a particular time and accepts times of the form HH:MM to run a
job at a specific time of day.
In the command, expression like noon, midnight, teatime, tomorrow, next week, next
Monday, etc. could be used with at command to schedule a job.
Syntax: at [OPTION...] runtime
Working with at command
Command to list the user’s pending jobs:
o at -l
OR
o atq
Schedule a job for the coming Monday at a time twenty minutes later than the current
time:
o at Monday +20 minutes
Schedule a job to run at 1:45 Aug 12 2020:
o at 1:45 081220
Schedule a job to run at 3pm four days from now:
o at 3pm + 4 days
Schedule a job to shutdown the system at 4:30 today:
o echo "shutdown -h now" | at -m 4:30
Schedule a job to run five hour from now:
o at now +5 hours
05 – Process Synchronization
Using the ps
The "-T" option for the ps command enables thread views.
The "SPID" column represents thread IDs, and "CMD" column shows thread names.
To restrict the top output to a particular process and check all threads running inside the process:
Example 2: top -H -p 1572
Using htop
A more user-friendly way to view threads per process is via htop, an ncurses-based interactive
process viewer.
This program allows user to monitor individual threads in tree views.
To enable thread views in htop, launch htop, and press F2 to enter htop setup menu.
sChoose "Display option" under "Setup" column, and toggle on "Tree view" and "Show custom
thread names" options. Presss F10 to exit the setup.
=== * ===
06 – Memory Management
1. free command
Commands to view memory consumption:
2. /proc/meminfo
Check memory usage by reading the file at /proc/meminfo.
Know that the /proc file system does not contain real files.
o They are rather virtual files that contain dynamic information about the kernel
and the system.
Check the values of MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree. They
indicate same values of memory usage as the free command.
3. vmstat
vmstat –s
Portion of output is
The top few lines indicate total memory, free memory etc and so on.
4. top command
The top command is generally used to check memory and cpu usage per process.
It also reports total memory usage and can be used to monitor the total RAM usage.
The header on output has the required information.
Check the KiB Mem and KiB Swap lines on the header. They indicate total, used and free
amounts of the memory. The buffer and cache information is present here too.
Portion of output is
5. htop
Similar to the top command, the htop command also shows memory usage along with
various other details.
The header on top shows cpu usage along with RAM and swap usage with the
corresponding figures.
.
s="Hello"
strlen=${#s}
for (( i=$strlen-1; i>=0; i-- ));
do
revstr=$revstr${s:$i:1}
done
echo "Original String : $s"
echo "Reversed String : $revstr"
=== * ===
8 – Automation of System Tasks
The cron is a software utility, offered by a Linux-like operating system that automates the
scheduled task at a predetermined time.
The rules which govern the format of date and time field as follows:
When any of the first five fields are set to an asterisk(*), it stands for all the values of the
field. For instance, to execute a command daily, we can put an asterisk(*) in the week’s
field.
One can also use a range of numbers, separated with a hyphen(-) in the time and date
field to include more than one contiguous value but not all the values of the field. For
example, we can use the 7-10 to run a command from July to October.
The comma (, ) operator is used to include a list of numbers which may or may not be
consecutive. For example, “1, 3, 5” in the weeks’ field signifies execution of a command
every Monday, Wednesday, and Friday.
A slash character(/) is included to skip given number of values. For instance, “*/4” in the
hour’s field specifies ‘every 4 hours’ which is equivalent to 0, 4, 8, 12, 16, 20.
As cron processes will run in background, so to check whether scripts are executed or
2. crontab -e
Example 2:
To run a job at 4.35 pm edit crontab
Check output
=== * ===
09 – Network Management
First, ensure that the wired network connection is already turned on by going to the network tab in the settings.
If you still do not have the internet connection established, you need to change the machine’s network adapter
settings from the Virtual machine settings.
For changing the network settings and for the modifications to take effect, turn off the virtual machine.
After closing the Virtual Machine, open the virtual machine settings by right-clicking on the machine and
selecting the settings option from the context menu.
In the settings window that appeared, click on the Network tab from the left bar.Step 4: Enable the Network
Adapter
In the machine’s Network Adapter settings, click on the “Enable Network Adapter” to enable the network
adapter and modify its settings.
In the machine’s Network Adapter settings, click on the “Enable Network Adapter” to enable the network
adapter and modify its settings.
If it is unchecked, then definitely this was the reason behind the internet connection not working because there
was no network adapter assigned to the Virtual machine by the VirtualBox.
After enabling the network adapter for the virtual machine, you can select the preferred method from the
“attached to” dropdown menu to attach the virtual network adapter to your host OS network.
We will suggest selecting the Bridged Adapter because this way, the virtual machine will be connected to the
network using the host OS Ethernet adapter.
After selecting the appropriate method from the “Name” drop-down, select the right device that you want to
choose.
After configuring all the described settings, click on the OK button to save the settings.
You will have the internet connection working perfectly fine on your virtual machine in the virtual box.
ifconfig:
ifconfig(interface configuration) is used to configure the kernel-resident network
interfaces.
It is used at the boot time to set up the interfaces as necessary.
It is used to assign the IP address and netmask to an interface or to enable or disable a
given interface.
Example 1: ifconfig -a
-a : This option is used to display all the interfaces available, even if they are down.
=== * ===
iwconfig:
iwconfig command in Linux is like ifconfig command, in the sense it works with kernel-
resident network interface but it is dedicated to wireless networking interfaces only.
It is used to set the parameters of the network interface that are particular to the wireless
operation like SSID, frequency etc.
iwconfig may also be used to display the parameters, and the wireless statistics which are
extracted from /proc/net/wireless.
=== * ===
ethtool:
The ethtool utility on Linux allows you to view and change some of your network-driver and interface-card
settings, especially for wired devices.
arpwatch:
ARP also known as “Address Resolution Protocol” is a very useful tool to find IP to MAC address mappings.
It is also used to manipulates or displays the kernel’s IPv4 network neighbor cache.
telnet:
The telnet command is used to create a remote connection with a system over a TCP/IP
network.
It allows us to administrate other systems by the terminal.
ftp:
ftp is the user interface to the Internet standard File Transfer Protocol.
The program allows a user to transfer files to and from a remote network site.
Prerequisites:
Operating System and Administration - 20CS42P - 65 -
Department of Computer Science and Engineering
Example 2: Download the file from ftp server (Connection done in Example 1)
get a.txt /home/admincs/Desktop/test.txt
o will download the file a.txt from ftp server to current user Desktop with file
name test.txt
Example 3: Upload the file from local machine to ftp server (Connection done in Example
1)
put /home/admincs/index.html test.html
will upload the file index.html from current (local /home/admincs) user to remote ftp
server with name test.html
netstat
netstat is a command line utility for Linux that prints network connections, routing tables,
interface statistics, masquerade connections, and multicast memberships.
netstat can be used to diagnose network issues and service problems.
Important Options used:
o -a: all listening and non-listening ports, -t tcp ports
o -u udp ports, -l listening ports
o -s Statistics of ports, -r Kernel Routing Information
ping
ping (Packet Internet Groper) command is used to check the network connectivity
between host and server/host.
This command takes as input the IP address or the URL and sends a data packet to the
specified address with the message “PING” and get a response from the server/host this
time is recorded which is called latency.
Example
traceroute:
o traceroute command in Linux prints the route that a packet takes to reach the host.
o This command is useful when user want to know about the route and about all the hops
that a packet takes.
The first column corresponds to the hop count. The second column represents the
address of that hop and after that, three space-separated time in milliseconds.
o traceroute command sends three packets to the hop and each of the time refers to
the time taken by the packet to reach the hop.
Options used:
-4 Use ip version 4 i.e. use Ipv4 -6 Use ip version 6 i.e. use Ipv6
-F Do not fragment packet.
=== * ===
tcpdump
tcpdump is a packet sniffing and packet analyzing tool for a System Administrator to
troubleshoot connectivity issues in Linux.
It is used to capture, filter, and analyze network traffic such as TCP/IP packets going
through system.
It is many times used as a security tool as well. It saves the captured information in a
pcap file, these pcap files can then be opened through Wireshark or through the command
tool itself.
tcpdump -i enp1s0
Importatnt Options used:
o –c Specifice Number of Packets captured
o –e Print the link-level header on each dump line.
10 – User Authentication
o
=== * ===
Useraddd command does not set any valid password by default, and user cannot log in
until a password is set.To set the password user the following command:
passwd
The passwd command changes passwords for user accounts.
A normal user may only change the password for their own account, while the superuser
may change the password for any account.
=== * ===
userdel
userdel command in Linux system is used to delete a user account and related files.
This command basically modifies the system account files, deleting all the entries which
refer to the username LOGIN.
Syntax: sudo userdel neuserw
=== * ===
usermod
Groups: Groups in
Linux refer to the user groups. In Linux, there can be many users of a single system, (normal
user can take uid from 1000 to 60000, and one root user (uid 0) and 999 system users (uid 1 to
999)).
groupadd
groupmod
=== * ===
Operating System and Administration - 20CS42P - 72 -
Department of Computer Science and Engineering
Example:
add the user to group:
o gpasswd -a existinguser existinggroup
Deleting the created user from group geeks.
o gpasswd -d existinguser existinggroup
=== * ===
groupdel
groupdel command is used to delete a existing group.
It will delete all entry that refers to the group, modifies the system account files, and it is
handled by superuser or root user.
Syntax: groupdel existinggroup
=== * ===
Test LDAP connection with ldapwhoami, which should return the username as:
ldapwhoami -H ldap:// -x
Output
o anonymous
o anonymous is the result expected, since running ldapwhoami without logging in
to the LDAP server. This means the server is running and answering queries.
WEEK
Work 11 Session
on Practice
Top command is a performance monitoring program that can display CPU usage, memory usage, swap
memory, cache size, buffer size, process PID, users, commands, etc. The top command is used to
display all running and active real-time processes in an ordered list and update them regularly. It can
also sort the processes of running processes according to memory or CPU utilization.
The top command is useful for system administrators to monitor and take corrective measures when
needed top
The output displays the summary area (the dashboard with resource usage stats) and the task area (a list
of all processes).
3. iostat
The iostat command in Linux lets you monitor CPU utilization and I/O (input/output) statistics of all the
disks and file systems.
iostat commands are useful for changing system configuration to better balance the i/o load between
physical disks
cat /proc/cpuinfo
To see what type of processor/CPU your computer system has, use this Linux command:
$ cat /proc/cpuinfo
Cat /proc/meminfo
The ‘/proc/meminfo‘ is used by to report the amount of free and used memory (both physical and
swap) on the system as well as the shared memory and buffers used by the kernel.
free
free command which displays the total amount of free space available along with the amount of
memory used and swap memory in the system, and also the buffers used by the kernel.
df
To know amount of space consumed by a particular file system on your LINUX system or how much
space is available on a particular file system.
df command that displays the amount of disk space available on the file system containing each file
name argument
Suppose you have a file named kt.txt and you want to know the used disk space on the file system that contains this file
then you can use df in this case as:
// using df for a specific file //
$df kt.txt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/the2 1957124 1512 1955612 1% /snap/core
dmesg command, shorthand for “diagnostic message”, is a Linux utility for displaying the messages
that flow within the kernel ring buffer. A kernel ring buffer is a logging mechanism from the system
startup which comes into play for diagnostics of a failed device.
Shutdown
The shutdown command in Linux is used to shutdown the system in a safe way. You can shutdown
the machine immediately, or schedule a shutdown using 24 hour format.It brings the system down in a
secure way. When the shutdown is initiated, all logged-in users and processes are notified that the
system is going down, and no further logins are allowed.
Only root user can execute shutdown command.
Syntax of shutdown Command
shutdown [OPTIONS] [TIME] [MESSAGE]
$shutdown now
All Ubuntu system logs are stored in the /var/log directory. Change into this directory in the terminal
using the command below:
$cd /var/log
You can view the contents of this directory by issuing the following command:
$ls /var/log
Essential system log files that may be present in the /var/log directory and what they contain:
/var/log/syslog: stores general information about any global activity in the system.
/var/log/auth.log: keeps track of all security-related actions (login, logout, or root user activity).
/var/log/kern.log: stores information about events originating from the Linux kernel.
/var/log/boot.log: stores system startup messages.
/var/log/dmesg: contains messages related to device drivers.
/var/log/faillog: keeps track of failed logins, which comes in handy when investigating attempted
security breaches.
init is parent of all Linux processes with PID or process ID of 1. It is the first process
to start when a computer boots up and runs until the system shuts down. init stands
for initialization
What is YUM?
YUM (Yellowdog Updater Modified) is an open-source command-line as well as
graphical-based package management tool for RPM (RedHat Package Manager)
based Linux systems.
It allows users and system administrators to easily install, update, remove or search
software packages on a system
Operations of YUM
YUM can implement operations like:
Week
Work on 12 – Session
Practice
Domain Name Service (DNS) is an internet service that maps IP addresses to fully
qualified domain names (FQDN) and vice versa.
• BIND stands for Berkley Internet Naming Daemon.
• BIND is the most common program used for maintaining a name server on Linux. •
1. Network Information
2. Install Bind
3. Configure Cache NameServer
4. Test the Cache NameServer
5. Configure Primary/Master Nameserver
6. Build the Forward & Reverse Resolution for Primary/Master NameServer
7. Test the DNS server
ftp
ftp is the user interface to the Internet standard File Transfer Protocol. The program allows a
user to transfer files to and from a remote network site.
Examples below are to upload and download files using ftp service.
Prerequisites:
Install Ftp (FTP-Client) and vsftpd (FTP-Server) using Software Manager.
Change /etc/vsftpd.conf file to enable write permission (other settings can be done
according to requirement.
◦ nano /etc/vsftpd.conf
Search for # write_enable=YES (around 30th line in that file)
Uncommnent and Save and Exit
Restart the Service: systemctl restart vsftpd
command.
Work on Practice Session
Example 2: Download the file from ftp server
get a.txt /home/admincs/Desktop/test.txt
o will download the file a.txt from ftp server to current user Desktop with file
name test.txt
After letting the command run, all required packages are installed and we can test it out by
typing in our IP address for the web server.
After letting the command run, all required packages are installed and we can test it out by
typing in our IP address for the web server.
If you see the page above, it means that Apache has been successfully installed on your server
To change default page from from normal page to custom page create html
file in /etc/var/html/test.html
Operating System and Administration - 20CS42P - 84 -
Department of Computer Science and Engineering
We can modify how Apache handles incoming requests and have multiple sites running on the same
server by editing its Virtual Hosts file.
Today, we’re going to leave the default Apache virtual host configuration pointing
to www.example.com and set up our own at gci.example.com.
So let’s start by creating a folder for our new website in /var/www/ by running
Now that we have a directory created for our site, lets have an HTML file in it. Let’s go into our newly
created directory and create one by typing:
cd /var/www/gci/
nano index.html
Paste the following code in the index.html file:
<html>
<head>
<title> Ubuntu rocks! </title>
</head>
<body>
Operating System and Administration - 20CS42P - 85 -
Department of Computer Science and Engineering
cd /etc/apache2/sites-available/
Since Apache came with a default VirtualHost file, let’s use that as a base. (gci.conf is used here to
match our subdomain name):
ServerAdmin yourname@example.com
We also want the DocumentRoot directive to point to the directory our site files are hosted on:
DocumentRoot /var/www/gci/
The default file doesn’t come with a ServerName directive so we’ll have to add and define it by adding
this line below the last directive:
ServerName gci.example.com
This ensures people reach the right site instead of the default one when they type
in gci.example.com.
Now that we’re done configuring our site, let’s save and activate it in the next step!
Now is the moment of truth, let’s type our host name in browser. Hooray!
13 – Storage Management
o So if user need to see the details of a particular disk, then pass the device name to
cfdisk. Work on Practice Session
o sudocfdisk /dev/sdb
parted
partedutility is to list out partitions and modify them if needed.
o sudo parted -l
df
df is not a partitioning utility, but prints out details about only mounted file systems.
The list generated by df even includes file systems that are not real disk partitions.
o df -h
o df -h | grep ^/dev
Note:df shows only the mounted file systems or partitions and not all.
Installation command