Practical 4- DOS and LINUX Basic Commands
Practical 4- DOS and LINUX Basic Commands
CLS COMMAND
This is an Internal dos command which is used to clear the output on the screen obtained when
executing any basic dos commands.
These commands clear all the text from the screen and show the user a Command prompt.
(Syntax)
C:\>cls (Press Enter)
DATE COMMAND
The date command is an internal basic dos command which is used to display or change the
current date of the system in the format of mm/dd/yy.
(Syntax)
C:\>date (Press Enter)
TIME COMMAND
The time command is used to display or change the current time of the Computer system.
The format which is used by the time command is HH:MM: SS::CC. Where HH stands for
hours of the day in 24-hour format, MM for minutes, SS For seconds, and CC For hundreds of
a second.
(Syntax)
C:\> Time (Press Enter)
To save the file use CTRL+Z OR F6 OR to cancel use CTRL+C from the keyboard.
TYPE COMMAND
Type command is used to view the content of the file.
(Syntax)
C:\>type abc.com (Press Enter)
Everybody wants to go to heaven but nobody wants to die.
If the content of the file is large and cannot be entirely viewed on the display device use the
following MS Dos command.
(Syntax)
C:\> type abc.com |more (Press Enter)
RENAME COMMAND
This Basic Dos Command is used for renaming an existing file or directory.
(Syntax)
C:\>Ren (old file name) (new file name) (Press Enter)
For Example, you have a file name abc.com and want to change the file name to computer.xyz.
Use the below command.
C:\>Ren abc.com computer.xyx(Press Enter)
Ok now if you need to change the name and extension of files in a group. you need to use
wildcards as given below
C:\>Ren *.com *.abc (Press Enter)
Here all the .com extension files will be renamed to .abc
COPY
Copy is a Basic internal dos command which is used to copy files from one location to another.
While using copy command you have to specify the path or address of the file and the location
where you
need to copy that file.
Do not forget to mention the address of the file and the destination where you need to copy it.
(Syntax)
C:\> Copy d:\abc.com E: (Press Enter)
Using wild cards you can copy each and every file present in a directory for example if you
need to copy files that are present in d:\songs to e:\newsongs use the following command.
C:\Copy D:\songs\*.* E:\newsongs (Press Enter)
You can use the switches present in the copy command to know the various switches using the
below mentioned MS-Dos command.
C:\>copy/? (Press Enter)
The Various Switches are
Source:: specifies the file and files to be copied
• /A:: Indicates an ASCII text file
• /B:: Indicates a Binary file Destination:: Specifies the directory and /or filename for the new
file.
• /V:: Verifies that new files are written correctly
• /Y:: Suppresses prompting to confirm you want to overwrite an existing destination file.
• /-Y:: Causes prompting to confirm you want to overwrite an existing destination file.
DELETE
Del is a Basic internal dos command which is used to delete the specifically mentioned files.
(Syntax)
C:\del abc.com (Press Enter)
To delete files in a group use wild cards.
C:\>del * .abc (Press Enter)
In the above command, all the files which have an extension .abc will be deleted.
DIR COMMAND
DIR Command Is used to display all the files and directories along with the filename, extension,
creation date, and modified date.
(Syntax)
C:\>Dir (Press Enter)
Switches Used in DIR Command
• /P:: uses to display the result in page-wise format c:\dir/p
• /W:: It Displays the result in widthwise format c:\dir/w
• /A:: is used to display files or directories with specific Attributes
• /O:: It is used to display a list in sorted order
MD COMMAND
MD or MKDIR command is an internal dos command which is used to create directories and
subdirectories.
(Syntax)
C:\>md (directory name) (Press Enter)
For example, if you need to create a directory named movies follow the below dos command.
C:\> MD movies (Press Enter)
CD.. COMMAND
CD.. command is used to change the directory from parent to child.
For Example:
C:\movies>cd.. (Press Enter)
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:
Linux File commands
6. touch Command
The touch command is used to create empty files. We can create multiple empty files by
executing it once.
Syntax:
1. touch <file name>
2. touch <file1> <file2> ....
Output:
7. cat Command
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file,
display content of the file, copy the content of one file to another file, and more.
Syntax:
1. cat [OPTION]... [FILE]..
To create a file, execute it as follows:
1. cat > <file name>
2. // Enter file content
Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as follows:
1. cat <file 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:
After pressing the ENTER key, it will clear the terminal screen.
20. ip Command
Linux ip command is an updated version of the ipconfig command. It is used to assign an IP
address, initialize an interface, disable an interface.
Syntax:
1. ip a or ip addr
Output: