How to change the Hostname in Ubuntu

There are times you may come up with a need for change in your computer’s identity over network. This is when you will have to change the Hostname of your computer. The hostname is pretty much like a label to your computer or the device for identification over the network. The hostname can be just a simple name, an IP Address or even a domain name.

To change the hostname in Ubuntu, follow these simple steps:

1. Find out your existing hostname by entering this command in terminal:

hostname

hostname ubuntu

So on my computer, the hostname is “santhosh-desktop”

2. Change the hostname by editing:

sudo nano /etc/hostname

You will see the existing hostname. Change it to whatever new hostname you want and save it by hitting Ctrl + O

In this tutorial, I change it to

gigacore-desktop

3. Now edit the hosts:

sudo nano /etc/hosts

Here change the ::1 and 127.0.1.1 to the new hostname you chose.

::1 gigacore-desktop localhost6.localdomain6 localhost6
127.0.1.1 gigacore-desktop

3. Restart the hostname service.

sudo /etc/init.d/hostname restart

Now check the hostname by following the step 1 and you should see the new hostname.

Category: Linux | Comments Off on How to change the Hostname in Ubuntu

Setting Up WiFi Connection Using WiCD

WiCD Logo

Often times Linux users find themselves wanting more from the network manager, especially laptop users on the move find it difficult to manage all the different networks they have access to. WiCD is one of the best tools for people wanting more. It’s gtk based network configuration tool, especially meant for wireless networks written in python. Apart from being dependent on gtk, it does not require any of gnome components to work. Rejoice all the openbox and fluxbox users.

Here’s what WiCD can do (taken from the official documentation),

Compatible with standard *nix networking commands (iwconfig, ifconfig, etc)
Once configured, will connect even if the X display does not start
Can be managed and configured via the command line using wicd-curses
Support for wired networks, as well as named profiles to save multiple wired configurations.
Supports configuring static IP addresses and DHCP on a per network basis
Store different static IPs, gateways, subnet masks, DNS server addresses per network
Automatically connect at boot – no user intervention required, even for encrypted networks
Keeps network keys in root accesible only (600) files (unencrypted, however)
Encryption (template based)

WPA 1/2
WEP
LEAP
TTLS
EAP
PEAP

Automatically connects at resume from suspend
Displays information about the network
Ability to run scripts before/after connecting/disconnecting

All this and it’s really easy to use. Let’s start by installing WiCD, if you are an Ubuntu user, you can install WiCD very easily. All you need to do is open a terminal and issue following command,

sudo apt-get install wicd

This will install both WiCD with all the required dependencies. It will then ask you for the users you want to configure WiCD for. WiCD also comes with a tray icon. You can add it by right clicking a panel and choosing add to panel option then choose custom application launcher. Give it any name you want and in the command box type,

/usr/bin/wicd-gtk

and you will have a tray icon now. Open WiCD and you will be greeted with a screen showing all the wireless networks in the range. You can then chose to connect to any network you want. If the network is protected by any security then you would have to chose the method of security in place and enter the correct key to connect to the network.

WiCD Networks

WiCD Networks

You, of course, also get the option to chose whether to use DHCP or static IPs, which DNS you want to use, which secondary DNS you want to use. gateways, subnet masks. You can also use it to manage wired networks.

WiCD Advanced

WiCD Advanced

And there’s more…

WiCD Advanced 2.0

WiCD Advanced 2.0

I for one have never had any problems with WiCD., although there are people who report certain incidents, it’s free from most major bugs and is a very solid program. One of my favourite distributions, Zenwalk, comes with WiCD pre-installed. Rest assured, this is a great tool to manage all your moving connection needs.

Category: Linux | Comments Off on Setting Up WiFi Connection Using WiCD

How to generate strong passwords in linux

passwordHow many times have you bothered about creating a strong password to your account? Be it an email account, server login, ssh or anything and everything that requires authentication. Usually, people create passwords that are easier to remember. But there are cases like database account, ssh accounts and other sensitive type of accounts where you need to create a password that is strong enough to resist any kind of password decryption methods used by hackers. Generating a password so strong can make you go bonkers. So you need something that generates a strong password automatically that is easier to remember as well.

Say hello APG.

It stands for Automated Password Generator. And as name suggests it is tool used to generate random passwords. APG houses two password generation algorithms. One is the Pronounceable Password Generation Algorithm (default) and the other is the Random Character Password Generation Algorithm. While the first generates strong passwords that are easy enough to remember since it provides you some clues on how to remember it, the latter just generates random passwords.

Installing APG

APG is literally available for any *NIX based operating system. In this tutorial, I will tell you how to install it on Ubuntu / Debian and Fedora / CentOS linux operating systems.

In Ubuntu:

In your terminal –

sudo apt-get install apg

In Fedora:

yum install apg

Using APG

Using APG is really simple. Let’s begin with simple password generation that is easy to remember and pronounceable, which is default. It will generated 6 passwords by using the random keyboard data you provide.

In your terminal,

apg

APG will then prompt you to input some random data so that it can generate a password for you (eg. I like noob2geek.com). Do remember that these passwords will be generated randomly no matter who many times you provide the same keyboard input. So passwords won’t be the same every time. And as you can see the bracket, it provides a pronounceable clue to remember them.

