From owner-freebsd-questions@freebsd.org Mon Feb 22 02:27:11 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5FF6AAF47B for ; Mon, 22 Feb 2016 02:27:11 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D4C21E36 for ; Mon, 22 Feb 2016 02:27:10 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-96-7.dynamic.qsc.de [92.195.96.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id 9062F276A1; Mon, 22 Feb 2016 03:27:02 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u1M2R2kY003929; Mon, 22 Feb 2016 03:27:02 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Mon, 22 Feb 2016 03:27:02 +0100 From: Polytropon To: Yudi V Cc: freebsd-questions@freebsd.org Subject: Re: minimize use of root account Message-Id: <20160222032702.86529bdb.freebsd@edvax.de> In-Reply-To: References: <20160219120503.fc97ef10.freebsd@edvax.de> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2016 02:27:12 -0000 On Mon, 22 Feb 2016 13:07:28 +1100, Yudi V wrote: > Thanks Polytropon. > > based on the answers here looks like the best answer is to use SUDO or > SUPER. A good idea. You need to see if you prefer sudo or super. Both have their individual strengths, but sudo is probably the one you'll find more often. > > > ############### > > > #!/bin/csh -f > > > > Why?! > > > > There's a relevant article: "Csh Programming Considered Harmful" written > > by Tom Christiansen. > > > > https://www-uxsup.csx.cam.ac.uk/misc/csh.html > > > > I have written one (!) csh script and I still regret it, maybe because > > it still works. :-) > > > > On FreeBSD, the default shell script interpreter is /bin/sh. > > > > > I am fairly new to Freebsd and I checked the shell variable before I wrote > the script and as it said CSH, I just went with the csh script. The C shell is the default interactive shell (dialog shell), while /bin/sh is the default non-interactive shell (script shell), which you can see as most system scripts start with "#!/bin/sh". It tends to be more readable and portable than the C shell (which isn't even the best imaginable interactive shell, as many users seem to prefer bash or zsh which can easily be installed on FreeBSD). > I did not > get why the user shell is /bin/sh and the root is /bin/csh. For all users (including root) /bin/csh is the default dialog shell. It's easy to set a different shell using the "chsh" command. The shell to use must be listed in /etc/shells. The more simple /bin/sh is used as dialog shell only in single user mode (maintenance mode) by default. > This is on a personal backup server and only has few scripts. I dont want > to readup on yet another shell scripting (someone in the forum mentioned > that /bin/sh is Almquist's Shell NOT bash). That is correct - it's "ash" (Almquist's Shell), which is a close re-implementation of the traditional Bourne Shell; bash is the Bourne Again Shell (common in Linux) which can be seen as a superset of the Bourne shell. So bash usually executes sh code, and sh code tends to be the most reliable and portable. > I am just happy if they work as intended. If the server was > meant for anything else I will definitely not use csh scripts. As I said, I'm guilty myself of writing one csh script which is still in use and still works, even though is so full of bullshit it should go into /dev/null. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...