Say I have a somecommands.sh and I use chmod 777 to make it executable. Why I have to type ./scommand.sh instead of typing just somecommand.sh to run it from its own directory?  Does this make any sense? If it's able to omit, what should I do?  Thanks
10337
Why do we use ./filename to execute a file in linux?  Why not just enter it like other commands gcc, ls etc...
66840
I saw the following snippet in this thread:   sleep 2 if (-x /usr/local/bin/bash) then   exec /bin/sh -c '. ~/.profile; exec /usr/local/bin/bash' endif   My understanding is that if you place this snippet in ~/.login it will invoke bash when you login.  I have a similar situation where I would like to use a similar snippet to invoke a  version of zsh that is different from the default one with which I log in. Part of the reason why I am going through this trouble is because I can't choose my desired version of zsh in the options allowed in chsh, and I don't have administrator privileges.  With this:   How would I change the snippet above to do this when switching between different versions of zsh?  Why are two exec commands needed in the snippet above? What do they do? Also, why does the snippet above use sh and bash (the user is supposed to login with csh)
77127
I can seem to run scripts (.sh) with and without them being set as executable. So where exactly this matters?
35015
What's the difference between executing a script like this:  ./test.sh  and executing a script like this:  . test.sh?  I tried a simple, two-line script to see if I could find if there was a difference:  #!/bin/bash ls   But both . test.sh and ./test.sh returned the same information.
63943
I have an executable. I want to execute the executable in terminal with name only like other commands.  I can put my executable in /usr/local/bin or I could add its PATH to ~/.bashrc. Both will work.  What is better?  Is there  any difference?
29570
I was curious how I would go about running multiple commands via shell script.  For example, just to try it out, I'd like to be able to connect a .desktop to a .sh that will run all the update codes so I don't have to type it out. I know how to execute a single command via a .sh, not multiple.  Any way?
111339
Is there a way to substitute aliases such that it is appended or prepended to an existing command in the shell?   For example, defining the alias:  alias execloc='/home/user/'   Prepending this to a command in the bash terminal:  cd exeloc/temp/somefolder   Can something like this be done, or is there a way to do it?
98139
Let's suppose I have compiled something and I run it like so:  $ /path/to/my/executable/mycmd Hello World   What do I need to do to run it like   $ mycmd Hello World    from everywhere in my computer?
33821
I used to use '' and "" (single and double-quotes) interchangeably on the command line, but I recently noticed that '$HOME/some/dir' is not expanded, while "$HOME/some/dir" is. I searched around a little bit and found that "" allows some protection of special characters, while '' allows full protection. So what other characters are protected by '' and not ""?  EDIT: What are practical situations in which these differences might be significant?
62331
Here is a simple example showing that using declare in a script the script will not run, while sourcing the script will:  $ cat /tmp/new #! /bin/sh declare -i  hello $ chmod a+rwx /tmp/new $ /tmp/new /tmp/new: 3: declare: not found $ source /tmp/new $    I wonder why directly running the script doesn't work, while sourcing it does? How can I make the first one work? Thanks!
113697
I created a Notepad file on Windows and copied it to Ubuntu. The file contains some iptables rules. After making the file executable using chmod +x and executing it, it didn't work.  However, when I created a Ubuntu () file and copied the same contents from the Notepad file, made it executable and ran it, it worked.  What should I do to make the Notepad file run on Ubuntu?
45426
If you have a series of subfolders (like from a to z) and want to run a command on each one of them (like rm *.pdf or ls *.pdf), how do you do that? The "manual" approach would be cd a, rm *.pdf, or ls *.pdf, cd .., cd b, ... That seems too complicated, so I believe there must be an easier approach.
96219
I was playing around in a shell and typed ./. I go the following output:  bash: ./: Is a directory   It looks like "./" checks if a directory with the given name exist. I was trying to find documentation on this to see if my understanding was right, but can't find anything online. Can anyone explain this one to me?
59061
I know that external commands are run in the shell by creating a separate process, but what exactly happens when a built-in command is run in a shell?  Are they executed as a function,  or does the shell create a new thread to execute them?
74855
On my server I have a directory structure looking something like this:  /myproject/code   I normally have an ssh connection to the server and 'stand' in that directory:  root@machine:/myproject/code#   When I deploy a new version of my code, the code directory is removed so I'm left with:  root@machine:/myproject/code# ./run -bash: ./run: No such file or directory   And the only solution I've found is to cd out and back in:  root@machine:/myproject/code# cd ../code root@machine:/myproject/code# ./run Running...   Can I avoid this? It's a somewhat strange behavior. If you have a nice explanation why this happens I would appreciate it.
18003
I was wondering if the following two ways of running a bash script are equivalent?  . ./myScript.sh  source myScript.sh  Are they both running the content of the script instead of running the script, i.e. not creating a subshell for running the script?
13284
I tried which cd and it didn't give a path but instead returned the exit code 1 (checked with echo $?). The coreutil cd itself is working, so the executable should be there, right? I also ran a find for cd, but there was no executable file shown. How is it implemented then?  Update:  I don't know if I should ask this in another post but since I think it is good here, I'm expanding (?) the post... So the answer was actually quite simple, there's no executable for that — because it's a builtin — But I've found some builtins (bash shell in Fedora) have the executable files! So builtin -> no executable isn't right I suppose? Maybe an answer explaining what builtins actually are (builtin commands?), which actually is the matter here, rather than focusing more on cd... Some good links posted previously indicate that builtins are not programs... so what are they? How do they work? Are they just functions or threads of the shell?