Lab 1
Network and System Administration laboratory manual
CMD, short for Command Prompt, is a command-line interpreter application available in most
Windows operating systems. It allows users to interact with the operating system directly by typing
text-based commands rather than using a graphical user interface (GUI). This is especially useful
for administrative tasks, troubleshooting, and automating repetitive tasks.
Here are some common CMD (Command Prompt) commands for file management on Windows:
1. List:- In order to see the list of files in your pc you have to write “dir” in the command
prompt for windows. And for linux you have to write “ls”. In order to go inside a folder
you have to write “cd folder_name”. Here cd means change directory.
Set by G.A
2. How to get help in the Command Prompt (CMD):- To access help in the Command
Prompt, you have to type the help command and then press Enter. A list with all available
commands is displayed, as you can see below.
To get help for any directory use /?, help
3. Date : In order to see dates we type “DATE /T”
4. Navigating Directories
cd <directory> Change directory to the specified path.
Example: cd C:\Users\Username\Documents
Set by G.A
cd .. Move one level up in the directory tree.
How to change the directory (folder) in Command Prompt (CMD):- The first command from
the list is CD (Change Directory). This command enables you to change the current directory or,
in other words, to navigate to another folder from your PC. For instance, the command CD\ takes
you to the top of the directory tree. To see how it works, after you open the Command Prompt,
type cd\ and press Enter on your keyboard. You should see how the CD\ command takes you to
the top of the directory tree. In this case, to the "C:" drive.
5. How to change the drive in Command Prompt (CMD) To access another drive, type the
drive's letter, followed by ":". For instance, if you wanted to change the drive from "C:" to
"D:", you should type "d:" and then press Enter on your keyboard.
To change the drive and the directory at the same time, use the cd command, followed by the "/d"
switch. The "/d"parameter is used to change the current drive to a specific folder from another disk
volume. For instance, if you are now on the "D:" drive and you want to go back to the Windows
folder from the"C:" drive, you should type "cd /d C:\Windows" and press Enter on your keyboard,
like in the following screenshot.
Set by G.A
6. How to view the contents of a directory in Command Prompt (CMD):- You can view
the contents of a folder by using a command called DIR. To test it, we have created a folder on
the D: drive, with several files and subfolders. You can see the m in the screenshot below.
Or
7. How to create a new directory with Command Prompt (CMD) You can make a new
folder using the MKDIR (Make Directory)or the MD command. The syntax of these
commands is "MKDIR Folder" or "MD Folder." Let's say we need to create a new folder
called Digital_Citizen_Life that is going to be placed in the "D:\Digital_Citizen" folder.
To do that, we need to type "mkdir Digital_Citizen_Life" and then press Enter, as shown
below.
Set by G.A
To test if it worked, use the DIR command again. The newly created folder appears in the list.
Another way to create a folder that does not involve being in the desired folder is to type the
complete path of the new folder. For example, if you are working on the "D:" drive and you
want to create a new folder in "C:," called other_stuff, type "mkdir c:\other_stuff" and then
press Enter.
Set by G.A
When you need to create a folder with subfolders at the same time, you can use the "MKDIR
Folder\Subfolder" command. For instance, if we type "mkdir
Digital_Citizen_Tests\Beta\Test1"three folders are created: Digital_Citizen_Tests, Beta and
Test1, in a tree-like structure.
8. How to rename files and folders with Command Prompt (CMD):- To rename files and
folders, you need to use the REN (Rename) command. To rename folders, type "ren Folder
NewFolderName." For example, if we wanted to rename the Digital_Citizen_Tests folder
to Digital_Citizen_Final_Tests, we should run "ren Digital_Citizen_Tests
Digital_Citizen_Final_Tests" and press Enter.
To create a file use the following
Set by G.A
To rename file name
9. How to copy files with Command Prompt (CMD) :- The Copy command allows you to
copy files from one location to another. To use this command, type "copy
location\filename.extension newlocation\newname.extension".
To delete file and folder
Set by G.A
How to copy folders (and their contents) with Command Prompt (CMD) To copy a folder
and its content from a location to another, use the XCOPY command followed by the "/s
/i" operators. Let's assume that we need to copy a folder from "D:\Digital_Citizen"to
"C:\Backup_Digital_Citizen." To do that, we have to run the command "xcopy /s /i
d:\Digital_Citizen
The DEL command cannot be used to delete folders. Therefore we must use another
command to remove any empty folder: RD (Remove Directory). We have previously
deleted all the files from the Digital_Citizen_Tests folder.
Set by G.A