What Exactly Is PATH

books say that PATH variable contains the locations where the shell searches the commands to execute them.

I created a shell script and saved it in /home/user/Downloads directory and then i ran this script from the /home/user/Downloads directory. It did not execute.

however when i did set the path
export PATH=$PATH:/bin/sh within /home/user/Downloads directory, the shell script executed. Does it not mean that PATH variable is holding the locations of the shell program rather than the commands that are to be executed?

everytime i have to give the location of the shell i.e /bin/sh in the PATH variable no matter from where i am executing my script


Similar Content



Is There A Way To Have A Script Called Source, That Can Be Run Without The Full Path?

Is there a way to have a script called source, that can be run without the full path?

Ex:
When I run:
export PATH=/home/user:$PATH
source

I get:
Code:
$ source
bash: source: filename argument required
source: usage: source filename [arguments]

However I want it to run my script called source:
Code:
$ cat source 
#!/bin/bash
echo "Hello World"

Is there way to override a shell builtin in the PATH var or some other way?

Bash Shell Scripting Need Help Figuring Out Process For Homework - JUST WANT DIRECTIO

Ok yes this is a homework assignment BUT I am NOT looking to have the answers given to me. I am in the 6th week of my first Linux class ever and we are in our few weeks of beginning scripting. I have some ideas of what to do or where to start but not many and no one to bounce any ideas off...we are using UNIX Bash shell so any others I have no clue. The scenario is that I need a script that searches all my users home directories for bad words. I need the script to report to the screen certain info like username and word found and path. It should ask a user if it is good or bad and if bad be put into a file of list of bad file names, if good remove from list and no longer flagged by the script. What I have so far is wanting to somehow do a loop. I do know that if I do a grep -r -e kill -e steal /home/* I get a list of what I need. I also know that the list is separated by delimiters which I can pipe to get a variable for the things I need. I also know that I can put it to a file with a > filename.txt

What I have no clue is how to start a loop that would do this...

for each line in filename.txt
UNAME=...
LOC=...
TXT=...
echo "Username: $UNAME, Line with bad word found: $TXT, and Path and file name: $LOC. Is this a BAD file? (Y)"
Read YORN

if ["$YORN" = "Y" ]; then
>> (line of text from grep) badfiles.txt
fi

Next or whatever goes there...sorry if this is crazy I just really need some direction. I am trying to learn so please don't give me the answer...that will do nothing for me and I will not be able to explain the code I came up with.

Path To My Script

Stupid question, i know, but what is the correct path to run a script from root that is located in /home?
screen -dmS bungee /home/sh bungeestart.sh >> /home/spigot.out
I have this but is doesn't work....
This is done via crontab at reboot...

User Permitted To Run Command,execute Program As Root And After Execution, Exit Root

when a command is typed(i.e. /path/to/the/program), as a normal user, he should be able to run that command , execute that program as ROOT and log out root after the execution is completed.
Only one user should be able to do it.
Hence, I have created a new user vj and added the following command in visudo:
Code:
vj ALL=(ALL) NOPASSWD: /path/to/the/program

Now user vj will be able to typein the command.

What I need is that the program which is been called must run as if it is run by a root user,and when the program is completely executed, exit the root user.

How do I proceed?

Executable Not Found From /usr/local/bin

Hi,

I installed ghostscript via yum package manager. Later I wanted a newer version of ghostscript and compiled it from source. "make install" placed the gs executable file under /usr/local/bin/gs. This works if I run the command with absolute path, but if try to run gs, the shell will output

"-bash: /usr/bin/gs: No such file or directory"

if I echo the path variable it will display

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin

If i run whereis it will give me the correct path
gs: /usr/local/bin/gs

How do I make it work so that typing "gs" will run the executable file from the /usr/local/bin/gs?

(I am using Centos 6)

Thanks.

Shell Scripts

I am taking a Linux class and am doing horribly, I just do not understand Linux. Can anyone please tell me how to create a shell script containing the `echo`, `whoami`, `groups`, and `pwd` commands?

I can do these as individual commands but cannot figure out how to do this in a shell script and get the output to produce output similar to the following:

You a
root
You are a member of the following groups:
root bin daemon sys adm disk wheel
Your current working directory is:
/tmp

My hair is getting thinner and grayer because of this.. Please help!

Rmdir -r

hi guys, im trying to get rid of a non empty directory. i have researched it online and it basically says that the command would be sudo rmdir -r filename
it keeps coming back with invalid option for r

what am i doing wrong?

the directory is in the home directory along with the documents, videos, download etc and i am in the home directory. i tried putting a text file there to make sure i am in the right path and it deleted it with rm so the path is correct.

i understand that i can do it with the gui but im trying to learn the terminal for the next forty years.

any suggestions would be greatly appreciated.

SFTP Shell Script

Hi,
I am looking for a simple shell script that allows for sftp to be run from the server to another server (Windows). I would like the script to be passed parameters suchas destination server, Id, password, Directory structure/folder name, file name etc...
Need some help to know how to start with and it would be great if someone help me with any sample sftp shell script

Need Help On Shell Script..

I have serveral nodes related files under /var/lib/ directory as shown below:

Code:
machine001.cluster.org 
machine002.cluster.org
machine003.cluster.org
machine004.cluster.org

I am trying to write a shell script which first finds out how many number of files are present in this directory. Then it should fetch the first name like machine001, machine002, machine003 etc. Then it should fetches ipaddress, hostname and netmask under machine001 first, then store it in some variable. Repeat this for all the nodes. How will the script look like?

Sending SMB Client Commands Through Shell Script

Hello.

I have a shell script, which I am using to access the SMB Client:

Code:
#!/bin/bash
cd /home/username
smbclient //link/to/server$ password -W domain -U username
recurse
prompt
mput baclupfiles
exit

Right now, the script runs, accesses the server, and then asks for a manual input of the commands.

Can someone show me how to get the commands:
Code:
recurse, prompt, mput baclupfiles and exit

to be run by the shell script please?