Uploaded by Islamic Status

Lab 1

advertisement
Operating System Lab #1
Introduction to Command Line Interface
Basic terminologies
Software
Software is a term that refers to the written instructions or programs that control the
operations of computer. Informally, software refers to the programs, application
packages (Word processor, Spread Sheets, DBMS, etc.) written for computer.
Software may be classified into two major categories.
i)
ii)
Application Software
System Software
i) Application Software
Application software is a generic term used for such types of software, which are used to
solve a problem. The problem to solve is user specific. Word processors, computer
games, database managers etc. are specific types of application of software.
ii) System Software
System Software are programs which are designed to operate, control, and extend the
processing capabilities of the computer itself, e.g. operating systems, compilers, linkers
etc.
Operating System
Operating System is a type of System Software and is a collection (set) of programs,
which performs two specific functions. First, it provides a user interface so that human
user can interact with the machine. Second, the operating system manages computer
resources.
Files
File is a mechanism through which we store information. Normally, there are two modes
of storing information.
i)
File
ii)
Directories
i) File
A simple file stores some type of information. The information it has may be in text
format, or in binary format.
ii) Directories
Directories are special types of files owned the operating system, which contains
information about files, and may contain other directories (called Subdirectories). So
directories are also files, which contains some vital information about the files, and
other directories.
There’s a file (management) system in operating system, which manipulates file and
directories. The major operations, which can be performed on files and directories, are
given below:











Create
Delete
Open
Close
Read
Write
Append
Seek
Rename
Get Attributes
Set Attributes
File Attributes
Since file contains some information about something, there’s needed some information
about the file itself. This information about the file is called file attributes.
All operating system associate some extra information with each file, for example date
and time of the file created, file size etc. These items are called file attributes. Some of
file attributes are given below:




File Name
File type For example text, binary, etc.
Creator
Owner Current owner





Date created
Date last read access
Date last modified
Current size Number of bytes in the file
Maximum size Maximum size file may grow to.
Lab Tasks
Open DOS CLI
Task 1: Open cmd
Press Windows key + r and type cmd.
OR
"Start" button ⇒ All Programs ⇒ Accessories ⇒ Command Prompt
Basic Dos Commands
1) Set Current Drive (x:) Command
• To set or change the current drive, enter the drive letter followed by a colon (:), e.g.,
• Prompt> d: // Change the current drive to D.
• Example
C:\> d:
D:\>
Task2: Make D drive as current working drive
2)- cd, cd.. and dir Command
– cd..
• Will return you to previous directory
• Example:
C:\user> Cd..
C:\>
– dir
•
•
Get the list of all files and folder within the directory
Example:
C:\user>dir
– cd directoryName (change directory)
• Allow you to change and switch between directories
•
Example:
C:\>cd user
C:\user>
Task 3: Reach desktop directory using cd, cd.. and dir command
3)- md and rd Command
;
– MD
Syntax: md/mkdir directoryName
• To create new directory
• Example:
C:\ user\desktop>md username
C:\user\desktop\username>
– RD
Syantax: rd directoryName
• To remove a directory
• Example:
C:\user\desktop\username> cd ..
C:\user\desktop>
C:\user\desktop> rd username
C:\user\desktop> dir
Task 4: create and remove a directory on desktop with your name.
4)- Copy Move Del Command
– Copy
– Syntax: copy filename directoryName/destinationPath
• To a file from current directory to new location
• Example:
C:\user\desktop>copy username.txt C:\user\desktop\username
C:\user\desktop>dir
C:\user\desktop\username> dir
– Move
Syntax: move filename directoryName/destinationPath
• To move file from current location to new location
• Example:
C:\user\desktop\Move> username.txt C:\user\desktop\newusername
C:\user\desktop> dir
C:\user\desktop\newusername>dir
– Del
Syntax: del filename
• To delete file
• Example:
C:\user\desktop\username> del username.txt
C:\user\desktop\username> dir
Task 5: Use copy command to copy text file from C drive to desktop (keeping desktop as
your current working directory)
Task 6: Use move command to move text file from C drive to desktop (keeping desktop as
your current working directory)
Task 7: Del text file from a directory
Task 8: Execute following command
1) Cls
2) Date
3) Help
4) Tree
5) Time
Relative and Absolute path
Current/Working Directory
The directory currently being used.
Pathname
Pathname is a reference to identify a file within the directory structure.
For example the following file name indicates the file in the hierarchy of directories:
/usr/users/bill/letters/pay
The first slash (/) indicates the root directory (start from root directory), move down to
usr, then users, then bill, then letters and finally to the file. So this pathname is
reference to the file pay with respect to the root directory.
Identify drive, root directory, path amd file from following :
C:\users\stu\desktop\file.txt
Drive:
“C:”
Root directory :
“\”
Path:
“users\stu\desktop\”
File:
“file.txt”
Type null > hello.txt
Del hello.txt
Type the following command to hide a folder or file and press Enter:
attrib +h "Ihsan.txt"
Type the following command to hide all files and folders inside the hidden
folder and press Enter:
attrib +h /s /d
Type the following command to make the items visible again and press Enter:
attrib -h "Secret Files"
Type the following command to remove the hidden attribute from all files and
folders inside the folder and press Enter:
attrib -h /s /d
start excel
A path may be of two types.
Absolute Pathname
The pathname, which identifies a file or a directory irrespective of the current state of
the user. The user's "current directory" is part of the user's state. The absolute pathname
always starts from the root directory.
For example, to locate file any file in lib directory, the absolute path of the file is:
/usr/local/lib/filename
Relative pathname
The pathname, which identifies a file or a directory in a way that depends on the state of
the user i.e. users current directory. Relative pathname identifies files with respect to
user current directory.
Consider the following diagram.
Current Directory (Working Directory)
thesis
chapter4.tex
to refer a file chapter4.tex in the in the subdirectory thesis with respect to the
current directory, we use pathname.
thesis/chepter4.tex
Task 9: Repeat Copy command with both relative and absolute path
Task 10: Repeat Move command with both relative and absolute path
Related documents
Download