Command syntax. NET USER Command Examples

Before you begin learning the commands, you need to get acquainted with some initial information that is necessary for further exploration of the command line.

Command line command syntax.

Each command has a specific syntactic structure according to which the user enters the command at the command line. For example, let's take the CD command, which is used to change the current directory. It has the following syntax cd [drive:][path] [..]. Most command line commands have various parameters and switches. Typically, a key is indicated by a letter of the Latin alphabet preceded by a vertical slash "/" (in some commands, keys may begin with a minus sign "-"). In our case, the CD command has one key. [drive:][path] and [..] are parameters to the CD command. If any keys and parameters are written in square brackets, then their use in the command is optional. For example, in our case, the CD command has a key and parameters that are optional, i.e. The CD command can be used without them. For example, let's take another command, XCOPY, which allows you to copy files and folders. It has the following syntax: xcopy source [result] ] ] [(/a|/m)] ][+[file3]] [(/y|/-y)] . As you can see, the command has many different keys and parameters. However, only one parameter is required: "source". When entering a particular command on the command line, you must adhere to the syntax, i.e. enter switches and parameters (if necessary) in the order in which they are presented in the syntactic structure of the command.

Register when typing commands.

You can type the names of commands, parameters and switches in any case, because it has no meaning when running on the command line.

Working with the file system.

The first command line lessons will be devoted to working with the Windows file system, i.e. working with files and folders. Therefore, a few words should be said about the features of determining paths to files and folders. The path to the file is written as follows: [drive][path\]file_name. Thus, it turns out that only “file_name” is a required parameter. Moreover, if the file name is preceded by a “\” sign, then the route to this file is calculated from the root directory; if the file name is used without the “\” sign, then the route to it is calculated from the current directory. For example, let’s create a file “text.txt” on drive “C”. Let's launch the command line. By default, the current directory is "C:\Users\username". In order to open a file using the command line, you just need to write down the name of the file. However, the route to this file must be correctly displayed here. If we simply type text.txt , then the message ""text.txt" is not an internal or external command, executable program or batch file" will appear on the screen. The fact is that the “text.txt” file is located in the root of the “C” drive, and our current directory is the “user_name” folder (in my case “Vadim”), located in the “Users” folder on the “C” drive. If we need the route to a file to be counted from the root of the disk, we need to put a “\” sign in front of the file: \text.txt

Now let's go to the root of drive "C" (this can be done using the CD\ command). Now, to open the “text.txt” file, it is enough to write text.txt on the command line without using the “\” sign, since the current directory is the “C” drive, and the file is located in the root of the “C” drive

Now let’s create a file “file.txt” in the “Users” folder and change the current directory to “C:\Users\username” (in my case, “username” is “vadim”). You can do this using the command: cd users\username. The file “file.txt” is located neither in the root of drive “C” nor in the current directory, so to open it you need to specify not only the name of the file, but also the directory in which it is located (in our case, “Users”). If we write simply users\file.txt, then the message “The system cannot find the specified path” will be displayed on the screen, since this same “system” is trying to find the file “file.txt” in the “Users” folder, starting from the current directory, those. along the route C:\Users\vadim\Users\file.txt. If we write \users\file.txt on the command line, then the system will look for the file “file.txt” in the “Users” folder, starting from the root of the “C” drive, i.e. via the route "C:\Users\file.txt" which is correct.

If the file is located on another drive, then to access it you must specify the full path indicating the drive name. For example, let’s create a folder “FOLDER” on drive “D”, and in it the file “f1.txt”. Then the command to open the file “f1.txt” will look like this: d:\folder\f1.txt

Special notations are used to designate the current directory and its 3 upper levels. So the current directory is indicated by the symbol “.” (dot), its parent directory - with the symbol "..", the 2nd level directory - with the symbol "...", the 3rd level directory - with the symbol "....". These notations are used in some commands. For example, the CD.. command changes to the parent directory.

Using wildcards.

When working on the command line, file names can be replaced with wildcards, “*” (asterisk) and “?” (question mark). The "*" character replaces any number of characters in the file name, and the "?" indicates the presence or absence of one character in the file name. For example, the entry "*.txt" denotes all text files. The entry "file.*" denotes files with the name "file" and any extension. The entry "*.*" denotes all files. The entry "fi?e.txt" can represent any text file named file.txt, fie.txt, fife.txt, fi4e.txt, etc.

When using filenames that contain more than one word, you must enclose them in double quotes. For example, let’s create a folder “new folder” on drive “C”, and in it a file “new document”. Then to open this file, the path to it must be enclosed in double quotes.

Using the already described dir command as an example, let's look at the rules for writing commands in the MS-DOS system. The specified command can be represented in general form as dir [path]

As you understand, this command should not be entered into the computer in this form. This notation specifies only the syntax of the command and is possible on paper, but not on the command line. The command entry begins with its name (in this example, the name is dir). The command name is followed by a space and then the drive name, which is indicated by d:. Because in some cases the drive may not be specified (see examples above), this part of the command is enclosed in square brackets. These parentheses indicate that a given command element may be missing. Naturally, the square brackets themselves should not be typed when entering a command. The drive name in the shared entry is followed by the path. It is also not necessary to specify it, in this case the contents of the root directory will be displayed on the screen.

MS-DOS commands may include so-called switches that set the conditions for executing the command. So, if you type /P after the dir command, the contents of the directory will be displayed page by page. This mode is useful for large directories whose contents may span several screen pages. For the SCHOOL directory, the paging command will look like: dir c:school/p

In addition to the P switch, the dir command can have a W switch, which specifies the output of only file names - five names on each line. The possibility of having switches in a command is reflected by an entry like: dir [path]

Any MS-DOS command can be roughly represented as:

Command-name [argument]... [switch]...

The ellipsis in these entries means that the command element preceding the ellipsis can be repeated an arbitrary number of times. The ellipsis should not be included in the command itself. An argument is usually understood as the object to which the command is applied (file name, directory name, etc.). Arguments are typically separated from the command name and from each other by a space.

Creating and deleting directories

You are already familiar with several commands for working with directories: dir, tree, cd. Let's supplement this list with commands designed to create and delete directories. These are the md and rd commands respectively. The md command can be written as mkdir, which is short for “make directory” - create a directory. The rd command can also be written in the more verbose form rmdir (short for “remove directory”). The syntax for the md and rd commands is the same:

md and rd

Using the md command, you can create a tree structure of directories by specifying the path to the new directory. Here are some examples:

Create a GRAPH3 directory in the current directory;

Create a REST directory in the root directory of drive C.

The rd command allows you to remove directories other than the current directory. For example, to delete the HOBBY directory on drive C, you need to type:

Note that the directory deleted by the rd command must be empty, that is, all files and subdirectories in it must first be deleted, and the deletion procedure must begin from the lowest level (operations with files will be discussed in the next paragraph). Versions of MS-DOS starting from 6.0 provide for the deletion of directories along with all their contents. To do this, you need to use the deltree command, which has a format similar to the md and rd commands:

deltree [path]

All deletions are made with confirmation, but if you specify the /y parameter in the command, then confirmation is not required. When you need to delete a directory (such as EXERC) contained in the current directory, you simply type deltree exerc

Before deleting a directory, the system will ask you to confirm the deletion. Type Y (Yes) and press Enter.

NET USER - user account management

NET USER command intended for adding, editing or viewing user accounts on computers. When you run the command in the Command Prompt without parameters, a list of Windows user accounts present on the computer is displayed (this command also works well in Windows 10). User account information is stored in the Windows database.

NET USER Command Syntax

net user [username [password | *] [options]]

net user username (password | *) /add [options]

net user username , Where

  • Username- Specifies the user account name that can be added, deleted, edited, or viewed. The name can be up to 20 characters long.
  • password- Assigns or changes the user password. Enter an asterisk (*) to display a password prompt. When entering from the keyboard, the password characters are not displayed on the screen.
  • /domain- Performs an operation on the primary domain controller for a given computer.
  • options- Specifies a command line option for the command.
  • net help command- Displays help for the specified net command.
  • /delete - Deleting a user account.

Additional NET USER Command Options

  • /active:(yes | no) - Activates or deactivates an account. If the account is not activated, the user cannot access the server. By default, the account is activated.
  • /comment:"text" - Allows you to add a description of the user account (maximum 48 characters). The description text is enclosed in quotation marks.
  • /countrycode: nnn - Uses the country code specified for the operating system to implement the appropriate language files when displaying user help and error messages. A value of 0 is the default country code.
  • /expires:(date | never) - Account expiration date. The never value corresponds to an unlimited validity period. The date is specified in mm/dd/yy or dd/mm/yy format depending on the country code. The month can be indicated in numbers, in full or in abbreviated form (three letters). The year can be indicated with two or four digits. Date elements are separated by slashes (/) with no spaces.
  • /fullname: "name" - The user's full name (as opposed to the user account name). The name is indicated in quotation marks.
  • /homedir: path - Specifies the path to the user's home directory. The specified location must exist.
  • /passwordchg:(yes | no) - Indicates whether the user can change their password (the default is can).
  • /passwordreq:(yes | no) - Specifies whether the user account should have a password (the default is must).
  • /profilepath[:path] - Specifies the path to the user's login profile.
  • /scriptpath: path - Path to the script used by the user to log in.
  • /times:(time | all) - Time to login. The time parameter is specified in the format day[-day][,day[-day]],hour [-hour][,hour [-hour]], with an increment of 1 hour. The names of the days of the week can be indicated in full or in abbreviated form. Hours can be specified in 12- or 24-hour notation. For the 12-hour representation, the designations am, pm, a.m are used. or p.m. The all value means there are no restrictions on login time, and the empty value means no login is allowed at all. Days of the week and time values ​​are separated by a comma; Multiple entries for day of week and time values ​​are separated by semicolons.
  • /usercomment:"text" - Allows an administrator to add or edit a comment for an account.
  • /workstations:(computername[,...] | *) - Allows you to specify up to 8 computers from which the user can log into the network. If the /workstations parameter is not specified with a list of computers or is specified as *, the user can log on to the network from any computer.

NET USER Command Examples

  • To display a list of all users on this computer, use the command: net user;
  • To display information about the user "petr" use the following command: net user petr;
  • To add a Petr user account with a full username and the right to connect from 8 am to 5 pm Monday to Friday, use the following command: net user petr /add /times:Mon-Fri,08:00-17:00/fullname:"Petr".
  • To delete an account you must enter the command: net user petr /delete;
  • To turn off account you need to enter the command: net user petr /active:no.

Video - Working with the NET USER utility

02/12/15 21.3K

Why is there such chaos in the world? Yes, because the administrator of our system forgot to fulfill his duties. Or I just lost the list of cmd commands from our world. Although this is a somewhat original look at the existing order of things, it nevertheless reflects part of the truth we need: using the command line, you can easily bring order to your computer:

What is the command line

The command line is the simplest tool for managing your computer's operating system. Control occurs using a number of reserved commands and a set of text keyboard characters without the use of a mouse ( in the Windows operating system).

On UNIX-based systems, you can use the mouse when working with the command line.

Some commands came to us from MS-DOS. The command line is also called the console. It is used not only to administer the operating system, but also to manage common programs. Most often, the most rarely used commands are included in this set of commands.

The advantage of using cmd basic commands is that it consumes a minimal amount of system resources. And this is important in emergency situations when all the computer’s powers are, one way or another, involved.

cmd implements the ability to execute and create entire batch files, which represent a specific order of execution of a number of commands (scripts). Thanks to this, they can be used to automate certain tasks ( account management, data archiving and more).

The Windows command shell for manipulating and redirecting commands to certain operating system utilities and tools is the Cmd.exe interpreter. It loads the console and redirects commands in a format that the system understands.

Working with the command line in the Windows operating system

You can call the console in Windows in several ways:

Both methods involve running the console as the current user. That is, with all the rights and restrictions that are imposed on its role in the operating system. To run cmd with administrator rights, you need to select the program icon in the Start menu and select the appropriate item in the context menu:


After launching the utility, you can get help information about commands and the format for writing them in the console. To do this, enter the help statement and press “Enter”:

Basic commands for working with files and directories

The most frequently used commands are:

  • RENAME – renaming directories and files. Command syntax:

RENAME | REN [drive/path] original file/directory name | final filename
Example: RENAME C:UsershomeDesktoptost.txt test.txt

  • DEL (ERASE) – used to delete files only, not directories. Its syntax is:

DEL | ERASE [processing method] [filename]
Example: Del C:UsershomeDesktoptest.txt/P

By processing method we mean a special flag that allows you to implement a certain condition when deleting a file. In our example, the “P” flag enables the display of a permission dialog for deleting each file:


More information about the possible values ​​of the “processing method” parameter can be found in the technical documentation for the Windows operating system.

  • MD – allows you to create a folder at the specified path. Syntax:

MD [drive:] [path]
Example:
MD C:UsershomeDesktoptest1test2

The example will create a subfolder test2 within the test1 folder. If one of the path's root folders does not exist, it will be created too:

  • RD ( RMDIR) – deleting a specific folder or all directories at a specified path. Syntax:

RD | RMDIR [process_key] [drive/path]
Example:
rmdir /s C:UsershomeDesktoptest1test2

The example uses the s flag, which will cause the entire branch of directories specified in the path to be deleted. Therefore, you should not use the rmdir command unnecessarily with this processing key.

In the next section, we'll take a closer look at network cmd commands.

Commands for working with the network

The command line allows you to manage not only the PC file system, but also its network capabilities. The console's network commands include a large number of operators to monitor and test the network. The most relevant of them are:

  • ping – the command is used to monitor the network connection capabilities of a PC. A set number of packets are sent to the remote computer and then sent back to them. The transmission time of packets and the percentage of losses are taken into account. Syntax:

ping [-t] [-a] [-n counter] [-l size] [-f] [-i TTL] [-v type] [-r counter] [-s counter] [(-j host_list | - k node_list)] [-w interval] [target_PC_name]

Example command implementation:
ping example.microsoft.com
ping –w 10000 192.168.239.132

In the last example of the cmd ping command, the request is sent to the recipient with the specified IP address. The waiting interval between packets is 10,000 (10 sec). By default this parameter is set to 4000:

  • tracert – used to determine the network path to a specified resource by sending a special echo message through the protocol
  • ICMP (Control Message Protocol). After running the command with parameters, a list of all routers through which the message passes is displayed. The first element in the list is the first router on the side of the requested resource.

The cmd command tracer syntax is:
tracert [-d] [-h maximum_hops] [-j node_list] [-w interval] [target_resource_name]
Example implementation:
tracert -d -h 10 microsoft.com

The example traces the route to a specified resource. This increases the speed of the operation due to the use of the d parameter, which prevents the command from attempting to obtain permission to read IP addresses. The number of transitions (jumps) is limited to 10 using the set value of the h parameter. By default, the number of jumps is 30:

shutdown [(-l|-s|-r|-a)] [-f] [-m [\PC_name]] [-t xx] [-c “messages”] [-d[u][p]: xx:yy]
Example:
shutdown /s /t 60 /f /l /m \191.162.1.53

The remote PC (m) with the specified IP address (191.162.1.53) will shut down (s) after 60 seconds (t). This will force you to log out of all applications (f) and the current user's session (l).

THEORETICAL PART

The operating system allows direct access to some files from its structure by the user in order to perform some action or operation. The action will be performed using programs written in these files, and the indication of such an action is called team

Operating system internal commands

The COMMAND.COM file describes how the computer can execute simple, most commonly used commands. DOS commands, which are written as codes in the COMMAND.COM file, are called internal teams. Data from the COMMAND.COM file is loaded into memory for the entire work session, so the system begins executing internal commands immediately. Here are examples of internal DOS commands, the execution codes of which are described in the COMMAND.COM file.

Team Description of the internal team
CD Print the name of the current directory or change directory
copy Copy a file or multiple files to a specified location
date Display the current date and change it if necessary
del, erase Delete specified files
dir List files and subdirectories in the current or specified directory
exit Stop running the COMMAND.COM command processor and transfer control to the program from which it was launched
md, mdir Create a directory or subdirectory
path Specify directories where DOS should look for executable files (programs)
rd, rmdir Remove directory
ren, rename Change the name of the selected file or files
time Display the system time and change it if necessary
type Print the contents of the specified file
verify Check and report the results of writing files to disk

Duplicate commands and abbreviated spellings are written separated by commas. An internal command does not require specifying who will carry it out.

External DOS commands

In addition to system files, the DOS package includes a large set of programs recorded in separate files with the extension .corn, .exe. The program from such a file is specially loaded into memory from disk only at the request of the command. This takes time, so the call, pointing to the name of the file with the DOS program, is called external teamDOS. An external command is the name of the program that will perform the expected action; the command does not include a file extension.

The COMMAND.COM file accepts various DOS commands from the keyboard, but itself only executes internal commands and command set batch files. When faced with a command that it is not prepared to execute internally, COMMAND.COM will look through the list of directory paths and load the appropriate program file from disk for execution.

Programs for executing external commands are supplied with DOS, are stored on disk in the DOS directory as regular files and perform maintenance actions.

Giving a command

Team- this is an order to perform actions, operations.

1. A general-purpose command can be typed on the keyboard in Latin letters; while typing, its text is displayed on the screen in the command line of the DOS prompt.

2. The command can be assigned to a keyboard key (hot key).

3. A command in programs with a windowed graphic design can be described by selecting its parameters with the keyboard or mouse cursor according to the graphic display on the screen: menus, windows that the program provides.

Structure, command syntax

Above, only the names of the commands were given, but in most cases the command only begins with a name, and then additional elements must be written down. The rules for writing and the order of command elements are called syntax teams.

A command can contain four types of elements: team name (required at the beginning) parameters, keys (switches) and meanings. They determine the option for executing a command: who (codes of which program, command), on what object and how will perform the required actions. Command elements are separated by spaces.