Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Tuesday, September 18, 2012

ddns: a Dynamic DNS updater for Namecheap

For any Mac/Unix/Linux users out there, I've created an extremely lightweight dynamic DNS client I'm calling ddns. The current version is 0.82.
  • Only works with Namecheap's DDNS service, which is free. For information on how to set that side up, visit my post here
  • Updates the A Record (DNS zone) of your choice with your current IP
  • Written in bash and requires curl and awk, which most distros have. I've tested it on a Mac, but should work on any *nix system
  • Works in a cron job or as a one-time run, and logs successes or failures
  • No known bugs, but please email me at ddns@lotsaoxen.com if you find any!

Download ddns 0.82 here.

Download sample config file here.


If you download the client and use it, please feel free to comment here with suggestions, issues, and such. I can't promise to be able or willing to fix everything, but I'm interested in feedback.
Saturday, May 5, 2012

How to enable the root account login on OS X and other Unix and Linux systems

For security reasons, many Unix and Linux systems, including OS X and Ubuntu, install with a locked or disabled root account by default, with no password (not to be confused with a blank password). As such, it isn't possible to log directly into root shell or use su. Instead, the default user is given administrator access. That being said, below are three ways I found to access the root shell in the rare case it may need to be done.

Note: This presupposes the user already has administrator/superuser rights. Because of this, for most users the root account does not generally need to be enabled.

  • The following will open an sh or bash process with full root privileges: sudo sh sudo bash
  • The following will log you in with full root privileges: sudo su - If one runs su alone, it will prompt for the root password, but with sudo first it instead prompts for the current user's password. The dash at the end loads the root user environment.
  • The following sets a password for the root user, thereby enabling normal login for root: sudo passwd root On some systems, OS X not included, the following will reverse the last command, both disabling the root login and removing its password hash: sudo passwd -dl root
Some systems, including OS X, also have a special command, dsenableroot.
  • To enable root login: dsenableroot
  • To disable root login: dsenableroot -d


For more information:
  • Apple's official instructions for various versions of OS X using the GUI to enable root can be found here.
  • Ubuntu's site has a great article on various uses and misconceptions about sudo and root, as well as a few useful tricks, that can be found here.

How to solve "sudo: cannot get working directory" error

Periodically, you may get the following error:
sudo: cannot get working directory
This error means that the directory you are supposedly in no longer exists. You can fix this by simply moving to a different directory, i.e. your home:
cd
Friday, November 5, 2010

How Make a Shell Script Run in Snow Leopard

When trying to run a new shell script in bash, you may get the following error:
-bash: ./samplescript: Permission denied
Navigate to the file and type the following:
sudo chmod u+x samplescript
You should then be able to run said file by typing this:
./samplescript

How to Change the Default Command Line Editor in Snow Leopard

These are instructions to change your default command line editor in Snow Leopard.

  1. Create or edit a file in your home directory called .profile (make sure you include the ".") using TextEdit or the editor of your choice. Note that files beginning with a period are invisible in Finder, so to use TextEdit you may have to open it with Terminal using the following command:
    open ~/.profileIf you get the following error, the file does not yet exist and needs to be created:
    The file /Users/randomuser/.profile does not exist.
  2. Add one of the following lines to the file based on your preferred editor:
    • emacs:
      export EDITOR=/usr/bin/emacs
    • vi:
      export EDITOR=/usr/bin/vi
    • TextEdit (may have side effects):
      export EDITOR=/Applications/TextEdit.app/Contents/MacOS/TextEdit