OkBazCag4 (Ok-Baz-Cag-FOUR)
TabOgUt6 (Tab-Og-Ut-SIX)
novtarsEst7 (nov-tars-Est-SEVEN)
bowebcojCal5 (bow-eb-coj-Cal-FIVE)
AbrIbgan2 (Abr-Ib-gan-TWO)
eikkotVis0 (eik-kot-Vis-ZERO)

Now to generate random passwords that are not pronounceable, you need to use the -a 1 option. Where -a is the Algorithm and 1 selects random mode.

apg -a 1

This do not require any random keyboard inputs.

%l?b`m^,
OS6}C>kwZn
RI9]VZ.Hk
/1}mYh5)
[>b/s~1:Y
‘*aST9″bZ

And finally to create a password that is really strong, really long (upto 63 characters) and really hard to break it, you need to make use of more options.

apg -s -a 1 -m 63 -n 4

This actually prompts you to enter some random inputs, but just hit “ENTER” key again to output the password.

}_B^kA#!c[g*8utG8″3S|2aHfP(~I_n|r8KEn”Uxq,[wtoSDYNx{K,0q:cXD619
lkSPcTbsP:>_AfQQP-gM)pI”6LXp-8}E0S*B[@jCY(6.X0j]%^9H`NN8e,,X&TH
bG05%ZF4n*ayxl-Rj5~6tV~zqPk6>d+c]_WCS4&sr7Eeq7!n?M2LpXUqjl7/[P.
B^U&@EqJpke6y`h7J?,CK#’Q!%u-`NkwDg5.Wm3ny@rYlii,>%Y0′+’g>!lki8i

This is really hard to remember as well, if you can, you got to be supernatural. To view all APG options, type man apg in your terminal.

Category: Linux | Comments Off on How to generate strong passwords in linux

How to install and configure vsftpd

This tutorial focuses on how to setup vsftpd server on your linux based VPS or a dedicated server. The vsftpd stands for “Very Secure FTP Daemon”. It is not just secure as the name suggests but also delivers excellent performance by consuming less memory. The tutorial also teaches you how to configure by adding ftp users and locking the directory to individual users.

You can install vsftpd on Ubuntu / Debian, CentOS /Fedora and RHEL linux.

Installing vsftpd on Ubuntu or Debian

sudo apt-get install vsftpd

Installing vsftpd on CentOS / Fedora

yum install vsftpd

How to configure vsftpd:

Now that you’ve installed vsftpd, follow this procedure to configure it. These steps applies for both the linux variants.

Before you get started, stop the vsftpd by typing:

service vsftpd stop

Edit the vsftp.conf

In Ubuntu / Debian:

vi /etc/vsftpd.conf

In Red Hat / CentOS

vi /etc/vsftpd/vsftpd.conf

Make the following changes:

We don’t want anonymous login:

anonymous_enable=NO

Enable local users:

local_enable=YES

The ftpuser should be able to write data:

write_enable=YES

Port 20 need to turned off, makes vsftpd run less privileged:

connect_from_port_20=NO

Chroot everyone:

chroot_local_user=YES

set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.

local_umask=022

Now that basic configuration is complete, now let us begin with locking / securing a directory to user.

sudo useradd -d /var/www/path/to/your/dir -s /usr/sbin/nologin ftpuser

Setup a password for the user:

sudo passwd ftpuser

In order to enable the ftpuser read and write the data in your home dir, change the permission and take ownership:

sudo chown -R ftpuser /var/www/path/to/your/dir
sudo chmod 775 /var/www/path/to/your/dir

Create userlist file and add the user:

Ubuntu / Debian:
vi /etc/vsftpd.userlist

CentOS / Fedora

vi /etc/vsftpd/vsftpd.userlist

and add the user:

ftpuser

save the file and open the vsftp.conf file again:

vi /etc/vsftpd.conf

Add the following lines at the end of the file and save it:

# the list of users to give access
userlist_file=/etc/vsftpd.userlist

# this list is on
userlist_enable=YES

# It is not a list of users to deny ftp access
userlist_deny=NO

After completing all these procedures it is almost ready to use it, give it a try but you will get a 500 OOPS permission denied error. To fix it you need to add a nologin to the shell set.

vi /etc/shells

The file should look like this:

/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash

Add this line at the end:

/usr/sbin/nologin

Now create a usergroup and add the ftpuser to it:

sudo addgroup ftpusers
sudo usermod -Gftpusers ftpuser

Now start the vsftpd:

service vsftpd start

That’s it. Now you have a secure installation of vsftpd on your server.

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/en_US/all.js#xfbml=1”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));

Category: Linux | Comments Off on How to install and configure vsftpd

How to start, stop and restart MySQL in Ubuntu

mysqlThere are times when you will be forced to start, stop or restart your MySQL server, be it on your VPS or on your localhost. And like every other linux distribution, Ubuntu also comes with a shell script that lets you to do this.

All you need to do is to login as a root or make use of sudo. Open the terminal or login to your VPS and perform these commands:

To start MySQL:

sudo /etc/init.d/mysql start

To stop MySQL:

sudo /etc/init.d/mysql stop

To restart MySQL:

sudo /etc/init.d/mysql restart

Category: Linux | Comments Off on How to start, stop and restart MySQL in Ubuntu