You are on page 1of 17

Lab Manual for Operating System

(BCSF19M025-LAB3)

Windows Commands:
Attrib command:
Attrib command is used to display, set or remove assigned attributes of files or directories. If used
without any parameters it displays the current attributes of the files of the current directory.

The general syntax of the command is:


attrib [{+|-}r] [{+|-}a] [{+|-}s] [{+|-}h] [{+|-}i] [<drive>:][<path>]
[<filename>] [/s [/d] [/l]]

+ive sign sets the attribute while -ive sign clears the attribute. r, a, s, h and i are attributes.

Let’s apply a attribute to file2.txt in the above files. Execute the following command:
attrib +r file2.txt

To remove the attribute use -ive sign with the same attribute and it will remove it.
attrib -r file2.txt

Parameters and their uses:


 r Parameter: r is used for read-only file attribute.
 a Parameter: a is used for achieve file attribute. This attribute set marks files that have
changed since the last time they were backed up.
 s Parameter: s is used for System file attribute. If this attribute is set, you must clear it
before you can change other attributes.
 h Parameter: h is used for hidden file attribute. If this attribute is set, you must clear it
before you can change other attributes.
Note: If either h or s attribute is set changing any other attribute will generate an error.

 /s Parameter: Applies attrib and any parameter to matching files in the current directory
and all of its subdirectories.
 /d Parameter: Applies attrib to directories.
 /l Parameter: Applies attrib to the Symbolic Link, rather than the target of the Symbolic Link.

Chdir Command:
Displays the name or changes of current directory. If used with a drive letter, chdir displays the name
of current directory in the specified drive. Without any parameters it displays the name of current
directory in current drive.

If given a path chdir changes the current directory of the drive.

Color Command:
Changes the foreground and the background color of windows command prompt for the current
session. If used without any parameter, it restores the default color of the command prompt.

The general syntax of the command is:


color [[<b>]<f>]

The first character is for the color of the background and the second character is for the color of
foreground text.
Below are some character values for the colors.

Values Color
0 Black
1 Blue
2 Green
3 Aqua
4 Red
5 Purple
6 Yellow
7 White
8 Gray
9 Light Blue
A Light Green
B Light Aqua
C Light Red
D Light Purple
E Light Yellow
F Bright White

Using the following command Yellow is set as a background color and blue is set as foreground color:

To return to default state just use color without any parameter:

Exit Command:
This command is used to exit the command interpreter/prompt.

The syntax is following:


exit [/b] [<exitcode>]

Find Command:
This command is used to search for a string of text in a file or files and display lines of text that
contain the specified string.

The general syntax of the command is:


find [/v] [/c] [/n] [/i] [/off[line]] <"string"> [[<drive>:]
[<path>]<filename>[...]]

Let’s consider 2 files [“file1.txt” and “file2.txt”] inside a folder named os. Let’s find if there is pucit
word in file1.txt.
As you can see, it prints out the lines with pucit in file1.txt by default.

Parameters and their uses:


 /v Parameter: is used to display all the lines that don’t contain the specified string.
 /c Parameter: counts the number of lines that contain the specified string.
 /n Parameter: Precedes each line with the number of that line in the file.
 /i Parameter: It specifies that the search is not case sensitive.

These parameters can be used individually or in combinations. For example:

To find the number of lines that don’t contain the specified string “pucit” in file1.txt.

Some Useful Information:


 If you omit the filename, this command takes input from the standard input source (usually
the keyboard, a pipe (|), or a redirected file) and then displays any lines that contain string.
 This command doesn't recognize carriage returns.
 You cannot use wildcards in the search string.
Help Command:
Help commands displays a list of all the available commands or detailed help information on the
specified command. If used without any parameters, it lists and briefly describes all system
commands.

Or you can type the name of command after help to get help about a certain command. Figure
below provides a detailed description of the exit command.
Help | more Command:
Using a pipe help command’s output is redirected to the more command which limits the output of
the help command to Command prompt page length.

You can press enter to display the next line of the help command’s output or press Ctrl + C to exit.

mklink Command:
This command creates a symbolic or hard link of a directory or file.

Hard Link: Hard links point, or reference, to a specific space on the hard drive. If a file/directory has
two hard links, even if one hard link is deleted the file/directory can still be accessed by the other
hard link.

Soft Link: A symbolic link, also termed a soft link or symlink, is a special kind of file that points to
another file. It is like a shortcut in Windows. If the hard Link or the original file is deleted, soft link
will not work as it points to the file not the memory.
Consider the structure as follows:

By using the mklink command a soft link is created inside folder1 for file1.txt.

Parameters and their uses:


 /d Parameter: Creates a directory link. By default, this command creates a symbolic link.
 /h Parameter: Creates a hard link instead of soft link.
Sort Command:
This command is used to Reads input, sorts data, and writes the results to the screen, to a file, or to
another device.

The general Syntax is:


sort [/r] [/+<N>] [/m <kilobytes>] [/l <locale>] [/rec <characters>]
[[<drive1>:][<path1>]<filename1>] [/t [<drive2>:][<path2>]] [/o [<drive3>:]
[<path3>]<filename3>]

Consider the following file with names, it can be sorted Alphabetically using the sort command.

Parameters and their uses:


 /r Parameter: It sorts in the reverse order (That is, sorts from Z to A and from 9 to 0)
 /+<N> Parameter: Specifies the character position where the sorting will begin in each
