How to do an svn checkout with a different username

Subversion
Image by Wikipedia – Fair use licence

The other day I had to do an svn checkout from an Amazon Web Services (AWS) instance and, of course, my user name on SVN was different from the user name on the AWS instance  which is by default ec2-user.  So how to do a checkout from a Subversion repository and specify at the same time the SVN user who is performing the checkout? Subversion has a handy username parameter,  here is the full command with some dummy output.

You will be asked to enter your SVN password and if you want to store your password unencrypted. I suggest to select no for the latter for security reasons but this means that you will need to provide the SVN password every time you perform an SVN command.

How to install Groovy on Linux system-wide

Groovy Logo
Image by Zorak1103 – CC BY-SA 3.0

(see section UPDATE at the bottom of the post to install Groovy using sdkman)

A colleague of mine recently asked me to install the Groovy programming language on our Red Hat 6.5 server and to make it accessible to all users. I thought it would be a very straightforward task but a quick search on the Red Hat 6.5 official repositories didn’t return any package for Groovy.

The easiest way to install Groovy manually is via gvm. I followed this  procedure to do it:

  1. Log in as root

2.  Retrieve the gvm install script and store it in a temporary file

3. Make the temporary file executable

4. Run the install script

5. Complete the installation as requested at prompt

6. Check that gvm is installed (this should return the help message explaining how to use gvm)

7. Remove the temporary install script

8. Install groovy via gvm

9. Select the current version of groovy as default (at the time of writing version 2.4.3)  and check that groovy is installed

10. Create a symlink to use groovy system-wide

11. Exit the root user

12. Check that groovy is installed system-wide

 

UPDATE:

Recently I had to install groovy on other Linux systems and discovered that that it is now much easier using sdkman, which is the evolution of gvm. This is the procedure to follow:

  1. Make sure you have Java installed by running:

If you don’t have Java, follow these instructions to install the default JRE/JDK or Oracle JDK.

2.  Install sdkman and set it up:

3. Check that sdkman is correctly installed:

4. Install groovy:

5. Check that groovy is correctly installed:

 

Happy grooving!

How to change timezone on a Linux server

Time Zone
Image by deckhand – CC BY-NC-ND 2.0

Every year in March and in October the clock changes in most countries for energy saving purposes. This has the annoying effect of messing up the current time on your server if the timezone is not set properly. Servers in Europe are often set up to UTC time. For example my web hosting provider explicitly says:

Note that any times specified are executed in the timezone of the server, and not your local timezone. Accordingly, you may need to make allowance for this when selecting when to run your cron job. Our servers run in the ‘UTC’ timezone because our client base is global, and it remains constant throughout the year with no changes for daylight saving.

This is a bit annoying for cron jobs as you need to do some calculations in case you want to run them at a specific local time.

Even if you don’t have sudo rights on your server, you can at least modify the time for a given user. For example, to change the timezone for the current user to a local time (e.g.  Europe/London)  run the following command and add it to your bash_profile to make the change permanent:

If you have full control on your server, you can change the timezone system-wide by symlinking /etc/localtime to the appropriate file in /usr/share/zoneinfo. For example, to set the timezone system-wide to the local time in Paris:

If you run Red Hat/CentOS, you may also need edit /etc/sysconfig/clock in a similar way.

How to add a new user with sudo rights

Sudo Sandwich
Image by xkcd – CC BY-NC 2.5

Let’s say you have a new user needing sudo access to a Linux server. How do you grant him/her this great privilege? First, explain to the new user that sudo rights allow to do pretty much anything on a Linux machine – including screwing everything up! – and that with greater power also comes  greater responsibilities. Then, follow this procedure:

1. Open the command line

2. Create a new user (e.g. newusername) and add it to group wheel (members of this group have sudo rights):

3. Set up the password for the new user. First, login as root:

Then set the password for the new user (e.g. newusername):

Finally exit from root with:

4. Test the newly created user and password by logging in as user newusername:

5. Test that the newly created user is in group wheel: