How to Resolve sudoer issue due to etc folder permission

In Ubuntu you can first strike Ctrl+Alt+T which opens the terminal. After that you can copy-paste the command below with Ctrl+C and paste in terminal with Ctrl+Shift+V

Command: pkexec chmod 0440 /etc/sudoers

 

Leave a comment

Create a New User and Grant Permissions in MySQL on Linux platform

Connect to mysql:

mysql -uroot -p

List all the users:

SELECT * FROM mysql.user;

Reset password:

UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]';


How to Create a New User

 

Let’s start by making a new user within the MySQL shell:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

Therefore, the first thing to do is to provide the user with access to the information they will need.

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';


Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.

FLUSH PRIVILEGES;


 

Leave a comment

Create a SSL Certificate on Apache for Ubuntu

Step One—Activate the SSL Module


The next step is to enable SSL on the droplet.

sudo a2enmod ssl

Follow up by restarting Apache.

sudo service apache2 restart

Step Two—Create a New Directory


We need to create a new directory where we will store the server key and certificate

sudo mkdir /etc/apache2/ssl

Step Three—Create a Self Signed SSL Certificate


When we request a new certificate, we can specify how long the certificate should remain valid by changing the 365 to the number of days we prefer. As it stands this certificate will expire after one year.

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.

This command will prompt terminal to display a lists of fields that need to be filled in.

The most important line is “Common Name”. Enter your official domain name here or, if you don’t have one yet, your site’s IP address.

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:NYC
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc
Organizational Unit Name (eg, section) []:Dept of Merriment
Common Name (e.g. server FQDN or YOUR name) []:example.com                  
Email Address []:webmaster@awesomeinc.com

Step Four—Set Up the Certificate


Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.

Open up the SSL config file:

sudo nano /etc/apache2/sites-available/default

You should make the following changes.

Change the port on the virtual host to 443, the default SSL port:

<VirtualHost *:443>

Add a line with your server name right below the Server Admin email:

ServerName example.com:443

Replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate).

Add in the following three lines to the end of your virtual host configuration, and make sure that they match the extensions below:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

Save and Exit out of the file.

Step Five—Activate the New Virtual Host


Before the website that will come on the 443 port can be activated, we need to enable that Virtual Host:

sudo a2ensite default

You are all set. Restarting your Apache server will reload it with all of your changes in place.

sudo service apache2 reload

In your browser, type https://youraddress, and you will be able to see the new certificate.

Leave a comment

Password protecting web pages using .htaccess files

Step By Step Instructions

Let’s suppose you want to restrict files in a directory called members to username memberone with password memberonepassword. Here’s what to do:

  1. Create a file called .htaccess in directory members that looks like this:
    AuthType Basic
    AuthName "Restricted access"
    AuthUserFile /home/USERNAME/.htpasswd
    require valid-user

    Notes:

    • In the AuthUserFile line, replace USERNAME with your ftp username.
    • The .htaccess file must be an ASCII text document.
      • A .htaccess file can be created in any word processor but must be saved as text only.
      • IF you upload your .htaccess file via FTP, the FTP client must be set to ASCII mode for transfer.
    • For security reasons, the .htaccess file on the server cannot be seen in a directory listing. If you don’t see it after uploading it, don’t worry.
    • Also note that AuthName can be anything you want. The AuthName field gives the Realm name for which the protection is provided. This name is usually given when a browser prompts for a password, and is also usually used by a browser in correlation with the URL to save the password information you enter so that it can authenticate automatically on the next challenge.
  2. Use the htpasswd command, from your home directory, to create a password file called .htpasswd in your home directory:

    SSH to your home directory. This is simply done by connecting with your SSH client and NOT entering any path, and NOT changing directories after connecting.

    After connecting to your home directory via SSH, enter:

    # htpasswd -c .htpasswd memberone

    Type the password — memberonepassword — twice as instructed.

  3. That’s the setup done. Now test by trying to access a file in the directory members; your browser should demand a username and password, and not give you access to the file if you don’t enter memberone and memberonepassword.

 

Multiple Usernames/Passwords

If you want to give access to a directory to more than one username/password pair, follow the steps above to create the .htaccess file and to create the .htpasswd file with one user. Then, add additional users to the .htpasswd file by using the htpasswd command without the -c:

# htpasswd .htpasswd membertwo
New password: 
Re-type new password: 
Adding password for user membertwo

 

Changing Passwords

If you want to change the password for an existing user, simply issue the same command as when you added the user. You will then be prompted for a new password. For example, if the user membertwo already exists and you want to change the password, just SSH to your home directory and enter:

# htpasswd .htpasswd membertwo

 

Password Protecting Multiple Directories

If you want to password protect multiple directories, and allow all users access to all password protected directories, then all you need to do is put the same .htaccess file in each directory that you want to password protect.

However, if you want to password protect multiple directories, and only allow certain users access to each directory, then you can create a different password file (all in your home directory) for each password protected directory.

Let’s say you have 3 different directories (members, admins, board) you want password protected, and each one has a different set of users that you want to allow access. Then just do the following:

Create three .htaccess files and put them in their appropriate directory:

AuthType Basic
AuthName "Restricted access"
AuthUserFile /home/USERNAME/.htpasswd.members
require valid-user

 

AuthType Basic
AuthName "Restricted access"
AuthUserFile /home/USERNAME/.htpasswd.admins
require valid-user

 

AuthType Basic
AuthName "Restricted access"
AuthUserFile /home/USERNAME/.htpasswd.board
require valid-user

Remember to replace USERNAME with your ftp username (in lower case).

Create three .htpasswd files in your home directory:

# htpasswd -c .htpasswd.members memberone
# htpasswd -c .htpasswd.admins adminone
# htpasswd -c .htpasswd.board boardmemberone

That’s it. Now when you need to add a user to one of the directories, just issue the htpasswd command on the appropriate .htpasswd file.

Leave a comment

Alt + Tab is not working in gnome shell at ubuntu 12.04

  1. Search the Ubuntu Software Center for “CompizConfig” or
    sudo apt-get install compizconfig-settings-manager
  2. Launch CompizConfig Settings Manager by pressing Alt+F2 and running ccsm. (This may also be run from a Terminal.)
  3. Click “Window Management”
  4. Enable either “Application Switcher” or “Static Application Switcher”

Leave a comment

Install LAMP (Linux + Apache + MySQL + PHP ) in Ubuntu

Remember, LAMP stands for Linux, Apache, MySQL and PHP. This script installs those programs and packages at once easily in Ubuntu. And if you’re reading this, then you probably already know what LAMP can be used for. So, without wasting anymore of your time, let’s get going.

Objectives:

  • Install LAMP in Ubuntu 12.10
  • Enjoy!

To get started, press Ctrl – Alt – T on your keyboard to open the terminal. When it opens run the commands below to install the packages.

sudo apt-get install lamp-server^

lamp_quantal

During the installation, you’ll be prompted to create a password or MySQL server. Create one to continue.

After the installation, test Apache by opening your web browser and typing localhost. When you seen the screen below, it means Apache is functioning.

lamp_quantal_1

To test PHP, create a test page by running the commands below.

sudo gedit /var/www/test.php

lamp_quantal_2

Then copy this line into the file and save it.

<?php phpinfo();?>

lamp_quantal_3

Finally, open your browser and go to http://localhost/test.php

lamp_quantal_4

 

Leave a comment

Twitter Widget

<div class=”block block-twitterbox” style=”border: 0px;”>
<script src=”http://widgets.twimg.com/j/2/widget.js&#8221; type=”text/javascript”></script>
<script type=”text/javascript”>
<!–
var twitterBoxWidget = new TWTR.Widget(
{
version: 2,
type: ‘profile’,
rpp: 4,
interval: 2000,
width: 220,
height: 280,
theme:
{
shell:
{
background: ‘#78d5e3’,
color: ‘#ffffff’
},
tweets:
{
background: ‘#ffffff’,
color: ‘#808080’,
links: ‘#648f11’
}
},
features:
{
scrollbar: true,
loop: false,
live: false,
hashtags: false,
timestamp: false,
avatars: true,
behavior: ‘all’
}
});

twitterBoxWidget.render().setUser(‘suryakantmaurya’).start();
–>
</script>

Leave a comment