- Сответствие консольных команд Windows и Linux.
- Votum separatum — Yuri Voinov’s Blog
- понедельник, 19 мая 2014 г.
- Аналог which в CMD.EXE
- Поиск по содержанию блога
- Translate
- Обо мне
- Is there an equivalent source command in Windows CMD as in bash or tcsh?
- 8 Answers 8
- What is the Windows equivalent of the diff command?
- 13 Answers 13
Сответствие консольных команд Windows и Linux.
При переходе с Windows на Linux и наоборот, для тех, кто знаком с командной строкой, может пригодиться небольшая справка по соответствию консольных команд этих операционных систем. Естественно, полного соответствия, за редким исключением, не бывает, и в приведенной таблице собраны команды, идентичные по результатам выполнения или функционально близкие.
Соответствие команд CMD Windows командам Linux
Описание | Команда CMD Windows | Команда Linux |
Вызов справочной системы | HELP | apropos, man, whatis |
Вызов командного интерпретатора (оболочки) | CMD | bash, csh, sh |
Очистка экрана | CLS | clear, reset |
Вывод сообщения на экран | ECHO | echo |
Пауза в работе | PAUSE | sleep |
Настройка параметров терминала | MODE | stty |
Установка значений переменных окружения (указание путей к каталогам) | PATH, SET, SETx | env, set |
Изменение системной даты | DATE | date |
Изменение системного времени | TIME | date |
Выход из командной строки | EXIT | exit |
Работа с файлами и каталогами | ||
Отображение списка файлов и каталогов | DIR | dir, ls |
Создание каталога | MKDIR | mkdir |
Удаление каталога | RMDIR | rmdir |
Удаление файла | DEL, ERASE | rm |
Переход в другой каталог | CD | cd |
Копирование файлов или каталогов | COPY, XCOPY | cp |
Переименование файла | REN, RENAME | mv |
Перемещение файлов | MOVE | mv |
Поиск файла | WHERE | find, locate |
Вывод на экран содержимого файла | TYPE, MORE | cat, less, more |
Сравнение содержимого двух файлов | COMP, FC | cmp, diff, diff3, sdiff |
Сортировка строк в текстовом файле | SORT | sort |
Изменение атрибутов файла | ATTRIB | chmod |
Создание символьной ссылки на файл или каталог | MKLINK | ln |
Резервное копирование данных | ROBOCOPY | cpio, tar |
Вызов текстового редактора | EDIT (нет в Windows Vista и старше) | vi |
Работа с томами и разделами | ||
Создание разделов | FDISK | fdisk |
Управление разделами | DISKPART | parted, partx |
Форматирование диска, создание файловой системы | DISKPART, FORMAT | mformat, mkfs |
Проверка файловой системы | CHKDSK | fsck |
Управление системой. | ||
Отобразить список процессов | TASKLIST, QUERY PROCESS | ps |
Уничтожить процесс | TASKKILL | kill, killall |
Перезагрузить компьютер | SHUTDOWN | shutdown, reboot |
Выключить компьютер | SHUTDOWN | shutdown, halt |
Выполнить команду от имени другого пользователя | RUNAS | sudo |
Отобразить имя компьютера | HOSTNAME | hostname |
Пользователи и группы. | ||
Создать нового пользователя | NET USER | useradd |
Изменить параметры пользователя | NET USER | usermod |
Изменить пароль пользователя | NET USER | passwd |
Удалить пользователя | NET USER | userdel |
Создать новую группу пользователей | NET GROUP | groupadd |
Изменить параметры группы | NET GROUP | groupmod |
Удалить группу | NET GROUP | groupdel |
Отобразить список активных пользователей | QUERY USER | users |
Работа с сетью. | ||
Работа с таблицей соответствия IP и MAC адресов ARP | arp | arp |
Конфигурация протокола IP | IPCONFIG, NETSH | ifconfig, ip |
Работа с таблицей маршрутизации | ROUTE | route |
Опрос узла по протоколу ICMP | PING | ping |
Клиент Telnet | TELNET | telnet |
Работа с DNS-сервером в интерактивном режиме | NSLOOKUP | dig, nslookup |
Трассировка маршрута к удаленному узлу | TRACERT | traceroute |
Отобразить статистику сетевых соединений | NETSTAT | netstat |
Строчные и заглавные буквы для команд командной строки Windows воспринимаются одинаково, ECHO и echo — будет интерпретировано как одна и та же команда. При работе в командной строке Linux соблюдение регистра символов обязательно.
Если вы желаете помочь развитию проекта, можете воспользоваться кнопкой «Поделиться» для своей социальной сети
Votum separatum — Yuri Voinov’s Blog
Особое мнение — блог Юрия Воинова
понедельник, 19 мая 2014 г.
Аналог which в CMD.EXE
А теперь, внимание — вопрос.
Как то же самое проделать в CMD? 😉
Да, я знаю, гугл приводит в кучу намеков. Но где работоспособное решение? 😉
rem Check dig installed
for /f «delims=» %%a in (‘where dig’) do @set dig=%%a
if /I «%dig%»==»» echo Dig not found. If installed, add path to PATH environment variable. & exit 1
echo Dig found: %dig%
echo Warming up cache by MRU domains.
rem %dig% -f my_domains 1>nul 2>nul
rem echo Done.
Скажете, нафиг так сложно?
Первое. Попробуйте получить то же самое иным путем. 😉
Так надо. 🙂 Это универсально и это — работает. В отличие от всех прочих частичных решений.
Поиск по содержанию блога
Translate
Обо мне
Юрий Воинов IT — профессионал с большим опытом практической работы, OCP 8i, OCP 9i, OCP 10g, OCP 11g, OCP iAS 10g, OCA PL/SQL, SCSA, SCNA, SCSECA, Oracle SQL Expert, Sun Certified SA for Sun Cluster, Oracle RAC Expert, Oracle WebLogic System Administrator Expert.
Специалист в области Oracle RDBMS, Oracle iAS, OIM/OIF, Oracle Application Express, Oracle Designer и CASE, PL/SQL, Solaris, Sun Cluster, Web-технологий, технологий поиска, технологий кэширования, сетевых технологий, технологий хранения данных Просмотреть профиль
Is there an equivalent source command in Windows CMD as in bash or tcsh?
I know that in the unix world, if you edit your .profile or .cshrc file, you can do a source
/.profile or source
/.cshrc to get the effect on your current session. If I changed something in the system variable on Windows, how can I have it effect the current command prompt session without exiting the command prompt session and opening another command prompt session?
8 Answers 8
I am afraid not, but you can start using Powershell, which does support dot sourcing. Since powershell window is really based on cmd so all your dos command will continue to work, and you gain new power, much more power.
In the usual Windows command prompt (i.e. cmd.exe), just using call mybat.bat did what I wanted. I got all the environment variables it had set.
The dos shell will support .bat files containing just assignments to variables that, when executed, will create the variables in the current environment.
Following example will help you to solve your problem.
env.bat This file is for setting variables. Its contents are given blow.
test.bat Our main batch file.
Now print.bat batch file to print variables. Its contents given below
The only way I have found this to work is to launch a new cmd window from my own config window. eg:
The last cmd will launch a new cmd prompt with the desired settings exported to the command window.
Here’s a workaround for some limited use-cases. You can read-in a file of commands and execute them in-line. For example the calling command file looks like:
In the setup-java.bat file you can’t use % expansion. You need to use ! ; e.g.:
So you are litterally source -ing commands from a text file. You will need to test which commands sourced in this way. It took a few trials just to set some environment variables.
I don’t think we can do logic or loops because the command processor scans the file at the start. I am OK just having a simple workaround to reuse shared things like environment definitions. Most other things won’t need an actual source command (I am hoping). Good luck.
What is the Windows equivalent of the diff command?
I know that there is a post similar to this : here.
I tried using the comp command like it mentioned, but if I have two files, one with data like «abcd» and the other with data «abcde», it just says the files are of different sizes. I wanted to know where exactly they differ. In Unix, the simple diff tells me which row and column, the comp command in windows works if I have something like «abd» and «abc». Not otherwise. Any ideas what I can use for this?
13 Answers 13
Run this in the CMD shell or batch file:
FC can also be used to compare binary files:
Well, on Windows I happily run diff and many other of the GNU tools. You can do it with cygwin, but I personally prefer GnuWin32 because it is a much lighter installation experience.
So, my answer is that the Windows equivalent of diff , is none other than diff itself!
Winmerge has a command line utility that might be worth checking out.
Also, you can use the graphical part of it too depending on what you need.
Another alternative is to download and install git from here. Then, add the path to Git\bin\ to your PATH variable. This will give you not only diff, but also many other linux commands that you can use from the windows command line.
You can set the PATH variable by right clicking on Computer and selecting Properties. Then you can click on Advanced System Settings on the left side of the screen. In the pop up, click Environment Variables and then either add or update the PATH variable in your user variables with Git\bin\
FC works great by in my case it was not helpful as I wanted just the lines that are changed. And FC give additional data like file name, same lines and bilateral comparison.
but in my case I wanted only the lines that have changed and wanted those lines to be exported to different file, without any other header or data.
So I used «findstr» to compare the file :
data.txt.bak is the name of old file
data.txt is the name of new file
DiffResult.txt contains the data that is changed i.e just one line ####09
There’s also Powershell (which is part of Windows). It ain’t quick but it’s flexible, here’s the basic command. People have written various cmdlets and scripts for it if you need better formatting.
Not part of Windows, but if you are a developer with Visual Studio, it comes with WinDiff (graphical)
But my personal favorite is BeyondCompare, which costs $30.
fc. fc is better at handling large files (> 4 GBytes) than Cygwin’s diff.
DiffUtils is probably your best bet. It’s the Windows equivalent of diff.
To my knowledge there are no built-in equivalents.
The reason you getting the error with COMP is that the utility assumes the files that you are comparing are of the same size. To overcome that you can use th ‘/n’ option with which you can specify the number of lines you want to compare. (see the options supported by comp by typing ‘comp /?’ on the command line. so your command would look like :
This should solve your problem if you wanna stick to using COMP. But this will be a problem for really large files.
Though comp is an option, but I feel it is primitive and FC is a better option. you can use FORFILES and FC together to probably make a really good filecompare utility if you require one on a frequent basis.
FC is used this way for ref:
there are many options available which you can see by ‘fc /?’ hope this helps