FB og;image not showing original image

Sunday, November 30, 2014

og:image could not be downloaded or is too small  :-

og:image was not defined, could not be downloaded or was not big enough. Please define a chosen image using the og:image metatag, and use an image that's at least 200x200px and is accessible from Facebook. Image 'http://img.example.com/images/imagename.jpg' will be used instead.

Read more...

Integrate FindBugs Plugin With Eclipse

FindBugs Eclipse Plugin :-

This web page provides automatic distribution and updates for the Eclipse plugin for FindBugs.

Plugin requirements

This plugin has primarily been tested with Eclipse 3.3 and 3.4 It should work with 3.x releases, but let us know if you have any problems. The plugin is not compatible with versions of Eclipse preceding 3.3. The plugin runs under Java 1.5/5.0, or newer.

Plugin installation

If you have previously installed a version of the FindBugs plugin prior to mid-May, 2006, then you should remove it first. Simply remove the de.tobject.findbugs_0.0.n directory from Eclipse's pluginsdirectory.
To install the FindBugs plugin:
  1. In Eclipse, click on Help -> Software Update -> Find and Install...
  2. Choose the Search for new features to install option, and click Next.
  3. Click New Remote Site.
  4. Enter the following:
    • Name: FindBugs update site
    • URL: one of the following (note: no final slash on the url)
      • http://findbugs.cs.umd.edu/eclipse for official releases
      • http://findbugs.cs.umd.edu/eclipse-candidate for candidate releases and official releases
      • http://findbugs.cs.umd.edu/eclipse-daily for all releases, including developmental ones
    and click OK.
  5. "FindBugs update site" should appear under Sites to include in search.
    Click the checkbox next to it to select it, and click Finish.
  6. You should see FindBugs Feature under Select features to install.
    (You may have to click on one or two triangles to make it visible in the tree.)
    Select the checkbox next to it and click next.
  7. Select the I accept option to accept the license and click Next.
  8. Make sure the location is correct where you're installing it. The default (your workspace) should be fine. Click Finish.
  9. The plugin is not digitally signed. Go ahead and install it anyway.
  10. Click Yes to make Eclipse restart itself.

Read more...

How to Set Unicode (UTF-8) with Tomcat, Java, MySQL, JDBC, HAProxy?

Monday, November 17, 2014

How to Set Unicode (UTF-8) with Tomcat, Java, MySQL, JDBC, HAProxy ?

Set content-type:charset=UTF-8 :-
One example where we will create a simple page with form to enter Unicode strings and display them. The strings will be saved to MySQL database. We will create UTF-8 database and use JDBC to connect to it from our JSP code.

Step 1:-
            Create a Unicode database and a database user using cPanel or command line:-
            mysql> create database unicode character set utf8 COLLATE utf8_bin;
            mysql> create user unicode@localhost IDENTIFIED BY 'mypass123';
            mysql> grant all on unicode.* to unicode@localhost;
            mysql> flush privileges;
            mysql> use unicode;
            mysql> create table person (name text);
            mysql> \q

           MySQL Connector/J driver connection string has the form of “jdbc:mysql://[hostname]:[port]/[db_name]“


Step 2:-
            now following index.jsp to one of your Tomcat webapps. In our example we put it into ~/apache-tomcat-7.0.5/webapps/ROOT for easy access at root URL of our testing domain. There are a few places in the code where UTF-8 is referenced.

<%@page pageEncoding="UTF-8" language="java" import="java.sql.*"%>
<%@page contentType="text/html;charset=UTF-8"%>

