Command 'ls' not working in command prompt - windows

Command 'ls' not working in windows
Getting an error while executing 'ls'
'ls' is not recognized as an internal or external command, operable
program or batch file.

Use the command dir to list all the directories and files in Windows; ls is a unix command.

Please follow below steps to fix this
download and install git
https://git-scm.com/downloads.
After git installation is completed,navigate to folder where git is installed. Check in C/Program Files Folder.
Navigate to C:\Program Files\Git\bin
Add the above location (C:\Program Files\Git\bin) in path variable in system environment variables.
Restart cmd and try to run ls and other Linux commands.
It should work now!!`

We don't use ls(List) command in windows.
Instead of using ls command use dir(Directory) command.
This command also displays the total number of files and directories
listed.
NOTE:
We can use ls command in Windows PowerShell. It works in PowerShell, shows the files and directories listed.

Related

'gawk' is not recognized as an internal or external command, operable program or batch file. but other files in the similar path can be run in Cmd

I wan to run a code which should be read in Cmd using gawk. I have installed it in my program file directory. I also have installed another file named Grep.exe in the same directory:
enter image description here
when I try to run codes with these files I can run grep in cmd but I cant run gawk which is in the same directory. see the picture:
enter image description here
I thought the problem is with the path so I tried different things.
1
defining the path in cmd with this command and this link
setx path "%path%;c:\directoryPath"
define path in windows env using this link
Installing in different directory and adding env path
renaming the gawk.exe to ggawk.exe and trying to run
installing in other computrs
none of them work.
I dont know what is the reason that it can read other files in the same directory but not this specific .exe file that I need.

Git bash: whereis command not found

I am using git bash on a windows machine. Everything works normally except for the whereis command. The terminal tells me the command is not found:
$ whereis grep
bash: whereis: command not found
I have already tried adding C:\Program Files(x86)\Git\bin to my PATH.
How do I fix this?
Use the where in Windows
Utilized the command whereis in Linux is equals that command where , provided for the Windows kit for Windows 98, and is included by default in Server 2003, Vista, and newer versions :
$ where git
C:\Program Files\Git\mingw64\bin\git.exe
C:\Users\MyUser\scoop\shims\git.exe
More information
Equivalent whereis in Windows
where.html
Add the .exe in gitbash for Windows
While you want an executable of the type .exe in gitbash you should be add in the follow path relation :
C:\Program Files\Git\mingw64\bin\<EXE>.exe
Or where there is ubication the folder git but always should be add in mingw64\bin\.
Install whereis in Windows
You must download the following file:whereis.zip
Once unzipped, you should copy the whereis.exe file that is in :
mvp_tips/whereis/Debug/
And copy it in :
C:\Program Files\Git\mingw64\bin\
If all went well, close all the GitBash tabs and reopen one of them and enter :
$ whereis whereis
C:\Program Files\Git\mingw64\bin\whereis.exe #And what should come out if everything is correct:
Script for download and installation
Run the Git Bash as Run As Administrator
#!/bin/bash
wget www.flounder.com/whereis.zip
unzip whereis.zip
cd mvp_tips/whereis/Debug/
cp whereis.exe 'C:\Program Files\Git\mingw64\bin\'
source ~/.bashrc
whereis whereis

Cannot change directory in psql on windows 10. PostgreSQL 11

I downloaded local PosgreSQL 11 on Windows 10.
I try to change directory in psql on command line window to c:\Program Files\PostgreSQL\11\bin>
I get either invalid command or directory does not exist
I tried following with
postgres=# cd c:\Program Files\PostgreSQL\11\bin
Invalid command \Program. Try \? for help.
postgres-# \cd c:\Program Files\PostgreSQL\11\bin
Invalid command \Program. Try \? for help.
postgres-# \cd..
Invalid command \cd... Try \? for help.
postgres-# \cd ..
postgres-# \cd Program Files
\cd: could not change directory to "Program": No such file or directory
I'm not even sure about current directory as pwd is not recognized:
postgres-# \! pwd
'pwd' is not recognized as an internal or external command,
operable program or batch file.
many thanks in advance
UPADATE: Figured out how to check current directory \! cd
Tried to run command this way \! C:\>cd C:\Program Files\PostgreSQL\11\bin
I get:
postgres-# \! C:\>cd C:\Program Files\PostgreSQL\11\bin
Access is denied.
A bit late for OP, but here are some tips for others who stumble in here.
There are two relevant psql commands for these directory change and drive change tasks.
The "built-in" \cd command. You can use this to actually perform the change of directory. However, where Windows uses backslash, use instead forward slash. Also, this command understands drive letter, and unlike Windows cd, you don't have to add a flag to change drive with the cd command here. Examples:
\cd /dir1/dir2
\cd D:/dira/dirb <-- Drive letter
\cd '/dir with spaces/other dir' <-- single quotes
Problem: How do you display the current drive/directory? Unlike in Windows, if you issue a \cd with no argument, psql does not show you the current directory. Instead it changes to the root C:\ directory (presumably in analogy to linux cd command changing to home directory.) So you need to issue a different command to see current directory.
psql can call a shell command, using the form \! <command>
So in linux you could use \! pwd to view present working directory. However, Windows doesn't have a pwd command. But you could use \! cd.
This is apt to get confusing, and prone to accidentally using \cd (which changes the directory unwantedly) when you intended ! cd, especially if you're jumping between Windows and Linux. So on Windows you might want to create a batch file to implement pwd.
As a further point of confusion, you might think to use something like:
\! cd \dira\dirb , however, for some reason, running \! cd with arguments doesn't seem to work (forward or back slashes).
An additional alternative, if you only need to change to a particular current directory once, you could cd before running the script that launches psql. That is to say, don't use the "SQL Shell (psql)" command that Postgresql installs on the Start Menu. Instead, look at the properties of that command, note the path to the script, and use that in a command window only after you've cd'ed to the desired directory.
You could try
postgres=# \cd 'c:\\Program Files\\PostgreSQL\\11\\bin'
I'm using windows btw
You have to change your directory before you run psql
Now, you might be thinking but when I open psql shell Its already running psql that's because you opened it in psql shell, don't do that
Here's what you need to do
open command prompt
change your directory using cd
then run the psql command
if you are getting 'psql is not a command' error, that is because the psql path is not in your environmental variables
if you need to fix that go to this page..→ Click me

msysgit Git Bash ignores 1 entry in my PATH variable

The Problem
When I enter the command android in the normal Windows command prompt, android.bat is launched from the a directory I included in the PATH-variable.
When I enter the same command in the msysgit Git Bash, the bash complains:
sh.exe": android: command not found
android is the only command that has this problem, all others work on both shells (the directory it is contained in is android-sdk/tools )
Working examples are node, npm, heroku.
My environment
This is what echo $PATH returns in Git Bash:
/c/Users/Tobias/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Users/Tobias/AppData/Local/apache-ant-1.9.4/bin:/cmd:/c/Program Files/nodejs/:/c/Python27:/c/Python34/:/c/Python34/Scripts:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/c/Program Files (x86)/Common Files/Acronis/SnapAPI/:/c/Program Files (x86)/Heroku/bin:/c/Program Files/Java/jdk1.8.0_11/bin:/c/Ruby200-x64/bin:/c/Users/Tobias/AppData/Roaming/npm:/c/Users/Tobias/AppData/Local/Android/android-sdk/tools:/c/Users/Tobias/AppData/Local/Android/android-sdk/platform-tools:.
This is what echo %PATH% returns in Windows CMD:
C:\Users\Tobias\AppData\Local\apache-ant-1.9.4\bin;C:\Program Files (x86)\git\cmd;C: \Program Files\nodejs\;C:\Python27;C:\Python34\;C:\Python34\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Heroku\bin;C:\Program Files\Java\jdk1.8.0_11\bin;C:\Ruby200-x64\bin;C:\Users\Tobias\AppData\Roaming\npm;C:\Users\Tobias\AppData\Local\Android\android-sdk\tools;C:\Users\Tobias\AppData\Local\Android\android-sdk\platform-tools;
Seems like msysgit can't access files inside C:\Users\x\AppData\Roaming.
I fixed the issue by moving the directory directly in the C: drive.

cwrsync in windows not being recognised

I am trying to move from a mac environment to a windows one and require rsync.
Found cwrsync # http://www.rsync.net/resources/howto/windows_rsync.html
I have installed the cwrsync program fine, I can call the rsync at cmd but on when in the directory which contains the sync.exe
When in command prompt, if i call rsync when not in the relavent directory it moans and sayS:
"rsync" is not recognised as an internal or external command, operable
program or batch file.
Is there a way to add the rsync.exe to a global list so as rsync is recognised outside of its immediate parent directory?
Thanks,
John
Add the path in the Windows system variables:
- Control Panel -> System -> tab Advanced, button Environment Variables.
- Edit the "Path" system variable and add the full path to the installed rsync:
C:\Program Files\cwRsync\bin or C:\cygwin\bin. or
C:\Program Files (x86)\cwRsync\bin or C:\cygwin\bin.
This way the commands rsync and ssh should run from any directory. Make sure you put in the correct install path to the application else it won't work. See screenshot below:
Environment Variable Setup: Make sure the path you added is under System Variables:
Command: As seen, I am running this directly from root of C: drive
cwRsync distribution contains a batch file example called cwrsync.cmd with correct path settings. You can simply add your rsync command into that file.

Resources