Preliminary discussion on--windows PowerShell
Basic operations for directories and files
You can browse directories, create, move, delete directories, and files from the system with some commands. The operation of directories and files is based on the use of command-line tools. Windows users open Powershell, and then try these next commands.
(1) View your current location: pwd
Powershell, as well as the terminal, displays your current directory by default on the left side of the cursor. You can also use the PWD (print working directory) command to see where you are now.
C:\Users\Administrator, which is where I am now, is the working directory that is entered when the Powershell is opened by default, C \ Is the system's drive letter, which is unique to Windows, there is no drive letter on Mac and Linux, and users are where all user documentation is stored in the system. Administrator is the name of the user who is currently logged on to the system. This C:\Users\Administrator is Administrator the user's home directory (home).
(2) display the current directory of things: ls or dir
To see what is under a directory, with the LS command, you can specify the path to a directory at the back of the command, which shows what is in the specified path, and if you use LS directly, it will show you what is in your current location.
Windows Powershell will show more detail about everything under the directory, such as permissions on files and directories, the time of the last update, and so on.
- You can add a path after the LS command, which shows what's underneath this path, which can be either an absolute path or a path path. For example, take a look at all the things under the user's home directory:
LS Desktop
- The above uses a relative path, that is, the LS command will be under the current directory to see what is in the desktop directory. If you use an absolute path, this is the case:
LS C:\Users\Administrator\destop
Note : The Windows path is preceded by a backslash (\), but in Powershell you can also use a slash (/).
(3) displaying the directory structure in a tree shape
Format: Tree [X:][path][parameter]
Parameter explanation:
/a specifies that the tree displays the rows of the linked subdirectory using characters rather than graphic characters
/F Displays the file names in each directory
Tree
R
tree/a
tree/f
(4) Empty the display above the command line: Clear
If you feel that there are too many things on the screen, you can use the clear command if you want to clear the page. You have a refreshing command window.
(5) The symbol in the path:/~./.User home Directory ~
The operating system assigns a specific directory to each user who logs on to the system, and the name of the directory is usually the same as the user's name, and the document belonging to the user is stored under this directory. This directory is the user's home directory, which is represented in the command line by the ~.
Root directory/
A slash (/), which represents the root of the system, is represented by a root directory under a certain drive letter, such as LS/This command will show everything underneath the C packing directory. Both the MAC and Linux represent the root directory of the system.
Current directory./
./OR. , which represents the current directory, such as what you want to do with the current directory, you can add the front of the path./, such as the LS command described above, you want to list the contents of the current directory, you can use LS./, but can generally omit it, directly with the LS command to display the current directory below the object.
Top-level directory: /
You want to deal with the contents of the upper level in your location, you can use one at the beginning of the path. /, for example, to display something in the previous level of the current directory, you can enter LS. / 。 One.. /Represents the previous level of the directory, the first two levels are: /.. / 。
(6) Enter or exit a directory CD
Format: CD [[/d][x:][path][.]]
Parameter explanation:
.. Go to the top level directory
/d quickly change the current directory
/? Display Help information in the command prompt
\ go back to the root directory
(7) Create directory mkdir
Create a new directory at the specified location, using mkdir (make directory), followed by the name of the directory you want to create: mkdir directory Name
My current location is on the desktop and I'm going to create a directory called projects on the desktop: mkdir projects
If you need to create a directory structure, you may want to create a subdirectory under a directory. On Windows, you can add the path to the directory you want to create directly after the mkdir command, and all of the directories above that path will be created if they don't already exist.
(8) Delete subdirectories from a specified location
Format: RD [x:]path[/s][/q]
Parameter explanation:
/s deletes the specified directory and all directories and files for the specified directory.
/q Delete the directory without confirmation.
(9) Path: Set the search path for the executable file
Format: path [[%path%][x:]path[;] ......]
; Separating directories in the command path
%path% Specifies that Windows XP adds a command path to an existing catalog set listed in the PATH environment variable.
Xcpoy: Copies all folders and files under directories and directories to the specified directory location.
Format: xcopy source [destination][/s][/e][/v]
Parameter explanation:
/s copies non-empty files.
/V validates each file when it is written to the destination file.
/E to copy even if the subdirectory is empty
ren: Renaming a directory
Format: ren [x:][path]filename1 filename2
Parameter explanation:
[x:] [PATH]FILENAME1 Specifies the location and name of the folder or file to be renamed
Filename2 new file name specified when renaming files
Get-help is a fairly important cmdlet that can query all Windows PowerShell directives and documentation. For example:
- GET-HELP *: Lists all topics, including directives and concepts.
- Get-help * | MORE: Lists all the topics, including instructions and concepts, and pauses when the full window is displayed.
- Get-help about*: Lists all the conceptual topics.
- Get-help get*: Lists the topics for all get starts.
- Get-help {< instruction name or subject name;}: Lists instructions for the specified instruction or topic, such as Get-help dir can query the use of the dir instruction.
Preliminary discussion on--windows PowerShell