Unable to successfully execute some commands in Cygwin - windows

I installed Cygwin64 in my 64-bit Windows 7 machine. The following commands failed executing, however, by displaying the error messages below. Could you help providing a resolution please?
$ ll
-bash: ll: command not found
$ clear
-bash: clear: command not found
However, the command ls -l worked...
$ ls -l
total 0
Also i tried by un-commenting the following line in .bashrc file in my home dir -
# alias ll='ls -l'
But it didn't help either!

After you uncomment the alias, you should start a new Cygwin shell for it to take effect. The .bashrc file is actually a script that is sourced when bash starts.
clear is not a Cygwin (Unix) command. Just use Ctrl-L instead.

Related

What is the difference between bash as a default shell and running 'bash'?

I set up subl command in ~/bin
But I couldn't run the command subl unless I run bash in my terminal. I thought changing default shell from zsh to bash would fix it but it did not. I still have to run bash before subl and this is annoying.
What's the difference between default bash and command bash?
Why subl wouldn't work until I run bash and what should I do to make it work?
I've just started learning actual computer and I know these could be silly questions. Thanks a lot for your help.
TORIs-MacBook-Pro:~ taro$ echo $SHELL
/usr/local/bin/bash
TORIs-MacBook-Pro:~ taro$ subl --help
-bash: subl: command not found
TORIs-MacBook-Pro:~ taro$ bash
bash-5.0$ subl --help
Sublime Text build 3211
Execute ~/bin/subl
Your subl command located in ~/bin (very often equivalent to /home/user/bin) is probably not in zsh's PATH variable :
The command interpreter doesn't look everywhere on you computer when you execute a command, it has a few directories to search in. This list is stored in an environment variable called PATH. It contains something like this :
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
In my case, ~/bin is not in the list, but I can add it for this session only executing PATH="$PATH:~/bin" or include it when zsh starts by adding this line to ~/.zshrc :
PATH="$PATH:~/bin"
Now my PATH is :
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin
Change the default shell
I'm not sure how it works with macOS X, but on Linux to change the default shell you need to execute this command line :
$ chsh -s /bin/bash
NOTE : the argument following -s must be a path to an interpreter, like bash.
You can found its path with which bash for example.
Then just relaunch your terminal or log out and in.
important : see first comment below about the tilde expansion (thanks to #Charles Duffy)

Failing to run external Bash program — /usr/bin/bash: bad interpreter: No such file or directory

I'm trying to run a CLI tool in Linux (Mint) which allows me to edit subtitles. It is named subedit: github link. In order to run it, I've added executable permission with chmod +x and added it to the path in bash. However, when I run it, I get the following error message:
bash: /home/main/Documents/shellTools/subedit/subedit: /usr/bin/bash: bad interpreter: No such file or directory
I'm not very experienced with external bash programs and forgot to do something that would be obvious in hindsight.
When I do echo $PATH this is the output:
/home/main/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/main/Documents/shellTools/subedit/
Could somebody please help?
Assuming bash is installed, (it usually is), change the first line of subedit from:
#!/usr/bin/bash
to:
#!/bin/bash
Or if one would prefer not to edit subedit, try this one-liner covering what Al-waleed Shihadeh suggested:
ln -s "$(which bash)" /usr/bin/bash
It seems that you don't have bash installed, you can verify that by running
which bash
if the above command returns "bash not found", then you need to install it.
In case the above command returns a path, you can use the below command to add a symlink to the expected path
ln -s $(path from the above command) /usr/bin/bash
Use the command termux-chroot ONCE!
If you want to always run at the start of a session, be sure to check if it was never run before.
if [ -z $CHROOT ]; then
CHROOT=1
termux-chroot
fi

-bash: unalias: emacs: not found

I followed some advice on how to remove an alias and run unalias on it. Now every time I open up a shell I get this message :
-bash: unalias: emacs: not found
Please help!
It would seem that you've put unalias emacs in a script that runs each time you log on - perhaps in ~/.bashrc. Each time you log in, it's trying to run the unalias command when the alias has already been removed. Try removing this command from any startup scripts and see if that fixes your problem.
If you can't find where you put the unalias command, you can try grep'ing through your file system, but it may take a long time: grep -rn / -e "unalias emacs" 2>/dev/null
Happy hunting!

Bash alias doesn't work in cygwin

Can someone please explain to me how to set up bash aliases? I am using cygwin on windows 8.
I added alias my_first_alias='git status' at the end of /.bashrc file. Typing my_first_alias into cygwin results in -bash: my_first_alias: command not found.
Trying to restart cygwin, running . .bashrc doesn't help with that.
The syntax of your alias command is correct and should be working as long as the alias command is actually being executed. It sounds like your .bashrc file is not being loaded when you start your bash shell. Make sure you have the following in your ~/.bash_profile file:
[[ -s ~/.bashrc ]] && source ~/.bashrc
Also make sure that the location of .bashrc and .bash_profile are in your home directory. Above you have referenced /.bashrc. I doubt "/" is your home directory. You can determine the location of your home directory from the shell by entering the command:
cd; pwd

“export: command not found [duplicate]

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
When I open terminal on my mac it shows
Last login: Sun Mar 15 22:12:02 on ttys000
-bash: “export: command not found
-bash: “export: command not found
-bash: “export: command not found
-bash: “export: command not found
(My echo $PATH)
MacBook-Air-Tim:~ timreznik$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/timreznik/bin:/usr/local/bin
MacBook-Air-Tim:~ timreznik$
I have already tried to edit my .bash_profile to
# general path munging
PATH=${PATH}:~/bin
PATH=${PATH}:/usr/local/bin
but it still keep showing me “export: command not found when I launch terminal...
P.S. all commands seems to work but my inner perfectionist is screaming!
First, export is a shell builtin:
$ type export
export is a shell builtin
This means that PATH is irrelevant.
Second, the error message makes clear that the script is attempting to run the command “export. There is no such command:
$ “export
bash: $'\342\200\234export': command not found
The solution is to remove the spurious character from before the string export.
This misspelled command is in one of the shell's initialization files. These would include: ~/.bashrc, /etc/bash.bashrc, ~/.bash_profile, ~/.bash_login, ~/.profile, and any files they include.
Alternatively, the following commands will tell you which files and which lines in those files have the misspelled export command:
PS4='+ $BASH_SOURCE:$LINENO:' BASH_XTRACEFD=7 bash -xlic "" 7>trace.out
grep '“export' trace.out
For details on how the above works, see this post.
I had a similar problem, the culprit was non-breaking space between export and the name of the variable.
To resolve the issue, just replace it with a regular space character.
Details:
I had the following in .bash_profile:
export a=foo
When I start new terminal, I would get
-bash: export a=foo: command not found
If we run xxd on the file, however, we can plainly see the problem (dots are non-printable characters:
$ cat .bash_profile | head -n1 | xxd
00000000: 6578 706f 7274 c2a0 613d 666f 6f export..a=foo
Byte sequence c2a0 stands for non-breaking space

Resources