<%
 try{
    request.setCharacterEncoding("UTF-8");
  } catch(Exception e) {}

  out.println("encoding is "+request.getCharacterEncoding());
  out.println("
testing unicode string is 'Miłością'");
  out.println("
request.getLocale() is "+request.getLocale());
  out.println("
response.getLocale() is "+response.getLocale());

  String name = (String)request.getParameter("name");

  java.sql.Connection conn = null;
  try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String jdbc = "jdbc:mysql://localhost/unicode?user=unicode&password=mypass123";
    String jdbcutf8 = "&useUnicode=true&characterEncoding=UTF-8";
    conn = DriverManager.getConnection(jdbc+jdbcutf8);
    String sql = "SELECT name FROM person";
    Statement st = conn.createStatement();

    if(name != null){
// uncomment below line if URIEncoding="UTF-8" is not set in Connector in server.xml
//      name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8");
// comment out below line if URIEncoding="UTF-8" is not set in Connector in server.xml
      name = new String(request.getParameter("name"));
      out.println("
parameter sent is "+name); 
      String sqlInsert = "INSERT INTO person SET name='"+name+"'";
      out.println("
sqlInsert="+sqlInsert);
      st.execute(sqlInsert);
    }

    ResultSet rs = st.executeQuery(sql);
    out.println("

");
    while(rs.next()) { out.print( rs.getObject(1) + "
"); }

  conn.close();
  } catch( Exception ex ) { ex.printStackTrace( new java.io.PrintWriter(out)); }

  %>

 

   
 
   
 

 

You can then access and try the form at your root URL e.g. http://username.jvmhost.net/ or http://username.jvmhost.net:HTTPPORTNUMBER/ if you have an account with JVM Host. By default request parameters and values are ISO-8859-1 encoded so you may need to decode them with

Step 3:-

name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8");

Step 4:- 
Alternatively, you can tell Tomcat to to do the encoding/decoding for you using URIEncoding=”UTF-8″. Below this setting is activated for both HTTP and AJP connectors as both are used by default at JVM Host. You can add URIEncoding in server.xml.


    connectionTimeout="20000" redirectPort="10105" URIEncoding="UTF-8" />

Step 5:-
With this setting active you can just use

name = new String(request.getParameter("name"));
This way you can have any international characters hardcoded in your pages display correctly. Also international characters sent to database via the form are read back and displayed correctly.


Set content-type:charset=UTF-8 in HAProxy:-
pls set below line in backend section just before load balancer servers.
http-response set-header Content-Type text/html;charset=UTF-8


Set Vary:User-Agent in HAProxy:-
pls set below line in backend section just before load balancer servers.
http-response set-header Vary  User-Agent



    

Read more...

RPM remove error: specifies multiple packages

Sunday, November 9, 2014

Mysql Remove Excluding Packages By Removing One My One Packeges:-

You may receive an error message “error: packagename specifies multiple packages” while removing a package with “rpm -e package-name”, for example:

# rpm -e mysql-devel
error: "mysql-devel" specifies multiple packages
This is because the packages of both the architectures (32 and 64 bit) are installed  on the server i.e.
mysql-devel.i386
mysql-devel.x86_64
CentOS, Fedora will list the duplicate packages when you query them using RPM. It won’t list the architecture i.e.
# rpm -qa mysql-devel
mysql-devel
mysql-devel
To list the packages along with their architecture, use the –queryformat option while querying the package,
# rpm -q --queryformat "%{name}.%{arch}\n" mysql-devel
mysql-devel.i386
mysql-devel.x86_64
Now, remove the package you wish to, for example 32 bit package:
# rpm -e mysql-devel.i386

Read more...

How To Create a New User and Grant Permissions in MySQL

Friday, October 17, 2014

How To Create a New User and Grant Permissions in MySQL ?

There are 3 steps :-

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

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

3. FLUSH PRIVILEGES;


How To Grant Different User Permissions :-

Here is a short list of other common possible permissions that users can enjoy.

ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
CREATE- allows them to create new tables or databases
DROP- allows them to them to delete tables or databases
DELETE- allows them to delete rows from tables
INSERT- allows them to insert rows into tables
SELECT- allows them to use the Select command to read through databases
UPDATE- allow them to update table rows

GRANT OPTION- allows them to grant or remove other users' privileges

1.  GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

2.  REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;

3. DROP USER ‘demo’@‘localhost’;

4.  quit 

5. mysql -u [username]-p


Read more...

Finding text string in all files on Linux

How To Finding text string in all files on Linux :-

Commands:-

1. grep -rnw 'directory' -e "pattern"

2. grep -Ril "text-to-find-here" /

3. grep -r "string to be searched"  /path/to/dir

4. grep -inr "Text" folder/to/be/searched/

grep "text string to search” directory-path

grep [option] "text string to search” directory-path

grep -r "text string to search” directory-path

grep -r -H "text string to search” directory-path

egrep -R "word-1|word-2” directory-path

egrep -w -R "word-1|word-2” directory-path

Read more...

Delete Symbolic Link or Softlink Linux

How To Delete Symbolic Link or Softlink in Linux, Centos, Ubuntu using command prompt ?

following command to remove symbolic links:-

1st rm - removes each given FILE including symbolic links
2nd unlink - deletes a single specified file name including symbolic links.

Delete Symbolic Link File :-

following syntax:

rm linkname
unlink linkname

Example:-

cd /tmp
ln -s /etc/resolv.conf mytest
ls -l mytest

output -
lrwxrwxrwx 1 user user 16 2008-12-16 08:27 mytest -> /etc/resolv.conf


Now delete dns symbolic link:
rm dns
OR
unlink dns


Delete Symbolic Link Directory :-

following syntax:-

rm linkDirName
unlink linkDirName

Example:-
cd /tmp
ln -s /etc test
ls -l test
Sample Output:

lrwxrwxrwx 1 user user 4 16 2008-12-16 08:27 test -> /etc

Now delete test symbolic link directory:
rm test
OR
unlink test

Read more...

Recursively delete .svn directories

How to Recursively delete .svn directories and files on linux, centos, ubunto :-

Step 1. "find" command to find all .svn folders beginning from current directory.

$ find . -type d -name .svn
./.svn
./sourceA/.svn
./sourceB/.svn
./sourceB/module/.svn

./sourceC/.svn


Step 2. rm command remove all .svn directories
     
     $ rm -rf `find . -type d -name .svn`


More Commands :-

find . -name .svn -exec rm -rf {} \;
Before running a command like that, I often like to run this first:

find . -name .svn -exec ls {} \;

or

You almost had it. If you want to pass the output of a command as parameters to another one, you'll need to use xargs. Adding -print0 makes sure the script can handle paths with whitespace:

find . -type d -name .svn -print0|xargs -0 rm -rf

Read more...

MYSQLDump Only Certain Rows of Table

Thursday, September 25, 2014

How to use mysqldump for a portion of a table ?

below are command to use mysqldump for a portion of a table :-

>mysqldump --opt --user=username --password=password databasename tablename 
--where=date_pulled='2011-05-23' > test.sql

Just fix your --where option. It should be a valid SQL WHERE clause, like:

--where="date_pulled='2011-05-23'"


You have the column name outside of the quotes.

One more Example :-

>mysqldump -uroot -p -h172.16.101.5 databasename tablename --where=" id<100000> data_path.sql

OR

you can use below also

>SELECT * INTO OUTFILE 'data_path.sql' from tablename where id<100000 p="">

Full Table MysqlDump :-

mysqldump -u root -p db_name table_name > table_name.sql

Read more...

Disable MySQL slave Configuration and Reset Mysql Slave

Wednesday, September 24, 2014

How do I completely disable MySQL replication ?

Reset Mysql Slave :- 

following are steps to reset mysql slave :-

1. >login mysql

2. mysql>check slave status \G;

3. mysql> STOP SLAVE;

4. mysql> RESET SLAVE;
               (Use RESET SLAVE ALL; for MySQL 5.5.16 and later)

5. mysql>exit

6. edit my.cnf file
    vi /etc/my.cnf

7. comment below in my.cnf
     #relay-log=mysqld-relay-bin
     #replicate-do-db=
     #replicate-do-db=
     #server-id=2

8. restart mysql
    /etc/init.d/mysqld restart

Read more...

Kill User Session

how do I kill another Login User Session remotely - Linux, Centos

How do I kill all login users session in Linux  OS using command prompt ?

use "pkill" command which will look up or signal processes based on name. It can send the specified signal (such as KILL) to each process. following commands as root user:-

$ sudo pkill -9 -u username


OR
# pkill -9 -u username

To list all users pids, enter:
$ pgrep -u username

OR better try:
$ ps -fp $(pgrep -d, -u userNameHere)


Example: Kill Unix / Linux User Session :-

In this example, list all process owned by a user called lighttpd, enter:
# ps -fp $(pgrep -d, -u lighttpd)

Sample outputs:

UID        PID  PPID  C STIME TTY          TIME CMD
lighttpd   4703     1  0 04:20 ?        00:01:07 /usr/sbin/lighttpd -f /user/local/etc/.myconf/lighttpd/master.example.com.conf
lighttpd   4705  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4708  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4710  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4712  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4714  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4715  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4716  4710  0 04:20 ?        00:00:07 /usr/bin/php-cgi
lighttpd   4718  4705  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4719  4708  0 04:20 ?        00:00:02 /usr/bin/php-cgi



To kill all process owned by lighttpd user, enter:
# pkill -9 -u lighttpd


Task: Kill and Logout All Users

The ultimate command to kill and logout all users is as follows:
# skill -KILL -v /dev/pts/*

Read more...

MySQL error 1062 - Duplicate entry when starting slave or replication fail?

Tuesday, September 16, 2014

Duplicate entry when starting slave? MySQL error 1062


Why does replication fail with error Duplicate entry for key?

following error when executing the mysql> start slave;:

    Last_SQL_Errno: 1062
    Last_SQL_Error: Error 'Duplicate entry '115846' for key
'PRIMARY'' on query. Default database: 'db'. Query: 'INSERT INTO
request_posted (id, user_id, channel, message, link, picture, name, ...

Solution :-
Try to skip some queries with:
mysql> STOP SLAVE; 
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; 
mysql> START SLAVE;

Read more...

Cannot load from mysql.proc. The table is probably corrupted

Cannot load from mysql.proc. The table is probably corrupted


Following from my dependency hell problems the other day my new version of MySQL/MariaDB seems to have all its stored procedures corrupted, displaying the following message when any of them are executed:

Cannot load from mysql.proc. The table is probably corrupted
also "your MariaDB server version for the right syntax to use near 'mysql_upgrade' at line 1"

how to fix it ? run below command to fix it.

> mysql_upgrade  -uroot -p

Problem solved.

Read more...

Installing MySQL 5.6 on CentOS Using YUM

Friday, July 4, 2014

Installing MySQL 5.6 on CentOS Using YUM :-
Below Steps to install MySQL 5.6 on CentOS :-
You will need to be running as a root user.
Step 1. Need to remove the default mysql-libs that come with CentOS and replace them with the ones from Oracle.
> yum remove mysql-libs
Step 2. clean up the cache
> yum clean dbcache
Step 3. Get the latest release from Oracle
> wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm/from/http://repo.mysql.com/
Step 4. Install the release
> yum localinstall mysql-community-release-el6-*.noarch.rpm
Step 5. Install the MySQL Community Server
> yum install mysql-community-server
Step 6. Start MySQL 5.6
> service mysqld start
Step 7. Set it up so that MySQL starts automatically on reboot:
> chkconfig mysqld on
> chkconfig --list mysqld

Read more...

Upgrade from MySQL to MariaDB on CentOS - 10 Easy Steps

Saturday, June 21, 2014

How To Upgrade from MySQL to MariaDB on CentOS :-

How to upgrade MySQL to MariaDB in 10 simple steps. assume that you already have installed MySQL latest version and it’s up and running now.

10 Easy Steps To Upgrade from MySQL to MariaDB :-
Step1 : Backup MySQL Databases
[root@server ~]#  mysqldump --all-databases --user=root --password --master-data > backupdatabase.sql
Enter password: 
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
This command will backup all databases and save them in the current directory.
Step 2: Stop MySQL service
[root@server ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@server ~]# chkconfig mysqld off
Step 3: Remove MySQL
Remove all MySQL packages now:
[root@server ~]# yum remove mysql* mysql-server mysql-devel mysql-libs
The above command will take the backup of your current MySQL config file /etc/my.cnf to/etc/my.cnf.rpmsave.

Step 4: Install REMI Repository to resolve MySQL Compatibility issue
You will probably get dependencies errors while installing MariaDB. So let us add REMI Repository to solve dependencies problems.
[root@server ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install compat-mysql55 package now:
[root@server ~]# yum --enablerepo=remi-test --disablerepo=remi install compat-mysql55
Step 5: Install MariaDb
Create a repository file for MariaDB and add the following lines:
For 32bit systems:
[root@server ~]# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 5.5 CentOS repository list - created 2013-06-06 07:42 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
For 64bit systems:
[root@server ~]# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 5.5 CentOS repository list - created 2013-06-06 07:53 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Save and exit the file and run yum update command:
[root@server ~]# yum update
Now start installing MariaDB:
[root@server ~]# yum install MariaDB-devel MariaDB-client MariaDB-server -y
Step 6: Start MariaDB service
[root@server ~]# service mysql start
Starting MySQL...... SUCCESS! 
[root@server ~]# chkconfig mysql on
Step 7: Set MySQL root password
[root@server ~]# /usr/bin/mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] 
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] 
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
Step 8: Restore /etc/my.cnf config file
Now copy the contents of the file /etc/my.cnf.rpmsave to /etc/my.cnf file:
[root@server ~]# cp /etc/my.cnf.rpmsave /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
Step 9: Import Database
Now import the database backup which we created back in Step 1:
[root@server ~]# mysql -u root -p < backupdatabase.sql 
Enter password:
Step 10: Restart MariaDB service
[root@server ~]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL...... SUCCESS!

Step 11: Upgrade Mysql
      [root@server ~]#mysql_upgrade  -uroot -p

That’s it. Login to the MySQL server and check for the old databases and tables.
Sample outputs
[root@server ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.31-MariaDB-log MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
Check Databases:
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| unixmen            |
+--------------------+
3 rows in set (0.01 sec)
Check the status of the of database server:
MariaDB [(none)]> status;
--------------
mysql  Ver 15.1 Distrib 5.5.31-MariaDB, for Linux (i686) using readline 5.1

Connection id:        3
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server:            MariaDB
Server version:        5.5.31-MariaDB-log MariaDB Server
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:            6 min 15 sec

Threads: 1  Questions: 7  Slow queries: 0  Opens: 0  Flush tables: 2  Open tables: 8  Queries per second avg: 0.018
--------------
Verify the tables:
MariaDB [(none)]> use unixmen;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [unixmen]> show tables;
+-------------------+
| Tables_in_unixmen |
+-------------------+
| sample            |
+-------------------+
1 row in set (0.01 sec)
If you seen the output like shown above, you’re done. You successfully upgraded from MySQL to MariaDB.

Read more...

Starting MySQL couldn’t find MySQL Manager

If Your doing mysql start/restart you may get following error:
Starting MySQLCouldn’t find MySQL manager (/var/lib/bin/mysql) or server (/var/lib/bin/mysqld_safe)
To fix this you need to comment out or remove the basedir directive line from /etc/my.cnf file
[mysql.server ]
server=mysql
#basedir=/var/lib
Now restart mysql
# service mysql restart

Note:- For Centos, Ubunto, Linux etc..

Read more...

File And Folder Permissions - Chmod on Linux, Centos, Ubunto

Sunday, February 2, 2014

File And Folder Permissions - Chmod on Linux, Centos, Ubunto, Fedora

 file & folder have methods of assigning permissions or access rights to specific users and groups of users. These file systems control the ability of the users to check or make changes to the contents of the filesystem on linux, centos, ubunto, fedora etc operationg system.

Want to check a permission of file/folder need to use below command :-
> ls -al
command result is :-
>-rw-r--r--  1  bob  users  1892  Jul 10  18:30 linux_course_notes.txt

Chmod Command :-
chmod is a Linux command that will let you \"set permissions\" (aka, assign who can read/write/execute) on a file.

> chmod permissions file
> chmod permission1_permission2_permission3 file

When using chmod, you need to be aware that there are three types of Linux users that you are setting permissions for. These users are technically know as:-
1. Owner
2. Group
3. World

There are three types of permissions that Linux allows for each file.
1. read
2. write
3. execute


if you wanted a file to be readable by everyone, and writable by only you, you would write the chmod command with the following structure.

COMMAND : OWNER : GROUP : WORLD : PATH

chmod read & write read read FileName

chmod 644 myfile.txt

ls -al

-rw-r--r-- 1 gcawood iqnection 382 Jan 19 6:49 myfile.txt

You will need to convert the word read or write or execute into the numeric equivalent (octal) based on the table below.

4 read (r)
2 write (w)
1 execute (x)

Permission Examples
chmod 400 mydoc.txt read by owner
chmod 040 mydoc.txt read by group
chmod 004 mydoc.txt read by anybody (other)
chmod 200 mydoc.txt write by owner
chmod 020 mydoc.txt write by group
chmod 002 mydoc.txt write by anybody
chmod 100 mydoc.txt execute by owner
chmod 010 mydoc.txt execute by group
chmod 001 mydoc.txt execute by anybody

7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)

Notation of traditional Unix permissions:-

Symbolic notation:-
Each of the three characters represent the read, write, and execute permissions:
* r if reading is permitted, - if it is not.
* w if writing is permitted, - if it is not.
* x if execution is permitted, - if it is not.

The following are some examples of symbolic notation:
* -rwxr-xr-x a regular file whose user class has full permissions and whose group and others classes have only the read and execute permissions.
* crw-rw-r-- a character special file whose user and group classes have the read and write permissions and whose others class has only the read permission.
* dr-x------ a directory whose user class has read and execute permissions and whose group and others classes have no permissions.

Numeric notation:-
Each of these digits is the sum of its component bits (see also Binary numeral system). As a result, specific bits add to the sum as it is represented by a numeral:
1. The read bit adds 4 to its total (in binary 100),
2. The write bit adds 2 to its total (in binary 010), and
3. The execute bit adds 1 to its total (in binary 001).

Symbolic NotationOctal NotationEnglish
----------0000no permissions
---x--x--x0111execute
--w--w--w-0222write
--wx-wx-wx0333write & execute
-r--r--r--0444read
-r-xr-xr-x0555read & execute
-rw-rw-rw-0666read & write
-rwxrwxrwx0777read, write, & execute

Special Permissions for Files :- 
Control
Full Modify
Execute
Read & Read
Write
Special Permissions
Traverse Folder/Execute File
X
X
X


List Folder/Read Data
X
X
X
X

Read Attributes
X
X
X
X

Read Extended Attributes
X
X
X
X

Create Files/Write Data
X
X


X
Create Folders/Append Data
X
X


X
Write Attributes
X
X


X
Write Extended Attributes
X
X


X
Delete Subfolders and Files
X




Delete
X
X



Read Permissions
X
X
X
X
X
Change Permissions
X




Take Ownership
X







Special Permissions for Folders:-

Full Modify
Execute
Read & Contents
Folder Read
List Write
Special Permissions
Control
Traverse Folder /
X
X
X
X


Execute File






List Folder /Read Data
X
X
X
X
X

Read Attributes
X
X
X
X
X

Read Extended
X
X
X
X
X

Attributes






Create Files /
X
X



X
Write Data






Create Folders /
X
X



X
Append Data






Write Attributes
X
X



X
Write Extended
X
X



X
Attributes






Delete Subfolders
X





and Files






Delete
X
X




Read Permissions
X
X
X
X
X
X
Change Permissions
X





Take Ownership
X







Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP