473,573 Members | 5,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting file permissions on a web server

I always read about how you need to set certain file permissions (for
cgi files, for example), but it's never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this? Is this done on your personal system, or on
the server? What if you are using Windows? If it's done on the server,
how do you do it?

The only way I've figured out so far how to do this is to upload my cgi
files to my server, then within my FTP program I right-click the file
and change its permission number that way, but that seems an inefficient
way to do it, especially having to do it each time.

Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically? Or do certain editors
allow you to save files with a predetermined permission?

Aside from my right-clicking method, I don't know how else to do it.
Apr 30 '06 #1
10 2601
John Salerno:
I always read about how you need to set certain file permissions (for
cgi files, for example), but it's never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this?
This is a Unix/Linux command. You run it in a shell login on the server
(e.g. in Putty, SecureCRT, or some other ssh client you're using).
Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically?


Not in the script itself via cgi of course, because it needs certain
permissions before it can be run as cgi script. But you could put the
command in an installation script that installs the cgi script.

--
René Pijlman
Apr 30 '06 #2
> I always read about how you need to set certain file permissions (for
cgi files, for example), but it's never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this? Is this done on your personal system, or on
the server? What if you are using Windows? If it's done on the server,
how do you do it?

The only way I've figured out so far how to do this is to upload my cgi
files to my server, then within my FTP program I right-click the file
and change its permission number that way, but that seems an inefficient
way to do it, especially having to do it each time.

Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically? Or do certain editors
allow you to save files with a predetermined permission?

Aside from my right-clicking method, I don't know how else to do it.


I guess this would be a good starting point:

http://www.linuxcommand.org/man_pages/chmod1.html

In short, chmod refers to local files so wherever you run it it will
refer to files on that machine. You run it simply by typing it in a
shell as a user who has privilage to perform the operatation, which
can mean you have to be an owner of the file but if you are root you
can do it in any case. Depending on your ftp, scp, http or whatever
method you use to transfer files the file permissions may or may not
change during the transfer. If permissions are kept intact you can
chmod on your local machine and then transfer, if they are not then
you transfer first and chmod on the server. When you transfer files
from a windows machine to *nix it again depends on the particular
method you choose how the permissions will be set.

There is no way of putting this permission information into the file
itself but some (most?) editors can be set to save the file with a
permission of your choice.

Hope this helps.
Apr 30 '06 #3
Daniel Nogradi wrote:
In short, chmod refers to local files so wherever you run it it will
refer to files on that machine. You run it simply by typing it in a
shell as a user who has privilage to perform the operatation, which
can mean you have to be an owner of the file but if you are root you
can do it in any case. Depending on your ftp, scp, http or whatever
method you use to transfer files the file permissions may or may not
change during the transfer. If permissions are kept intact you can
chmod on your local machine and then transfer, if they are not then
you transfer first and chmod on the server. When you transfer files
from a windows machine to *nix it again depends on the particular
method you choose how the permissions will be set.


Thanks, but I'm still a little confused. Since I'm running Windows, I
assume that I can't run the chmod line on my own computer. My web server
uses Unix, but is it possible for me to have access to a command line
for the server? I didn't know that was possible for basic web hosting
plans (I'm using 1and1 right now).

I suppose I could write a script that would set the permissions of all
the files in a particular folder on my computer to 755, but is there a
Windows equivalent command for chmod to do this? Or am I stuck having to
do it on the server side?
Apr 30 '06 #4
> I suppose I could write a script that would set the permissions of all
the files in a particular folder on my computer to 755, but is there a
Windows equivalent command for chmod to do this? Or am I stuck having to
do it on the server side?


The chmod has to be executed on the machine the file resides on - aka
the server. If your plan includes a ssh-account you can use that.
Otherwise you might be able to create an ftplib-based script that will
automate this over ftp.

Diez
Apr 30 '06 #5
> > In short, chmod refers to local files so wherever you run it it will
refer to files on that machine. You run it simply by typing it in a
shell as a user who has privilage to perform the operatation, which
can mean you have to be an owner of the file but if you are root you
can do it in any case. Depending on your ftp, scp, http or whatever
method you use to transfer files the file permissions may or may not
change during the transfer. If permissions are kept intact you can
chmod on your local machine and then transfer, if they are not then
you transfer first and chmod on the server. When you transfer files
from a windows machine to *nix it again depends on the particular
method you choose how the permissions will be set.
Thanks, but I'm still a little confused. Since I'm running Windows, I
assume that I can't run the chmod line on my own computer.


Correct, chmod is a *nix command.
My web server
uses Unix, but is it possible for me to have access to a command line
for the server?
This depends on your arrangements with your web server provider.
Perhaps you are allowed to ssh into that machine, perhaps not, you
need to ask your provider. In case you can use ssh, then you can log
in with putty (an ssh client for windows, grab it from here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/) and you will have
a command line on the server so you can run chmod there.
I didn't know that was possible for basic web hosting plans (I'm using 1and1 right now).
I have absolutely no experience with public web hosting but I guess
some might provide ssh-ing possibilities although I imagine most
don't.
I suppose I could write a script that would set the permissions of all
the files in a particular folder on my computer to 755, but is there a
Windows equivalent command for chmod to do this?
I have next to zero experience with windows but as far as I know
windows doesn't have file permissions at all (anyone, please correct
me if I'm wrong :)) so in windows land it doesn't make any sense to
"change file permissions". Even if it has some sort of a notion of
file permissions I wouldn't know how that gets translated into unix.
Or am I stuck having to do it on the server side?


I guess so. But that's not a terribly big problem even if you can't
use ssh. What I would do is write a script (in python of course :))
that does the file permission changing and run that script over the
web. Since this can have serious security implications my strategy
would be to place this script somewhere which is not reachable through
the web and only relocate it to a web accessible directory when you
want to run it over the web, and when you are done, you place it back
to its secure location so nobody can reach it. You can find out how to
write this script from http://docs.python.org/lib/os-file-dir.html

HTH :)
Apr 30 '06 #6
John Salerno wrote:
Thanks, but I'm still a little confused. Since I'm running Windows
You misplaced your period, it goes at the end of that line. ;)
assume that I can't run the chmod line on my own computer.
Sure you can, install cygwin. chmod only affects files on your computer,
and won't alter the Windows permissions (which use a different scheme), but
you can do it.
My web server
uses Unix, but is it possible for me to have access to a command line
for the server? I didn't know that was possible for basic web hosting
plans (I'm using 1and1 right now).
It is entirely possible (indeed, I don't know how most things would ever get
done without it). Most basic hosting plans however don't provide shell
access.
I suppose I could write a script that would set the permissions of all
the files in a particular folder on my computer to 755, but is there a
Windows equivalent command for chmod to do this? Or am I stuck having to
do it on the server side?


1. Settings permissions on your computer won't do a thing.
2. There's probably a Windows-equiv of chmod for your own files, but it
won't affect files placed on another machine.
3. You're stuck having to do it on the server side. Now a good ftp program
can automate this for you, but it's still your job, not the servers.

These sound like good questions for your hosting provider, or failing that,
google.

Apr 30 '06 #7
Daniel Nogradi wrote:
I have next to zero experience with windows but as far as I know
windows doesn't have file permissions at all (anyone, please correct
me if I'm wrong :)) so in windows land it doesn't make any sense to
"change file permissions".
Actually Windows has a quite good permission scheme, with full owner/group
ACLs and granular permissions for read, write, append, delete, and several
others I can't recall. The problem is no one uses them much. The
manipulation tools are a pain, and developers routinely ignore them
(including Microsoft's own developers, although I hear they've gotten much
better lately).
I guess so. But that's not a terribly big problem even if you can't
use ssh. What I would do is write a script (in python of course :))
that does the file permission changing and run that script over the
web. Since this can have serious security implications my strategy
would be to place this script somewhere which is not reachable through
the web and only relocate it to a web accessible directory when you
want to run it over the web, and when you are done, you place it back
to its secure location so nobody can reach it.
You're right about the security concerns, but your solution sounds like more
trouble than it's worth. With a bit more effort, you could write a local
python script that acts as an ftp client and applies permissions remotely.
But why bother when a good ftp client already has that built-in (and is
much less likely to contain destructive bugs).
You can find out how to
write this script from http://docs.python.org/lib/os-file-dir.html


You're worried about security and you turn a novice with a scripting
language loose in the briar patch of unix permissions, on a remote server
no less? And I thought I was sadistic! :)

Apr 30 '06 #8
Daniel Nogradi wrote:
I have next to zero experience with windows but as far as I know
windows doesn't have file permissions at all (anyone, please correct
me if I'm wrong :)) so in windows land it doesn't make any sense to
"change file permissions". Even if it has some sort of a notion of
file permissions I wouldn't know how that gets translated into unix.


This is getting a little off-topic, I admit, but the NT-derived versions
of Windows do indeed have file permissions. The Windows-equivalent of
chmod (and chown) is cacls ("Change Access Control Lists"):

http://www.ss64.com/nt/cacls.html

In essence, each file has an owner and a list of other users and groups,
who may each have "Full control" (meaning they can change permissions),
read-only, write-only, read-write, or no access.

Windows 95 and its descendants don't have permissions any more than DOS
does. (Except with respect to Windows network file-sharing.)

(Heh, I checked just before posting this and someone beat me to it.
Here's my post anyway.) :-)

-Kirk McDonald
Apr 30 '06 #9
Daniel Nogradi wrote:
This depends on your arrangements with your web server provider.
Perhaps you are allowed to ssh into that machine, perhaps not, you
need to ask your provider. In case you can use ssh, then you can log
in with putty (an ssh client for windows, grab it from here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/) and you will have
a command line on the server so you can run chmod there.


Turns out that my web hosting company provides ssh access on the next
highest plan and up, but not mine. :)

Oh well, I think I'll explore FileZilla a little more and see if there's
more of an automated way to do it than just right-clicking each file (or
even right-clicking multiple files at once, if possible). It shouldn't
be too big of a deal anyway, but I'm always after more automated ways to
do things...call me lazy! :)
Apr 30 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2321
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company 1&1 with only limited server configuration via a web based control panel. My query relates to the ASP security model and how it relates to...
2
3927
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company 1&1 with only limited server configuration via a web based control panel. My query relates to the ASP security model and how it relates to...
1
3402
by: AlunBoyd | last post by:
Quick Question. Is it possiable via a ASP to set (NTFS) permissions on files not on the IIS server? I'm sticking together an ASP to create our new user Home/Profile dir file structure. The script is running in anonymous user mode using an account which has full perm on the file severers. It's creating the file structure OK, but when it...
9
3010
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions to do this? (I use public host) Thanks!
3
1536
by: Rich Rekos | last post by:
Does anyone know how to set file permissions via asp.net? I have a page that allows me to upload files, but I want to be able to set the permissions on the file after I upload it. Any ideas? Thanks, Rich *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
6
1139
by: Scott M | last post by:
I would like to create the shell dialog box that opens the search box that allows a user to search for groups, users and or computers on a local machine of on a domain (Like choosing domain users when setting file permissions). Does anyone have a nice .Net wrapper that I can use to accomplish this or know where I can find it online? Thanks...
1
1638
by: Fredo | last post by:
I know very little about java and javascript, and I'm not really sure if this is a java or javascript issue. I'm trying to run an app call jmol in a local browser. jmol is activated by a javascript, but I'm pretty sure it's running a java app since the java icon is in my system tray (Windows, obviously). The problem I'm having is jmol...
0
1460
by: Ian Toltz | last post by:
I'm working on a program for creating user accounts. I'm having issues with setting the permissions. Here's an example: String homeDir = @"\\SERVER\directory\"+username; //Create the directory Directory.CreateDirectory(homeDir);
4
10540
by: Tony B | last post by:
I've moved an existing site (which I didn't write) from a apache/php/mysql host under windows to a linux apache/php/mysql host. I've sorted out most problems except one. There is an upload function on the site, which uploads files via POST to temp folder and then moves it into a folder on the host using php function move_uploaded_file. Under...
0
7792
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8218
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8091
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6435
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3744
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.