- What are Shell Commands?
- basename
- clear
- mkdir
- rmdir
- Shell Command
- Syntax
- Arguments
- Switches
- Remarks
- Windows commands
- Prerequisites
- Command shell overview
- Command-line reference A-Z
- Команды Windows Windows commands
- Предварительные требования Prerequisites
- Общие сведения о командной оболочке Command shell overview
- Справочник по командной строке A-Z Command-line reference A-Z
- What are Shell Commands?
- basename
- clear
- mkdir
- rmdir
What are Shell Commands?
The shell is the command interpreter on the Linux systems. It the program that interacts with the users in the terminal emulation window. Shell commands are instructions that instruct the system to do some action.
Some of the commonly used shell commands are −
basename
This command strips the directory and suffix from filenames. It prints the name of the file with all the leading directory components removed. It also removes a trailing suffix if it is specified.
Example of basename is as follows −
This gets the name of the file i.e. city which is present in folder country.
This command concatenates and prints the contents of the file. If there is no file, then it reads the standard input.
Examples of cat are as follows −
Let us see how to print the contents of a file −
The above example displays the contents of the file example.txt.
Let us see how to concatenate two files −
In the above example, the contents of the text files example1 and example2 are concatenated into the text file example3. Then the contents of example3 file are displayed.
This command is used to display a calendar. If a single parameter is specified, then the four-digit year is displayed. If there are two parameters, that denotes the month and the year. No parameter means that the current month is displayed.
Example of cal is as follows −
Since there is no parameter specified with cal, it returns the calendar of the current month i.e. September.
cd is used to change the current working directory to the required folder. If the directory name is given, then the shell’s name is changed to that directory. Otherwise, it changes to home.
Example of cd is as follows:
The current directory is changed to example using cd and that is displayed using pwd command −
This command copies the contents of a file into another file.
Example of cp is as follows −
cp copies the contents of the text file example into the backup file example.bak
clear
The clear command clears the terminal screen. It ignores any command line parameters that may be present.
Example of clear is as follows −
This clears the terminal screen.
This function compares two different files and reports the differences between them character by character. If the files differ, it tells the first byte and line number where they differ.
Example of cmp is as follows −
This example demonstrates that the first difference in example1.txt and exampl2.txt is in line 1 and at byte 10.
mkdir
This command is used to create a directory in the Linux operating system.
Example of mkdir is as follows:
The above command creates a directory apple in the directory fruit.
rmdir
This command is used to remove a directory. All the files and subdirectories in a directory should be deleted first before deleting a directory.
Example of rmdir is as follows −
This deletes the directory example.
The mv i.e. move command can be used for renaming directories.
Example of mv is as follows −
The initial name of the directory is name1 which is changed to name2.
Shell Command
Launches executable programs from within Visual Studio.
Syntax
Arguments
Required. The path and file name of the file to execute or the document to open. A full path is required if the specified file is not in one of the directories in the PATH environment variable.
Optional. Any arguments to pass to the invoked program.
Switches
/commandwindow [or] /command [or] /c [or] /cmd
Optional. Specifies that the output for the executable is displayed in the Command window.
/dir: folder [or] /d: folder
Optional. Specifies the working directory to be set when the program is run.
/outputwindow [or] /output [or] /out [or] /o
Optional. Specifies that the output for the executable is displayed in the Output window.
Remarks
The /dir /o /c switches must be specified immediately after Tools.Shell . Anything specified after the name of the executable is passed to it as command line arguments.
The predefined alias Shell can be used in place of Tools.Shell .
If the path argument supplies the directory path as well as the file name, you should enclose the entire pathname in literal quotes («»»), as in the following:
Each set of three double quotes («»») is interpreted by the Shell processor as a single double quote character. Thus, the preceding example actually passes the following path string to the Shell command:
Windows commands
All supported versions of Windows (server and client) have a set of Win32 console commands built in.
This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Prerequisites
The information that is contained in this topic applies to:
- Windows Server 2019
- Windows Server (Semi-Annual Channel)
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2
- Windows Server 2008
- Windows 10
- Windows 8.1
Command shell overview
The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
You can also download and install PowerShell Core, the open source version of PowerShell.
Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.
To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Command-line reference A-Z
To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Команды Windows Windows commands
Все поддерживаемые версии Windows (сервер и клиент) имеют набор встроенных команд консоли Win32. All supported versions of Windows (server and client) have a set of Win32 console commands built in.
Этот набор документации описывает команды Windows, которые можно использовать для автоматизации задач с помощью скриптов или средств создания скриптов. This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Предварительные требования Prerequisites
Сведения, содержащиеся в этом разделе, применимы к: The information that is contained in this topic applies to:
- Windows Server 2019 Windows Server 2019
- Windows Server (Semi-Annual Channel) Windows Server (Semi-Annual Channel)
- Windows Server 2016 Windows Server 2016
- Windows Server 2012 R2 Windows Server 2012 R2
- Windows Server 2012 Windows Server 2012
- Windows Server 2008 R2 Windows Server 2008 R2
- Windows Server 2008 Windows Server 2008
- Windows 10 Windows 10
- Windows 8.1 Windows 8.1
Общие сведения о командной оболочке Command shell overview
Командная оболочка была первой оболочкой, встроенной в Windows, для автоматизации стандартных задач, таких как управление учетными записями пользователей или ночное резервное копирование с пакетными файлами (bat). The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. С помощью сервера сценариев Windows можно выполнять более сложные сценарии в командной оболочке. With Windows Script Host you could run more sophisticated scripts in the Command shell. Дополнительные сведения см. в разделе cscript или Wscript. For more information, see cscript or wscript. С помощью скриптов можно более эффективно выполнять операции, чем с помощью пользовательского интерфейса. You can perform operations more efficiently by using scripts than you can by using the user interface. Скрипты принимают все команды, доступные в командной строке. Scripts accept all Commands that are available at the command line.
Windows имеет две командные оболочки: Командная оболочка и PowerShell. Windows has two command shells: The Command shell and PowerShell. Каждая оболочка представляет собой программную программу, обеспечивающую прямой обмен данными между вами и операционной системой или приложением, предоставляя среду для автоматизации ИТ-операций. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell был разработан для расширения возможностей командной оболочки для выполнения команд PowerShell, называемых командлетами. PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Командлеты похожи на команды Windows, но предоставляют более расширяемый язык сценариев. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. Вы можете выполнять команды Windows и командлеты PowerShell в PowerShell, но Командная оболочка может выполнять только команды Windows, а не командлеты PowerShell. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
Для наиболее надежной и последней версии службы автоматизации Windows рекомендуется использовать PowerShell вместо команд Windows или сервера сценариев Windows для службы автоматизации Windows. For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
Вы также можете скачать и установить PowerShell Core, версию PowerShell с открытым исходным кодом. You can also download and install PowerShell Core, the open source version of PowerShell.
Неправильное изменение реестра может серьезно повредить систему. Incorrectly editing the registry may severely damage your system. Перед внесением следующих изменений в реестр следует создать резервную копию всех ценных данных на компьютере. Before making the following changes to the registry, you should back up any valued data on the computer.
Чтобы включить или отключить завершение имен файлов и каталогов в командной оболочке на компьютере или в сеансе входа пользователя, запустите regedit.exe и задайте следующее значение reg_DWOrd: To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\completionChar\reg_DWOrd HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\completionChar\reg_DWOrd
Чтобы задать значение reg_DWOrd , используйте шестнадцатеричное значение управляющего символа для конкретной функции (например, 0 9 — TAB, а 0 08 — Backspace). To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). Заданные пользователем параметры имеют приоритет над параметрами компьютера, а параметры командной строки имеют приоритет над параметрами реестра. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Справочник по командной строке A-Z Command-line reference A-Z
Чтобы найти сведения о конкретной команде, в следующем меню A-Z щелкните букву, с которой начинается команда, а затем щелкните имя команды. To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Объект | Б | C | Г | Д | F | Ж | З | Я | J | Л | L | М | N | O | P | Вопросы и ответы | Язык R | С | T | U | Версия | Н | X | Y | Гармошкой A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
What are Shell Commands?
The shell is the command interpreter on the Linux systems. It the program that interacts with the users in the terminal emulation window. Shell commands are instructions that instruct the system to do some action.
Some of the commonly used shell commands are −
basename
This command strips the directory and suffix from filenames. It prints the name of the file with all the leading directory components removed. It also removes a trailing suffix if it is specified.
Example of basename is as follows −
This gets the name of the file i.e. city which is present in folder country.
This command concatenates and prints the contents of the file. If there is no file, then it reads the standard input.
Examples of cat are as follows −
Let us see how to print the contents of a file −
The above example displays the contents of the file example.txt.
Let us see how to concatenate two files −
In the above example, the contents of the text files example1 and example2 are concatenated into the text file example3. Then the contents of example3 file are displayed.
This command is used to display a calendar. If a single parameter is specified, then the four-digit year is displayed. If there are two parameters, that denotes the month and the year. No parameter means that the current month is displayed.
Example of cal is as follows −
Since there is no parameter specified with cal, it returns the calendar of the current month i.e. September.
cd is used to change the current working directory to the required folder. If the directory name is given, then the shell’s name is changed to that directory. Otherwise, it changes to home.
Example of cd is as follows:
The current directory is changed to example using cd and that is displayed using pwd command −
This command copies the contents of a file into another file.
Example of cp is as follows −
cp copies the contents of the text file example into the backup file example.bak
clear
The clear command clears the terminal screen. It ignores any command line parameters that may be present.
Example of clear is as follows −
This clears the terminal screen.
This function compares two different files and reports the differences between them character by character. If the files differ, it tells the first byte and line number where they differ.
Example of cmp is as follows −
This example demonstrates that the first difference in example1.txt and exampl2.txt is in line 1 and at byte 10.
mkdir
This command is used to create a directory in the Linux operating system.
Example of mkdir is as follows:
The above command creates a directory apple in the directory fruit.
rmdir
This command is used to remove a directory. All the files and subdirectories in a directory should be deleted first before deleting a directory.
Example of rmdir is as follows −
This deletes the directory example.
The mv i.e. move command can be used for renaming directories.
Example of mv is as follows −
The initial name of the directory is name1 which is changed to name2.