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

Operating System Lab 5

Operating system lab 5

Uploaded by

Babar Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Operating System Lab 5

Operating system lab 5

Uploaded by

Babar Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

OPERATING

SYSTEM LAB MANUAL


INSTRUCTOR NAME: ANEES ASGHAR

2021
LAB 05
LINUX OPERATING SYSTEM
System Information Commands

Lab objective:
 This lab introduces few of the system information commands of
Linux.
 Also, man command, info command and command –help.

Df command:

The df command displays file system disk space usage for all mounted
partitions.

Df –h command:
"df -h" is probably the most useful - it uses megabytes (M) and gigabytes
(G) instead of blocks to report. (-h means "human-readable").
Du Command:
The du command displays the disk usage for a directory. It can either
display the space used for all subdirectories or the total for the directory
you run it on. Example:

In the below example we checked the directory usage for f directory.


For example:
Suppose you want to check the disk usage for a directory xampp which is
present in c directory. Then use the command du –sh /mnt/c/xampp.

In the above example -s means "Summary" and -h means "Human


Readable".
In the above diagram we didn’t use –sh in the command. Instead we use
du /mnt/c/xampp, so it provides all the details about the sub directories of
the xampp directory as well.
Free command:
The free command displays the amount of free and used memory in the
system. "free -m" will give the information using megabytes, which is
probably most useful for current computers.

echo
The "echo" command helps us move some data, usually text into a file.
For example, if you want to create a new text file or add to an already
made text file, you just need to type in, echo “hello, my name is xyz” >>
new.txt. You do not need to separate the spaces by using the backward
slash here, because we put in two triangular brackets when we finish what
we need to write.
Top ('table of processes') command:
The top ('table of processes') command displays information on your
Linux system, running processes and system resources, including CPU,
RAM & swap usage and total number of tasks being run. To exit top,
press "q".
htop command in Linux system is a command line utility that allows the
user to interactively monitor the system's vital resources or server's
processes in real time. htop is a newer program compared to top
command, and it offers many improvements over top command.

uname -a:
The uname command with the -a option prints all system information,
including machine name, kernel name & version, and a few other details.
Most useful for checking which kernel you're using.
Options
The default behavior for a command may usually be modified by adding
a --option to the command.
 The ls command for example has an -s option so that "ls -s" will
include file sizes in the listing.

 There is also a -h option to get those sizes in a "human readable"


format.

 Options can be grouped in clusters so "ls -sh" is exactly the same


command as "ls -s -h".
 Most options have a long version, prefixed with two dashes instead
of one, so even "ls --size --human-readable" is the same
command.

"Man" and getting help


 man command, info command and command --help are the most
important tools at the command line.
 Nearly every command and application in Linux will have a man
(manual) file, so finding them is as simple as typing "man
"command"" to bring up a longer manual entry for the specified
command.
 For example, "man mv" will bring up the mv (move) manual.
Move up and down the man file with the arrow keys, and quit back
to the command prompt with "q".
 "man man" will bring up the manual entry for the man command,
which is a good place to start! "man intro" is especially useful - it
displays the "Introduction to user commands" which is a well-
written, fairly brief introduction to the Linux command line.
 There are also info pages, which are generally more in-depth
than man pages. Try "info info" for the introduction to info pages.
 Some software developers prefer info to man (for instance, GNU
developers), so if you find a very widely used command or app that
doesn't have a man page, it's worth checking for an info page.
 Virtually all commands understand the -h (or --help) option which
will produce a short usage description of the command and it's
options, then exit back to the command prompt. Try "man -
h" or "man --help" to see this in action.
Note: It's possible (but rare) that a program doesn't understand the -h
option to mean help. For this reason, check for a man or info page first,
and try the long option --help before -h.
Some important short keys:

Ctrl+ L Clear the Screen


Ctrl+ D Exit or return back to the prompt shell.
Ctrl + A Moves the cursor to the start of a line.
Ctrl+ E Moves the cursor to the end of a line.
Esc + B Moves to the beginning of the previous or current word.
Deletes from the current cursor position to the end of the
Ctrl + K line.
Deletes from the start of the line to the current cursor
Ctrl + U position.
Ctrl + W Deletes the word before the cursor.
Alt + B Goes back one word at a time.
Alt + F Moves forward one word at a time.
Capitalizes letter where cursor is and moves to end of
Alt + C word.

nano, vi, jed


nano and vi are already installed text editors in the Linux command line.
The nano command is a good text editor that denotes keywords with color
and can recognize most languages. And vi is simpler than nano. You can
create a new file or modify a file using this editor. For example, if you
need to make a new file named "check.txt", you can create it by using the
command “nano check.txt”. You can save your files after editing by using
the sequence Ctrl+X, then Y (or N for no). jed text editor is recommended
for HTML editing.

apt-get
Use apt to work with packages in the Linux command line. Use apt-get to
install packages. This requires root privileges, so use the sudo command
with it. For example, if you want to install the text editor jed, we can type
in the command “sudo apt-get install jed”. Similarly, any packages can be
installed like this. It is good to update your repository each time you try
to install a new package. You can do that by typing “sudo apt-get update”.
You can upgrade the system by typing “sudo apt-get upgrade”. We can
also upgrade the distro by typing “sudo apt-get dist-upgrade”. The
command “apt-cache search” is used to search for a package. If you want
to search for one, you can type in “apt-cache search jed”.

You might also like