Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Modify bash_profile to set permissions automatically  (Read 6171 times)

0 Members and 1 Guest are viewing this topic.

UnixKid

  • Guest
Modify bash_profile to set permissions automatically
« on: March 01, 2012, 10:47:25 PM »
Hey all -

Running Fedora Core 11 here. I'm editing my .bash_profile so it will execute the following:

alias "chmodWeb"="chmod ugo-rwx *.* | chmod u+rwx *.* | chmod o+rx *.*"

Theoretically, this should take all files and folders within a given directory and change the permissions as follows:

u: rwx
g: ---
o: r-x

However, when I run this, it's.... strange. I have yet to get anything consistent from this. Sometimes it changes the permissions of one out of four files to rwx------, sometimes it changes all of them to ------r-x. Can someone help me figure out what is going on and how to fix it? If you've got another idea for quickly changing permissions to rwx---r-x via command line without installing additional software, I'm all ears. Well, eyes, in this case.

Thanks!

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Modify bash_profile to set permissions automatically
« Reply #1 on: March 14, 2012, 05:38:51 AM »
Why are you using the pipe symbol?  Did you mean ';' instead of '|'?
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

UnixKid

  • Guest
Re: Modify bash_profile to set permissions automatically
« Reply #2 on: March 14, 2012, 12:05:34 PM »
Why are you using the pipe symbol?  Did you mean ';' instead of '|'?

I want them to execute the commands with one command, not three. The whole idea is to simplify setting permissions for web pages.

The problem is it seems to want to execute all sessions at the same time, rather than in order. I tried using ';' instead of '|', and I got the same results. What is the difference, in theory, between ';' and '|'?

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Modify bash_profile to set permissions automatically
« Reply #3 on: March 22, 2012, 05:01:12 AM »
Pipe takes the output of the command to the left of the pipe and sends it as input to the command to the right of the pipe.

I really don't think you want to execute these commands simultaneously.  If for example the first command happened to run a millisecond after the second and third commands, you'd just end up undoing the effects of the latter commands.  (Think about it.)

Anyway, as it happens, the Gnu version of chmod can do all this in one command, so how about this instead:
Code: [Select]
alias chmodWeb="chmod g-rwx,u+rwx,o+rx *"
The ".*" is redundant in Linux/Unix.  You're thinking of Windows/DOS.
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

UnixKid

  • Guest
Re: Modify bash_profile to set permissions automatically
« Reply #4 on: March 26, 2012, 01:28:35 AM »
Pipe takes the output of the command to the left of the pipe and sends it as input to the command to the right of the pipe.

I really don't think you want to execute these commands simultaneously.  If for example the first command happened to run a millisecond after the second and third commands, you'd just end up undoing the effects of the latter commands.  (Think about it.)

Anyway, as it happens, the Gnu version of chmod can do all this in one command, so how about this instead:
Code: [Select]
alias chmodWeb="chmod g-rwx,u+rwx,o+rx *"
The ".*" is redundant in Linux/Unix.  You're thinking of Windows/DOS.
This worked. Thanks a ton!

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Modify bash_profile to set permissions automatically
« Reply #5 on: March 26, 2012, 06:09:15 AM »
You're welcome.  :)
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos