2017
Add sudo user in Ubuntu
15/06/17 18:48 Filed in: Devops
The sudo users are granted with administrator privileges to perform administrative tasks. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server's sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.
Steps to Create a New Sudo User. Be sure to replace server and user name with your name.
Log in to your server as the root user.
$ssh root@SERVER
Use the adduser command to add a new user to your system.
$adduser username
Set and confirm the new user's password at the prompt. A strong password is highly recommended. Set password prompts:
$Enter new UNIX password:
$Retype new UNIX password:
$passwd: password updated successfully
Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.
$Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Use the usermod command to add the user to the sudo group.
$usermod -aG sudo username
Test sudo access on new user account. Use the su command to switch to the new user account.
$su - username
As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
$sudo command_to_run
For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
$sudo ls -la /root
The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed.
Output:
[sudo] password for username:
If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.
Steps to Create a New Sudo User. Be sure to replace server and user name with your name.
Log in to your server as the root user.
$ssh root@SERVER
Use the adduser command to add a new user to your system.
$adduser username
Set and confirm the new user's password at the prompt. A strong password is highly recommended. Set password prompts:
$Enter new UNIX password:
$Retype new UNIX password:
$passwd: password updated successfully
Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.
$Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Use the usermod command to add the user to the sudo group.
$usermod -aG sudo username
Test sudo access on new user account. Use the su command to switch to the new user account.
$su - username
As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
$sudo command_to_run
For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
$sudo ls -la /root
The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed.
Output:
[sudo] password for username:
If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.
Setting up Go development environment
02/03/17 21:39 Filed in: Programming | Golang
Go is fast growing programming language, so I thought it would be helpful to show how to setup and run Go programs on your machine. The instruction is for Mac OS X. Homebrew is required. If you don't have home-brew in your local environment, follow this link to setup home brew in your Mac development environment.
https://brew.sh/
$ brew install go
In order to run Go within your terminal, you’ll need to setup the GOPATH environment variable. This will allow Go to properly locate your workspace in order to run your code and manage your packages. I have my workspace "code" inside my home directory. ($HOME/code") and or Golang I have in $HOME/code/go. I'm using bash profile to setup GOPATH.
1. Edit ~/.bash_profile.
2. Add following lines to bash_profile
export GOPATH="$HOME/code/go"
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
3. I.e. source .bash_profile file or close and open terminal.
$ source ~/.bash_profile
After the setup when you type go you should see as below.

https://brew.sh/
$ brew install go
In order to run Go within your terminal, you’ll need to setup the GOPATH environment variable. This will allow Go to properly locate your workspace in order to run your code and manage your packages. I have my workspace "code" inside my home directory. ($HOME/code") and or Golang I have in $HOME/code/go. I'm using bash profile to setup GOPATH.
1. Edit ~/.bash_profile.
2. Add following lines to bash_profile
export GOPATH="$HOME/code/go"
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
3. I.e. source .bash_profile file or close and open terminal.
$ source ~/.bash_profile
After the setup when you type go you should see as below.
