Os Practical
Os Practical
INTERNAL COMMAND
1. CLS:- (Clear the screen) This command is used to clear the screen or wipe out
every thing written on the screen.
Syntax:- C:\> CLS and press Enter
2. DIR:- (Directory) Dir command is used for listing files and directories present in
the current disk.
Syntax:- C:\> DIR [/switches]
Example:- C:\> DIR /P
/P Page wise
/W Widths wise
/S List all files and directory of subdirectories
/AH Display directory with hidden files
/AS Display directory with system files
/AD Display only directories present in current drive
3. VER:-(Version) Version numbers indicates that which edition of DOS we are
working on.
Syntax:- C:\> VER press enter
4. VOL:-(Volume) Displays the disk volume label and serial number, if it exist.
Syntax:- C:\> VOL press enter
After copy con we must specify a suitable file name. Press enter. Start typing the
informations of the file. After gathering the information we press ^Z (CTRL+Z)
button or F6 button to save the file. After pressing enter key computer will show a
message like 1 file(s) copied. This means that file is stored in the disk. Suppose
we don't want to save the file or we just want to abort from file creation job, then
we simply press ^C (CTRL+C) button to abort without saving the file, intend of
pressing ^Z button.
8. TYPE:- This command is used to display the contents or text of any file to the
display device.
Syntax:- C:\> TYPE <Filename>
A:\>TYPE GULAB.TXT
A clock in a office can never get stolen
Too many employees watch it all the time
9. COPY :- Copy command is used for copy any file to another location or to copy
the files to another directory. This command may also be used for copying any file
to another disk with different file name.
Syntax:- C:\> COPY <Source filename> <Target file name>
C:\>COPY ROSE.TXT ROSE.MSG
1 file(s) copied
15. PATH:- This command is used for display or sets directories for executable
files.
Synatx:- C:\> PATH
This command display current path settings.
C:\> PATH=C:\WINDOWS\COMMAND;C:\WINDOWS\;C:\TC
this command will sets the directories windows, the command subfolder of
windows and TC folder for executable files. Operating system will look for
executable files in these directories.
External commands
1. MORE:-Using TYPE command we can see the content of any file. But if length of
file is greater than 25 lines then remaining lines will scroll up. To overcome
through this problem we uses MORE command. Using this command we can
pause the display after each 25 lines.
Syntax:- C:\> TYPE <File name> | MORE
C:\> TYPE ROSE.TXT | MORE
or
C:\> DIR | MORE
2. MEM:-This command displays free and used amount of memory in the
computer.
Syntax:- C:\> MEM
the computer will display the amount of memory.
3. SYS:- This command is used for copy system files to any disk. The disk having
system files are known as Bootable Disk, which are used for booting the computer.
Syntax:- C:\> SYS [Drive name]
C:\> SYS A:
System files transferred
This command will transfer the three main system files COMMAND.COM, IO.SYS,
MSDOS.SYS to the floppy disk.
4. XCOPY:- When we need to copy a directory instant of a file from one location to
another the we uses xcopy command. This command is much faster than copy
command.
Syntax:- C:\> XCOPY < Source dirname > <Target dirname>
C:\> XCOPY TC TURBOC
5. MOVE:- Move command is used for moving one file or multiple files from one
location to another location or from one disk to another disk.
Syntax:- C:\> MOVE <file name> <path name>
C:\SONGS> MOVE *.MP3 C:\ SONGS\OLD SONGS\
C:\>
6. FC:-(File Compare) This command is capable for comparing two set of files and
display difference between two files.
Syntax:- C:\> FC <First set of file> <Second set of file>
C:\> FC ROSE.TXT GULAB.TXT
7.CHKDSK:-(Check disk) - This command is used to check the status of a disk and
show the report of result status.
Syntax:- C:\> CHKDSK
C:\>CHKDSK
13. DOSKEY:- Once we install doskey , our dos will star to memorize all
commands we uses. We can recall those commands using up or down arrow
keys. It also gives the facility to create macros, which creates a short key for long
keyword or command.
Key function for Doskey are given as-
UP,DOWN arrows recall commands
Esc clears current command
F7 displays command history
Alt+F7 clears command history
selects a command by
F9 number
Alt+F10 clears macro definitions
Syntax:- C:\> DOSKEY
DOSKey installed
Creating Macros:-
C:\>doskey t=time
C:\>t
C:\>time
Current time is 3:39:05.97p
Enter new time:
To list out all macros defined just type DOSKEY/MACROS at dos prompt and
press enter.
C:\>DOSKEY/MACROS
$D=date
T=time
14. FORMAT:- This command creates new Track & Sectors in a disk. Every
Syntax:- C:\> FORMAT [drive name] [/S]
C:\> FORMAT A:
this command will create new track & sectors.
C:\> FORMAT A: /S
This command will transfer system files after formatting the disk.
LINUX COMMANDS
Linux Directory Commands
1. pwd Command
The pwd command is used to display the location of the current working directory.
Syntax:
1. pwd
Output:
2. mkdir Command
The mkdir command is used to create a new directory under any directory.
Syntax:
1. mkdir <directory name>
Output:
3. rmdir Command
The rmdir command is used to delete a directory.
Syntax:
1. rmdir <directory name>
Output:
4. ls Command
The ls command is used to display a list of content of a directory.
Syntax:
1. ls
Output:
5. cd Command
The cd command is used to change the current directory.
Syntax:
1. cd <directory name>
Output:
8. rm Command
The rm command is used to remove a file.
Syntax:
rm <file name>
Output:
9. cp Command
The cp command is used to copy a file or directory.
Syntax:
To copy in the same directory:
1. cp <existing file name> <new file name>
To copy in a different directory:
Output:
10. mv Command
The mv command is used to move a file or a directory form one location to another
location.
Syntax:
1. mv <file name> <directory path>
Output:
grep Command
The grep is the most powerful and used filter in a Linux system. The 'grep' stands for
"global regular expression print." It is useful for searching the content from a file.
Generally, it is used with the pipe.
Syntax-grep [options] pattern [files]
Output:
Case insensitive search
Output:
3. Display the File Names that Matches the Pattern Using grep
We can just display the files that contains the given string/pattern.
grep -l "unix" *
or
grep -l "unix" f1.txt f2.txt f3.xt f4.txt
Output:
Output:
checking whole words in a file
Output:
Output:
sed command
The sed command is also known as stream editor. It is used to edit files using a regular
expression. It does not permanently edit files; instead, the edited content remains only
on display. It does not affect the actual file.
Syntax:
command | sed 's/<oldWord>/<newWord>/'
Output:
find Command-The find command is used to find a particular file within a directory. It
also supports various options to find a file such as byname, by type, by date, and more.
The following symbols are used after the find command:
(.) : For current directory name
(/) : For root
Syntax:
find . -name "*.pdf"