LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-11-2010, 01:43 PM   #1
edgarosy
LQ Newbie
 
Registered: Oct 2007
Posts: 22

Rep: Reputation: 0
Bash script


Hello everyone.

Question for you all...

let's say I have 38 servers. all of my servers hostnames start with abcapp1 abcapp2 ... etc. What is the easiest way to change permissions to 777 on all servers /opt directory at the same time? instead of just login in to each server individually and typing chmod 777 /opt ?

Thanks for your feedback.
 
Old 11-11-2010, 02:09 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by edgarosy View Post
Hello everyone.
Question for you all...

let's say I have 38 servers. all of my servers hostnames start with abcapp1 abcapp2 ... etc. What is the easiest way to change permissions to 777 on all servers /opt directory at the same time? instead of just login in to each server individually and typing chmod 777 /opt ?
Thanks for your feedback.
Depends. If you have your SSH keys swapped between your local machine and your servers, you can just write a simple bash loop to go through until you hit 38, and run a command. Like "ssh username@abcappXX "chmod 777 /opt"". If you use telnet, write an expect script to do it.

However, doing a chmod 777 on /opt is a BAD idea.
 
1 members found this post helpful.
Old 11-11-2010, 02:21 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Well there are plenty of ways to achieve this, personally I would recommend using func from fedorahosted.org which is exactly designed for this, but does require a certain level of configuration to get started. There is also dssh (distributed ssh I think) which does a similar thing with a simpler setup directly over ssh. Also if you install the python implementation of expect, pexpect, there its a very useful demo tool in it called hive.py which again does a similar thing. Finally if you do have ssh keys setup to allow passwordless access already from a central point then you can just do this all with normal ssh and a simple loop in bash.
 
1 members found this post helpful.
Old 11-11-2010, 02:25 PM   #4
goldenbarb
Member
 
Registered: Aug 2010
Distribution: Fedora, Centos, Debian
Posts: 49

Rep: Reputation: 7
Have a look.
And yes, 777 is a really bad idea.
 
1 members found this post helpful.
Old 11-11-2010, 02:26 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
And yes, as above doing a 777 on /opt is a really really bad idea in the first place. There must be a better way.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables and Mkvextract in a bash script and a good resource for bash help? gohmifune Linux - General 9 04-13-2011 09:37 AM
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 05:11 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 07:00 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 08:01 PM


All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration