Changing permissions
As root, how can I change the permissions of a file? I downloaded a file and even root doesn''t have execute permissions!
man chmod
chmod u+x myfile # gives user permission to execute
chmod a+x myfile # gives user/group/others permission to execute
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
chmod u+x myfile # gives user permission to execute
chmod a+x myfile # gives user/group/others permission to execute
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
OK, this is really freaking me out. I don''t know how to run a .sh file from the command line. I have tried running file.sh and file, as well as several stupid ideas, but I have no idea how to run a .sh from the command line. Please help!
February 11, 2004 09:19 PM
You may not have the current directory in your path. In that case I suggest that you try ./filename.sh or provide the full pathname to the file (ie /home/myuser/filename.sh).
./Check.sh gives ": bad interpretor: No such file or directory."
I doublechecked, ls listed the file. It is there.
I doublechecked, ls listed the file. It is there.
Get this straight:
x - execute
r - read
w - guess
Everything in unix is a file, even a directory. If a standard file (a text file, for example) has x bit set, then it can be executed. If a directory has the x bit set, it can list its contents (like
There are three field in a unix file that have permisions set. These are the `owner'', `group'', and `world (aka other)'' fields. If a file has the permision
Now, say that you want the file foo.txt to be readable-writable by the owner of it, only readable by the group, and only executable by the others (world.) You can use
u means the `user'' field, g means the `group'' field and o means `other''.
This is illistraited from the outputs of
Here,
Read the manpage for
I hope that helped. Correct me if I am wrong on the above information.
x - execute
r - read
w - guess
Everything in unix is a file, even a directory. If a standard file (a text file, for example) has x bit set, then it can be executed. If a directory has the x bit set, it can list its contents (like
ls
.) If a standard file has the r or w bit set, it can be written to and read from. If a directory has the r or w bit set, one can create other files (directories or plain files) in it and read the contents of those files.There are three field in a unix file that have permisions set. These are the `owner'', `group'', and `world (aka other)'' fields. If a file has the permision
rwxr-xr-x
, then the first three bits rwx
mean that the user can read, write, and execute the file. The second bit field, the group field, is r-x
and means that anyone in the group that the files belongs to can read and execute it. Same for the `world'' field.Now, say that you want the file foo.txt to be readable-writable by the owner of it, only readable by the group, and only executable by the others (world.) You can use
chmod
for thos. For the above scinerio, you would execute somthing like this:chmod u=rw,g=r,o=x foo.txt
u means the `user'' field, g means the `group'' field and o means `other''.
This is illistraited from the outputs of
ls -l
:-rwxr-xr-- 1 after after 354 Jan 15 16:20 all.sh
drwxr-xr-x 2 after users 5120 Jan 16 01:24 irc
-rw-r--r-- 1 after users 10994 Jan 30 23:14 log
-rwxr-xr-- 1 after users 414 Jan 27 01:29 lowercase.sh
-rw-r--r-- 1 after users 593532 Jan 20 04:47 mail
Here,
after
is the owner of the file mail
and can read and write to the file. Everyone else can only read it. lowercase.sh is a shell script and can be executed by the owner and group, but not anyone else.Read the manpage for
chmod
for more information on how this works.I hope that helped. Correct me if I am wrong on the above information.
Rate me up.
February 11, 2004 10:17 PM
You should also make sure that you are using the right path to the bash interpreter, as indicated in the first line of the file you''re trying to execute
February 11, 2004 10:18 PM
Bad interpreter may indicate that the shell the script was created for is not present on your system. Look at the first line in the script, it may read something like this >>
#!/bin/bash
The #! tells the system to run the script under the bash shell (there are others). If you do not have the appropriate shell installed you will not be able to run the script in question.
Other shells include csh, sh, ksh and so on.
Hope this helps.
#!/bin/bash
The #! tells the system to run the script under the bash shell (there are others). If you do not have the appropriate shell installed you will not be able to run the script in question.
Other shells include csh, sh, ksh and so on.
Hope this helps.
OK, the first line of the script is #!/bin/bash, and yes I do have bash installed, and I went to Shells/bash to start my terminal instance, so I''m assuming I was running bash. I have no idea why it won''t run... Oh, I''m running as root and the permissions are set to -rwxr--r--. Please help me!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement