[English (auto-generated)] Windows Command Line Tools - CompTIA A+ 220-1102 - 1.2 [DownSub.com].txt
Document Details
![PrudentGyrolite9836](https://quizgecko.com/images/avatars/avatar-16.webp)
Uploaded by PrudentGyrolite9836
Tags
Full Transcript
the windows command prompt allows you access to the operating system through what we call a cli a command line interface this brings up a window and you can type commands in in that window to interact with the operating system most of the commands that you'll learn in this video can be run by...
the windows command prompt allows you access to the operating system through what we call a cli a command line interface this brings up a window and you can type commands in in that window to interact with the operating system most of the commands that you'll learn in this video can be run by anybody with standard privileges these are the privileges associated with any user who might be logged into your network this works for almost all commands that the users might use but if you need additional rights and permissions you can use an elevated prompt or an administrative prompt this means that you'll need to be part of the administrators group and when you start the command prompt you'll need to choose the option to run as administrator you can also type the command cmd which stands for the command prompt and type in control shift enter to automatically launch the command prompt in administrative mode this is the same process whether you're in windows 10 or windows 11. in this case we'll use windows 11 we'll click the magnifying glass to search in my case i've already run the command prompt in the past and you can see it listed on that screen or i can simply type in cmd or command prompt and it will search through and find me matches for what i'm searching for in this case the command prompt which shows me the options to open run as administrator open a file location pin to the start and pin to the taskbar in this case let's click the open option and it will open the command prompt giving us access to the operating system as you can see the command prompt doesn't provide you with any information once you start up that window you're put at a prompt and it's up to you to know what to type next there are ways to get some additional assistance through the help command the help command can be used to give you more details about any of the other commands you might use at the command prompt like dir check disk copy and anything else that you might need to use when you're working at the command prompt you can also use the command with a slash question mark at the end which provides you with the same help text that you see when you use the help command and if you need to close this window once you're done using the command prompt you can simply type exit and the entire window will be closed we're back at our command prompt so we'll use the help command and copy to give us information on how the copy command can better be used and you can see there are many options available to copy files and other directories within windows and we can see all of the different options by using that help option if we were to clear this screen i'm going to type cls to clear the screen and use the copy command slash question mark you can see we get exactly the same information so if you're using the help command or using the slash question mark either one will provide you with more information about how that command should be used you may be familiar with using windows explorer to be able to graphically view all of the files and directories on your system and be able to rename or move any of those files around but you can also do this from the command line itself if you'd like to see all of the files available in a particular folder you can use dir which stands for directory list to be able to list all of the files and directories in the current folder you can also use the cd command or chdir to be able to change or move to a different directory on that system you would use the backslash to be able to delineate between different folders in that hierarchy on your drive another useful option at the command line is to use two dots or two periods to specify the folder that's just above the folder where you happen to be working this is especially useful if you need to move backwards through the file system and those two dots can help you do that very quickly you can also create or remove folders from the command line using the mkdir or rmdir commands we very often abbreviate these when we're typing to md for the mkdir and the rd command for the rmdir this makes it very easy to manage the file system at the command line which can be very useful if you don't have a graphical interface available when you're troubleshooting let's use that dir or directory command you can see that we're currently in the c column backslash users backslash professor subdirectory that's my user subdirectory if we type dir at the command prompt we can then get a list of all of the files and folders that are in the working directory users professor messer and you can see most of these are directories so i have additional folders within this current folder that i can then store other files in if we were to look at this in file explorer i'll click that folder at the bottom of the screen that brings up file explorer you can see there is a local disk listed i do have a users folder within that and within the users folder is the professors folder and you can see that the list of all of those folders that we saw at the command line are also shown within file manager and you can see that all of the folders that we saw at the command line are also listed in the file explorer let's now create some folders and remove some folders and see how that changes things in file explorer i'm going to move the file explorer to the right side of the screen and we'll move command prompt to the left side of the screen so we can really watch what's going on let's create a directory we are in our users professor messer folder so i'm going to use the md command with a space because i want to put this folder in my current directory and let's call this folder reports and if i hit enter you can see in file explorer that i have a new folder that was created called reports i may have just realized that i didn't want a folder named reports so i can use the rd command to remove the reports folder and when i press enter you can watch in file explorer that the reports folder will disappear because we have just removed it from the file system we can also use the change directory command to move through this different file structure for example if i use the cd command at the command prompt and specify the documents folder i'm going to start typing doc and then i'm going to hit the tab option to auto complete everything that i was typing in it automatically fills in the rest of the document's name and if i hit enter you can see that our working directory is now changed to users professor and documents i can then use the dir command to see if there's any files within that folder and there is another directory within that folder already named reports if we would then like to move back to the previous directory that we were in which would be user's professor i can use the cd command again and i could type in manually users backslash professor to move back to that directory or you can simply use the shortcut dot dot which will move back one directory and that leaves us at c column backslash users backslash professor when working inside of windows we need some way to designate where certain files may be located and different drives have different letters that we associate with them called drive letters these drive letters are usually associated with a partition or a remote share that's located on another machine and we usually associate that particular drive letter with that particular location for example it's very common for our local storage drive to be associated with the letter c so we put a colon right after the c to designate that that is the storage drive that we're referencing we've already seen this drive being used at the command line when we had the c column backslash users backslash professor the c colon designated that we were accessing our local storage drive and from that local storage drive we were accessing the subdirectory users which has within that folder the subdirectory professor and you can see if you have multiple locations or multiple drives in your system each one of those drives will be given a different drive letter you can see on this system i have drives for c colon s colon t u v w x y and z and of course we have other letters that we could associate with other folders so if we connected to a remote share we might want to call that drive drive g or drive h you have many options when assigning these drive letters and usually you'll pick something that people can remember so that you can tell them to store their user files in drive h or store public files in drive g one of the challenges you'll find very quickly in a support role is you may have many different command line windows up on the screen at once and these may be all connected or associated with different devices the real challenge is when you're typing at a command prompt which computer are you typing these commands into fortunately windows has a command called hostname that will put the name of the computer at the command prompt this means you can type in hostname and confirm that the next command you type in is really going to be applied to the correct system the hostname is one of those straightforward commands that also provide a lot of utility so if we type in hostname right at the command prompt the only thing the computer provides back is the name of the host in this case the name of this computer is daedalus so anything i type at the command prompt will make changes on the system that is named deadlifts if these changes are required to be on a different system typing hostname can give us an early warning that we may be in the wrong window and will need to go find the correct window to be able to make those changes when you create a partition in a file system it's an open area that you could then add other information to but you need some type of file system to be able to store information into that partition the process of installing that file system or configuring a file system in that partition can be done in windows using the format command the format command will write a new file system to this partition effectively erasing anything that may have been there previously so if you're using this format command make sure you specify the correct drive or you could accidentally remove data from your system in this example i previously created a partition and i've assigned a windows drive letter that partition called k that means all i have to do is use the format command with k colon and this tells windows to create a new file system on that drive k the default for this drive is to write a fat32 file system or file allocation table 32-bit and then verifies the size and then initializes the partition you can also provide a volume label so that you can recognize what this partition happens to be in this case i used info as my volume label and when it's done it shows you a summary of the available disk space and how the file system was created as i mentioned earlier the format command can permanently delete data so make sure that you're specifying the correct drive and that you have backups of anything that may have been previously saved on that drive just as you can copy and paste files in file explorer you can copy files at the command prompt using the copy command the syntax of the copy command uses copy the name of the source file and then the destination where you would like to copy that file you can also add different flags or options to the command for example slash v it will verify that the file that you've copied is identical to the original source and if you use y you can tell windows to skip over any prompts where it might be asking you whether you would really like to copy this file or not i've changed directories into a folder that's on my c colon drive it's under users professor documents and reports and if we perform a dir command at that prompt we can see there is a single file in this folder called p3k447report.txt let's say that we'd like to create a copy of this file and we'll make a copy in our existing directory so i'll use the copy command i'll specify p3k and i'll hit the tab key to auto complete and let's say that we would like to call this duplicate.text that is the syntax for the copy command which specifies the source and specifies the destination and if we hit enter it will tell us that one file has been copied if we perform another dir command if we hit enter we can see that we have two files now in this folder one is our original p3k 447 report and the other one is the new file we created called duplicate.txt if we were to perform that command again and i'm going to do that by hitting the up arrow to show that copy command we're going to copy that same file to that same destination but of course there's already a duplicate.txt file because we just created it with the previous copy command windows tells us that there is a file there already and it says would you like to overwrite duplicate.txt and you can either type y for yes or write the entire word y e s and hit enter and it will continue to copy that file of course you could always choose the option of no and windows would not overwrite that file if we already know that we would like to overwrite this file and we would not want to be prompted for this yes or no option we can use the copy command again with the slash y option and we'll specify again p3k447report.txt as our source and duplicate.txt as the destination if we use this command with the slash y and press enter we don't get the previous prompt to overwrite theduplicate.txt because we've already told windows yes we do want to overwrite that file and it simply performs the file copy the copy command is great for copying files that may be in a particular folder or copying a large group of data from one location to another but what if you have multiple files that are located in multiple folders and you would like to copy all of those at one time you can use the x copy command with the slash s this specifies subdirectories so that everything we're copying will not only be in our current folder but every other folder that happens to be underneath our current working directory we can also have a source such as the documents folder and in this case we're specifying that we would like to copy these files and all directories to the m colon drive under backslash backups and if we use this command it will go through all of the files that are underneath our current working directory which in this case is users administrator so under users administrator is a documents folder underneath the documents folder is a mission reports folder underneath the mission reports folder are individual mission reports folders and then separate reports underneath those there's also ship diagnostics folders and underneath that folder are also multiple folders if we were to specify these as individual files we would need to type in separate copy commands with each one of these but by using the slash yes to copy everything in a subdirectory windows goes through the entire group all at once copies all seven files and we didn't have to type anything else at the command line of course there's always more than one way in windows to complete a function and there is another copy command you might want to be familiar with called robocopy this stands for robust copy and it's designed to be a better version of xcopy this is a functionality included with windows 10 and windows 11 and you may find yourself using robocopy in many cases instead of x copy or the copy command the robocopy command provides extensive features for copying files from one location to another let's look through just a few of what these options might be i'm going to type in the robocopy command but i'm also going to use the slash question mark to get the help screen for robocopy and you'll see that a lot of information goes by on the screen let's scroll all the way back up to the top and you can see a summary of what robocopy does and then a list of all of the different options you can use when copying files this provides you with options that may be obvious such as copying subdirectories but not empty subdirectories but if i scroll down a bit you'll start to see more of the detail you can get from robocopy for example you can create files on the destination device using the 8.3 file allocation table file names only for compatibility with older operating systems or one that i like you can change the inner packet gap in milliseconds to specify how much bandwidth might be used when you're copying this file this can be very useful if you're copying files to a remote site especially a site that may have limited bandwidth and you don't want the copy command to overwhelm all of the bandwidth that you have available on that link you can also give robocopy very granular commands for example you can tell robocopy to only copy files during a certain time of the day or you may be copying files to a remote site and the connectivity to that site tends to go up and down throughout the day but you need to transfer a very large file so you can have robocopy begin the copy process if it does lose connectivity to that site it will simply wait until that connectivity is restored and it will then resume the copy process if you were using copy or xcopy those commands would see that the connection was no longer available and it would show you an error message instead of resuming that copy it's not unusual in windows that we may need to restart the system especially if we're installing a new driver or new application at the command prompt you can perform a restart by using the shutdown command the shutdown command as the name implies will shut down the system you can specify the slash s to perform a shutdown and if you'd like you could even use the slash t to specify an amount of time in seconds to wait before the system is shut down if you wanted the system to then restart after shutting down you can use the shutdown command with the slash r option and then optionally you could use the slash t to specify how many seconds it should wait before shutting down and then restarting the system if anywhere in here you feel that you don't want the system to shut down you can abort this process by using shutdown slash a let's perform a shutdown on my windows 11 system we'll use the shutdown command with a slash s to shut things down and i'll specify a time frame of 60 seconds and windows tells us that you're about to be signed out and windows will shut down in one minute we may decide here that there's another step we need to take before we begin the shutdown process so we need to stop this from occurring by typing in shutdown slash a and windows tells us that the log off is canceled and the scheduled shutdown has been cancelled we mentioned earlier about using the format command to write a file system to a partition but how do you create the partition to begin with from the command line you can use disk part which creates partitions from an available disk the diskpart command also has a number of different features inside of it including the ability to do the format from within the disk part command itself you can also list modify or delete volumes from the disk part command so you do want to be very careful when working with disk part or format because both of those commands can easily remove data from your system let's run disk part on my computer i'll type in disk part when i do that it will tell me that what i'm about to do requires elevated permissions and do i really want to run this program and we can say yes we do want to run it because we do know what we're doing in this case and you can see that we're at a disk part prompt on my deadlift server if i use the help command you can see there are a number of options available for disk part you don't have to know all of these options for the a certification but it is useful to know what options might be available if you needed to use the disk part command i'll scroll down so we can use the list command and see what options might be available by typing list i could list the disk i can list partitions volumes or v disks if i use the list command with disk it will show me that this system has a single disk inside of it and windows calls this disk 0. i do happen to know on this disk are additional volumes so i'm going to type list volume and you'll see that on that individual disk are a number of different volumes available and you can see how those particular volumes have been configured and the file systems on each one of those volumes the wenver command provides you with information about the version of windows that's running on your local system this is especially useful when troubleshooting because often you'll sit down at a system and you're not quite sure which version of windows happens to be loaded on that system especially if it's a windows version that has a lot of patches and you're interested in knowing if this system has been patched or not you simply use winver at the command prompt and you'll get the dialog box in windows that tells you more about that windows system if i run winver on this computer you can see that it is a windows 11 device it's running version 21 h2 which is os build 2200.675. with this information i can determine if there's been any patches installed on the system or if i need to install a particular driver i know exactly what operating system i need to look for so that i'm using the correct driver with the correct operating system in this training course we're going to do a lot more with active directory and setting group policies that you can manage remote windows devices but for the purposes of this video let's talk about some commands the users can run to be able to perform some of these group policy updates the first command we'll look at is gp update or forcing a group policy update when an administrator creates a group policy that changes the configuration of one or many remote devices you usually require that user to log out of windows and log back in for that change to take place but the gp update command can allow the user to perform that update without having to cycle through the login process before doing that the user might want to run gpresult to see what the current configuration is for group policy on that particular device and then once you perform a gp update you can run the gp result again to see what the differences might be for this example i've moved to a windows 10 device that is set up to be one of the users that's in an active directory infrastructure this user rodney mckay is logged in and we're at the command prompt for their system let's run a gp result slash r this will compile all of the information about the current active directory configuration and show you all the group policy settings you can see this is a member workstation the operating system version and other details about this user we also have information about the active directory configuration this is user rodney mckay who's in the user's ou under the atlantis ou in the pegasus ou and is part of the domain controller of sgc.local this user has two different objects that have been applied for group policy one redirects folders and the other maps drives during the login process in the background a system administrator has set up some new group policies that will change the configuration of all of the devices on the network one of these changes will be to add a new shortcut to the desktop of everyone's computer we could of course log out and log back in or we could use the gp update command which by itself will take any changes to group policy and apply those or if we want to apply everything in group policy we can use the slash force at the end so that everything is updated when i hit gpupdate force you'll see that it says that it is updating policy and if you look in the upper left a new shortcut was added to the desktop that was created using group policy if we then run another gpresult slash r we'll get the same report that we had before but you'll notice that one of the options under applied group policy objects includes the original folder redirection and login map drives but now there is a new group policy that's been added for desktop shortcut assignments this allows us and the user to confirm that the changes that were made for group policy have been pushed down to our local machine and are currently in use you