comparison.
 /m Parameter: Specifies the amount of Main Memory (RAM) to use for sorting in kilobytes.
 /rec Parameter: Specifies the maximum number of characters in a record or a line of the
input file (the default value is 4,096 and the maximum is 65,535).
 /t Parameter: Specifies the path of the directory to hold the sort command’s working
storage if the main memory is not enough to fit the entire data. By default, the system
temporary directory is used.
 /o Parameter: Specifies the file where the sorted input will be stored. If not specified the
data is printed to standard output.
 /unique: Only returns the unique results.

Some Examples:
Linux Commands:
ls Command:
It's used to display a list of files and sub-directories in the current directory.

Flags and their uses:


 -a Flag: Do not ignore entries starting with ".", providing visibility to hidden files (those
starting with a ".")
Ls in same directory as above but with -a Flag.

 -l flag: Use a long listing format.


First 10 characters in the output represent permissions, the number next to them represents
hard links, next is the file owner, followed by group to whom the file belongs, the size of the
file in blocks, the date and time of when the file was last modified and the file name.
Concept of Root directory:
Root directory in any operating system is the one containing all the folders, data, files, directories,
and subdirectories. The root directory is mixed up with the home directory by beginners and
consider them the same. Root directory is the uppermost directory in the system whereas the home
directory comes under the branch of root directory. In the file hierarchy, root directory is the
uppermost directory represented and accessible by slash (/). All other directories, hard drives, USBs
drivers etc., are located in this root directory.

Whoami Command:
The whoami command is a compound of the words “Who am I?” and prints the name of the user
associated with the current effective user ID. In other words, it displays the name of the currently
logged-in user.

pwd Command:
This command is used to display the present working directory. It prints the path starting from the
root to the present working directory.

List of system folders:


Some of the directories in the root with their purpose are briefly explained below:

 Bin directory: Bin folder contains the programs essential for the system to boot and run. It
stores the binary executables of programs.
 /dev directory: All devices such as USB, disks, cpu etc., are contained by this directory.
 /home directory: This directory contains home directories of each regular users on the linux
operating system.
 /lib directory: This directory contains libraries required by programs in /bin.
 /opt directory: This directory contains optional software such as dropbox, clion etc.
 /proc Directory: This directory contains information and data of processes in the system.
Everything in linux is a file, even processes.
 /root directory: This directory is home for the root user. Do not mix it with the root
directory which is (/).
 /usr directory: This directory contains programs and libraries used by a regular user.
Paths and Wild cards Revisited
Paths:
A path in Linux is same as a real-life path. Path is a way to reach some location. This location can be a
folder/file or a city.

There are two basic types of paths: relative paths and absolute paths. A relative path is the location
of a file/directory relative to the current directory. The current directory is the directory in which the
user is currently working. While absolute path is the location of a file/directory relative to root
directory.

Wildcards:
Wildcards or wildcard character is a symbol used to replace or represent one or more characters.
The most common wildcards are the asterisk (*), which represents one or more characters, and
question mark (?), which represents a single character. They can be used in a number of ways on
terminal.

mkdir Command:
mkdir command is used to create a directory.

cd Command:
cd command also known as change directory command is used to change directory in command-line
shell.

Cat Command:
Cat command is used to print the content of a file to the standard output stream.

When used without any parameter it takes input from standard input and outputs it to standard
output.
Virtual box installation
1. Click on the Add button

2. Add the iso image of ubuntu and change the folder if you want.

3. Provide username and the password


4. Enter the Amount of RAM you want to allot to the virtual machine and select how many
processors it can use.
Note: Recommended RAM is at least 1GB and Select half of your processors.

5. Create a new virtual hard disk and allot minimum of 15GB, you can allot higher Disk Space if
you want.

6. Finish the Creation process of the ubuntu virtual machine.


7. Ubuntu will self-install afterwards.
Dual Boot Installation:
Prerequisites:
You should have a copy of ubuntu and rufus.

Process:
1. Type Disk Management in search and open this or press Ctrl + X and select Disk
Management.

2. Select any volume you have space available and shrink it. Select a volume that has extra
space that you don’t require.

3. Enter how much you want to shrink the volume in MBs. Remember this space will become
unusable for windows until you have ubuntu installed. So, select carefully.
Note: Recommended minimum size for installation is at least 25-30GB.
4. Now, open rufus, select your USB device, the ISO file of ubuntu you downloaded earlier and
start the process.

5. Once finished, restart your laptop/Computer with the USB plugged in, open boot menu using
one of the function keys as displayed on the screen (These are different for different devices
but usually F11 or F12) to boot from USB.
6. Once you have booted through the USB, you’ll be presented with this menu. Click install
ubuntu.

7. After that select your Language and keyboard layout.


8. Then you will be presented with the following screen. Select “Normal installation”, check
install third-party software for graphics and wifi.

9. Choose “Something else” option from the menu


10. After that you’ll be presented the following screen. Select the free space here and click the
“+” symbol.

11. The following popup will appear. Use all free space in size and choose mount point as “/”
and click ok.
12. After this select the newly created ext4 partition and click Install Now. The selected partition
will be colored after you click on the partition.
Note: There are several ways of installing ubuntu. We will be following the easiest one.
DO NOT CHANGE THE “DEVICE FOR BOOT LOADER INSTALLATION:”

13. Select your country and press continue, the installation will begin.

Disclaimer:
When uninstalling ubuntu you must find an online guide. Deleting ubuntu partition might lead to
grub issues.

You might also like