Wednesday, 29 April 2015

Table Manipulation in MYSQL Ubuntu


1)
First we have to create database.

    mysql> CREATE DATABASE school;


school   ------------------>   Database

2)
And we have to switch to new database named school.

    mysql> use school
    Database changed



3)
Create a table in the database school.

mysql>  CREATE TABLE IF NOT EXISTS student (student_id int(5) NOT NULL AUTO_INCREMENT, student_name varchar(20) DEFAULT NULL, student_age int(2), PRIMARY KEY(student_id));



4)
If you want to show columns in the table named student, the screen shot is given bellow:



5)
Insert the data into the table named student, the screen shot is given bellow:


6)
After insert the data into the table student we can display the content of the table:


7)
If you want to delete a row from the table and show the content after deletion:

 

8)
 If you want to update a row from the table and show the content after the updation:


9)
If you want to drop the table then use drop command:


10)
Delete the database:


Tuesday, 28 April 2015

How to Install mysql server 5.6 on Ubuntu 14.04 LTS



1)
 Install MYSQL server 5.6.

Install MySql Server 5.6 using "apt-get" command.

anusree@anusree-VirtualBox:~$ sudo apt-get update
anusree@anusree-VirtualBox:~$ sudo apt-get install mysql-server-5.6

at the time of mysql installation you have to set password for the mysql roor user screen shot given bellow:



It will again ask mysql root password for confirmation screen shot given bellow:


2)
Login into MYSQL server.

After mysql server installation get finishes , it start the mysql service automatically. Hence, you can login now in MySQL Server with user root.
Login into MYSQL using:

    anusree@anusree-VirtualBox:~$ mysql -u root -p


3)
To Start MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql start


4)
To Stop MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql stop


 5)
 To Restart MYSQL service:

    anusree@anusree-VirtualBox:~$ sudo service mysql restart

 
 6)
Status of MYSQL after start:

    anusree@anusree-VirtualBox:~$ sudo service mysql status



 7)
 Status of MYSQL after stop:

     anusree@anusree-VirtualBox:~$ sudo service mysql status


8)
If you want to add new user, the command is given bellow:

    mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'test123';
  
    Here, test ---> user name and, test123 is password for user "test".



9)
View the full list of mysql users, the command is given bellow:

   mysql> SELECT User,Host FROM mysql.user;




10)
How to delete a user in mysql the command is given bellow:

   mysql> DROP USER 'test'@'localhost';

and after deleting the user view the full list of mysql users



11)
How to grand different user permission:

  •  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


The command for grand permission to the user is :

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



Suppose we have two user named "test" and "sample", and i am going to give SELECT permission to the user "test" and INSERT permission to the user "sample".

1)
Here we have two user "test" and "sample".



2)
Next i am going to give SELECT permission to the user "test".



3)
Next i am going to give INSERT permission to the user "sample".








Now the user "test" has only SELECT permission and the user "sample" have only INSERT permssion.

4)
Now i am going to check the permission of the user test. For that first i have to login as user "test".





The above picture shows that the user "test" have only SELECT permission.
When the user "test" try to insert a data to the table student it will cause error


5)
Now i am going to check the permission of the user sample. For that first i have to login as user "sample".




The above picture shows that the user "sample" have only INSERT permission.
When the user "sample" try to select a data to the table student it will cause error also try to delete a data from the table stdent will causes error.


Monday, 27 April 2015

Essential vim commands


Basic Commands:
  • :e file_name     ----------------->    Open file_name for edition    
  • :w                    ----------------->    Save file
  • :q                     ----------------->    Exit from Vim
  • :q!                    ----------------->    Quit without saving
  • :x                     ----------------->     Write file and exit (If changes has been made)
  • :sav file_name ----------------->    save file as file_name

Moving in the file

  • k or Up Arrow       ----------------->   move the cursor up one line
  • j or Down Arrow   ----------------->   move the cursor down one line
  • e                            ----------------->   move the cursor to the end of the word
  • b                            ----------------->  move the cursor to the begining of the word
  • 0                            ----------------->  move the cursor to the begining of the line
  • G                           ----------------->  move the cursor to the end of the file
  • gg                         ----------------->   move the cursor to the begining of the file

 Search

  • /word           ----------------->    Search word from top to bottom
  • ?word          ----------------->    Search word from bottom to top
  • /\cstring       ----------------->   Search STRING or string, case insensitive
  • /r[io]se         ----------------->   Search rise or rose
  • /\< the         ----------------->    Search the, theatre or then

Search and  Replace 

  • :%s/hai/hello/g     ----------------->  Find the occurence of "hai", in all line and replace it with "hello".
  • :s/hai/hello/g        ----------------->  Find the occurrence of "hai", in the current line only, and replace it with "hello"
  •  :%s/hai/hello/gc  ----------------->  Change each "hai" to "hello", but it will ask the confirmation first
  • :%s/hai/hello/gci  ----------------->  Change each "hai" (case sensitive) to "hello", but ask for confirmation
  • :%s/hai/hello/gcI  ----------------->  Change each "hai" (case insensitive) to "hello", but ask for confirmation
 
Copy and Pasting

  • v heighlight one charecter at a time.
  • V one line at a time.
  • y yank text into copy buffer.
  • p paste text after the current line.
  • P paste text on the current line.

Sunday, 26 April 2015

How to Compress and Extract Directory or File using "tar" Command


1)
Compress a file using tar command:

anusree@anusree-Inspiron-5547:~$ tar -cvf /home/anusree/tar_file            /my_music.tar -C /home/anusree/ my_music.mp3

a)
-cvf               

 | | |
 | |+--------------------------->   use archive file or device ARCHIVE
 |+----------------------------->   verbosely list files processed
+------------------------------->   create a new archive

b)
/home/anusree/tar_file /my_music.tar  -------->   Name of the compressed output file

c)

-C /home/anusree   -------------------->   Base location of the file to be compressed

d)

my_music.mp3   ----------------->  Name of the file to be compressed.

e)

There is a space between "-C /home/anusree" and "my_music.mp3"

2)

Extract a compressed .tar file using tar command

anusree@anusree-Inspiron-5547:~/tar_file$ tar -xvf my_music.tar my_music.mp3

3)

How to compress a directory of file in the current directory and save compressed file in current directory

$ tar -cvf output_file.tar my_directory


output_file.tar -->  Name of the compressed output file

my_directory   --> Name of the directory or file to be compressed





How To Zip and Unzip a Directory or File in Ubuntu



1)
Zip a directory/file using zip command

     anusree@anusree-Inspiron-5547:~$ zip -r zipped_my_music my_music
    adding: my_music/ (stored 0%)
    adding: my_music/zip_file (stored 0%)
    adding: my_music/zip_file~ (stored 0%)


zipped_my_music ---> Name of the compressed output zip file
my_music --->  Name of the directory or file to be compressed (zipped)

2)
Unzip or extract a zipped directory or file using unzip command

    anusree@anusree-Inspiron-5547:~$ unzip zipped_my_music.zip -d Desktop
    Archive:  zipped_my_music.zip
    creating: Desktop/
my_music/
    extracting: Desktop/
my_music/zip_file 
    extracting: Desktop/
my_music/zip_file~ 
-d Desktop --->  Directory to which to extract files



How To Install and Uninstall "deb" Package in Ubuntu


1)
Using "apt-get" command

a) Install git package using apt-get:

     $ sudo apt-get install git


  • If we install a package using apt-get, it first download the package into /var/cache/apt/archives directory, after that it will install that package into your system.
  • So, you can copy the deb package from  /var/cache/apt/archives


b) Uninstall git package using apt-get

    $ sudo apt-get remove git



Saturday, 25 April 2015

How To Find Ubuntu Version

1)
Find ubuntu version using "lsb_release" command

      anusree@anusree-VirtualBox:~$ lsb_release -a
      No LSB modules are available.
      Distributor ID:    Ubuntu
      Description:    Ubuntu 14.04.1 LTS
      Release:    14.04
      Codename:    trusty
      anusree@anusree-VirtualBox:~$



How to Lock and Unlock a User in Ubuntu Linux

1)
I have a user named "a1", and i can logging as user a1 using following command:
  
       anusree@anusree-VirtualBox:~$ su a1
      Password: [enter the password]
      a1@anusree-VirtualBox:/home/anusree$



2)
I am going to lock the user "a1".

       anusree@anusree-VirtualBox:~$ sudo passwd -l a1
      [sudo] password for anusree: [enter the password]
      passwd: password expiry information changed.
      anusree@anusree-VirtualBox:~$



3)
After i locked user "a1",  I am trying to login as user "a1" and it should fail.

       anusree@anusree-VirtualBox:~$ su a1
      Password:
      su: Authentication failure
      anusree@anusree-VirtualBox:~$



     
4)
After that i unlocked the user "a1" using following command.

      anusree@anusree-VirtualBox:~$ sudo passwd -u a1
     passwd: password expiry information changed.
     anusree@anusree-VirtualBox:~$ 





5)
After unlock the user "a1" i am going to logging as user "a1" and it should  success.

      anusree@anusree-VirtualBox:~$ su a1
      Password: [enter the password]
      a1@anusree-VirtualBox:/home/anusree$ 





How To Find Open Ports Of A Remort Mechine



Nmap - Network exploration tool and security / port scanner.
If we only know the IP address of the remort mechine and we want to know which of the port are open(running services) in that mechine then we use the command "nmap".

Using nmap we can find out the different port that are opened in the remort mechine.
    syntax:
    nmap [scan type] [Options] {ip-address-of-remort-mechine}

example:
1)
Check which of the port are open in 10.42.0.72
    anusree@anusree-Inspiron-5547:~$ nmap 10.42.0.72
    Starting Nmap 6.40 ( http://nmap.org ) at 2015-04-25 14:01 IST
    Nmap scan report for anusree-Inspiron-5547 (10.42.0.72)
    Host is up (0.00016s latency).
    Not shown: 999 closed ports
    PORT   STATE SERVICE
    22/tcp open  ssh
          
|     |    |
           |     |   +----------> The service is ssh
           |    +---------------> The state of the port is open
          +---------------------> The service ssh is listern to port 22/tcp to sent and receive packets
   
    Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds


2)
It shows that only 22/tcp is open in 10.42.0.72. If we stop the above service using the command:
    anusree@anusree-Inspiron-5547:~$ sudo service ssh stop
    ssh stop/waiting

3)
ater stoping the service ssh service then once again try namp

    anusree@anusree-Inspiron-5547:~$ nmap 10.42.0.72

    Starting Nmap 6.40 ( http://nmap.org ) at 2015-04-25 14:07 IST
    Nmap scan report for anusree-Inspiron-5547 (10.42.0.72)
    Host is up (0.00016s latency).
    All 1000 scanned ports on anusree-Inspiron-5547 (10.42.0.72) are closed

    Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds


It shows that all port are closed

4)
Start the service ssh again

    anusree@anusree-Inspiron-5547:~$ sudo service ssh start
    ssh start/running, process 3187

Then again tha state is running




Open port: When anyone asks, the computer responds
that there is a service listening on this port. This means anything
coming to this port will get processed by a program (a service) running
on that computer.
Closed port: When anyone asks, the computer responds that there are no services listening on that port.

Tuesday, 21 April 2015

SSH Passwordless Login Using SSH Keygen

SSH Passwordless Login Using SSH Keygen in 5 Easy Steps


    If you want to sent a secret message to remort mechine, the you need to know the remort mechine's public key after that you need to encrypt that message using the remort mechines's public key after that sent the message to remort mehine. After receiving the message the remort mechine decrypt the message with its private key.



In this example we will setup SSH password-less automatic login from server 192.168.56.1 as user anusree to 192.168.56.101 with user anusree.

step 1: Create Authentication SSH-Kegen Keys on – (192.168.56.1)
   
    anusree@anusree-Inspiron-5547:~$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/anusree/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/anusree/.ssh/id_rsa.
    Your public key has been saved in /home/anusree/.ssh/id_rsa.pub.
    The key fingerprint is:
    b2:d4:46:24:c9:06:62:f4:f1:d7:0a:ad:4f:37:40:c5
    anusree@anusree-Inspiron-5547
    The key's randomart image is:
    +--[ RSA 2048]----+
    | .+ oo..oo.      |
    | . o o+= .E      |
    |    ..o = .      |
    |       * o       |
    |      + S o      |
    |     . * . .     |
    |      . .        |
    |                 |
    |                 |
    +-----------------+
    First login into server 192.168.56.1 with user anusree and generate a pair of public keys using following command.

This will create the public key and also privet key, public key is save in /home/anusree/.ssh/id_rsa.pub, and private key is saved in /home/anusree/.ssh/id_rsa.



Step 2: Create .ssh Directory on – 192.168.56.101   ------------>   Use SSH from server 192.168.56.1 to connect server 192.168.56.101 using anusree as user and create .ssh directory under it, using following command.

 anusree@anusree-Inspiron-5547:~$ ssh anusree@192.168.56.101 mkdir -p .ssh
 anusree@192.168.56.101's password: [Enter Your Password Here]



step 3: Upload Generated Public Keys to – 192.168.56.101  ----------->   Use SSH from server 192.168.56.1 and upload new generated public key (id_rsa.pub) on server 192.168.56.101 under anusree‘s .ssh directory as a file name authorized_keys.

 anusree@anusree-Inspiron-5547:~$ cat .ssh/id_rsa.pub | ssh anusree@192.168.56.101 'cat >> .ssh/authorized_keys'
anusree@192.168.56.101's password: [Enter Your Password Here]



Step 4: Set Permissions on – 192.168.56.101
     --------->  (optional)

        Due to different SSH versions on servers, we need to set permissions on .ssh directory and authorized_keys file.

 anusree@anusree-Inspiron-5547:~$ ssh anusree@192.168.56.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
    sheena@192.168.0.11's password: [Enter Your Password Here]



Step 5: Login from 192.168.0.12 to 192.168.0.11 Server without Password

      From now onwards you can log into 192.168.56.101 as anusree user from   server 192.168.56.1 as anusree user without password.

anusree@anusree-Inspiron-5547:~$ ssh anusree@192.168.56.101
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)

* Documentation:  https://help.ubuntu.com/

Last login: Wed Apr 22 00:09:10 2015 from 192.168.56.1

 





   
   

Introduction to PIP

pip is a package management system used to install and manage software packages written in Python.


Diffrent pip commands are given bellow:

1)
First, we have to Install pip.
    $ sudo apt-get install python-pip

2)
Install a package using pip
    anusree@anusree-VirtualBox:~$ sudo pip install django
    [sudo] password for anusree:
    Downloading/unpacking django
      Downloading Django-1.8-py2.py3-none-any.whl (6.2MB): 6.2MB downloaded
    Installing collected packages: django
    Successfully installed django
    Cleaning up...


3)
command to Show what files are installed:
    anusree@anusree-VirtualBox:~$ pip show --files django
    ---
    Name: Django
    Version: 1.8
    Location: /usr/local/lib/python2.7/dist-packages
    Requires:
    Files:
    Cannot locate installed-files.txt


4)
List what packages are outdated:
    $ pip list --outdated

5)Upgrade a package:
    anusree@anusree-Inspiron-5547:~$ sudo pip install --upgrade django
    [sudo] password for anusree:
    Downloading/unpacking django
      Downloading Django-1.8-py2.py3-none-any.whl (6.2MB): 6.2MB downloaded
    Installing collected packages: django
    Successfully installed django
    Cleaning up...


6)
If you want to unintall a package
    $ pip uninstall PackageName

7)
If you want to upgrade the pip then the command is given bellow
    pip install -U pip

8)
To list installed packages:

    anusree@anusree-VirtualBox:~$ pip list
    adium-theme-ubuntu (0.3.4)
    apt-xapian-index (0.45)
    argparse (1.2.1)
    chardet (2.0.1)
    colorama (0.2.5)
    command-not-found (0.3)

    .
    .
    .


9)
If you want to search a package the command if given bellow:
    anusree@anusree-VirtualBox:~$ pip search django
    django-swstags            - UNKNOWN
    django-ptree              - pTree is a Django toolset that makes it easy to create and administer web-based social science experiments.
    django_backstage          - Django project and site deployment using virtualenv, uWSGI, nginx, etc.
    adrest                    - Adrest - Another Django REST. Simple application for quick build REST API.
    django-buckeye-corpus     - UNKNOWN
    django-facebook           - Facebook open graph API client in python. Enables django applications to register users using facebook. Fixes issues with
                                    the official but unsupported Facebook python-sdk. Enables mobile facebook authentication. Canvas page authentication for
                                    facebook applications. FQL access via the server side api.
    askbot                    - Question and Answer forum, like StackOverflow, written in python and Django
    django-libs               - A collection of things that we re-use in every Django project, such as custom middlewares, testrunner, templates,
    .
    .
    .
    .

   

10)
If you want to know about pip then type the command
    anusree@anusree-VirtualBox:~$ pip --help
            or   
    anusree@anusree-VirtualBox:~$ pip -h

    Usage:  
      pip <command> [options]

    Commands:
        install                     Install packages.
        uninstall                   Uninstall packages.
        freeze                      Output installed packages in requirements format.
        list                        List installed packages.
        show                        Show information about installed packages.
        search                      Search PyPI for packages.
        wheel                       Build wheels from your requirements.
        zip                         DEPRECATED. Zip individual packages.
        unzip                       DEPRECATED. Unzip individual packages.
        bundle                      DEPRECATED. Create pybundles.
        help                        Show help for commands.

    General Options:
        -h, --help                  Show help.
        -v, --verbose              Give more output. Option is additive, and can be used up to 3 times.
        -V, --version               Show version and exit.
        -q, --quiet                  Give less output.
        --log-file <path>         Path to a verbose non-appending log, that only logs failures. This log is active by default at
                              /home/anusree/.pip/pip.log.
        --log <path>              Path to a verbose appending log. This log is inactive by default.
        --proxy <proxy>          Specify a proxy in the form [user:passwd@]proxy.server:port.
        --timeout <sec>           Set the socket timeout (default 15 seconds).
        --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
        --cert <path>               Path to alternate CA bundle.





























Monday, 20 April 2015

Find Linux / UNIX Kernel Version Command


 uname command display the Linux or Unix Kernel Version.


     anusree@anusree-Inspiron-5547:~$ uname -r
     3.16.0-30-generic


  • 3 : Kernel version
  • 16 : The major revision of the kernel
  • 0 : The minor revision of the kernel
  • 30 : Immediate fixing / bug fixing for critical error.
  • generic : Distribution specific sting. For example, Redhat appends string such as EL5 to indicate RHEL 5 kernel. 

Different option with uname.  With no OPTION, same as -s.

       -a,      --all                                     print all information

       -s,      --kernel-name                     print the kernel name

       -n,      --nodename                        print the network node hostname

       -r,       --kernel-release                  print the kernel release

       -v,       --kernel-version                  print the kernel version

       -m,      --machine                           print the machine hardware name

       -p,       --processor                         print the processor type or "unknown"

       -i,        --hardware-platform          print the hardware platform or "unknown"

       -o,      --operating-system              print the operating system

       --help                                           display this help and exit

       --version                                       output version information and exit


We can also find the kernel version using /proc/version file. (Linux only Command).

1)
anusree@anusree-Inspiron-5547:~$ less /proc/version
Linux version 3.16.0-30-generic (buildd@kissel) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015


2)
anusree@anusree-Inspiron-5547:~$ more /proc/version
Linux version 3.16.0-30-generic (buildd@kissel) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015



3)
anusree@anusree-Inspiron-5547:~$ cat /proc/version
Linux version 3.16.0-30-generic (buildd@kissel) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015

Introduction to INODE




Also known as Index Node, Basically it is a “database” of all file information except the file contents and the file name.

In a file system, inodes consist roughly of 1% of the total disk space, whether it is a whole storage unit (hard disk,thumb drive, etc.) or a partition on a storage unit.  The inode space is used to “track” the files stored on the hard disk. The inode entries store metadata about each file, directory or object, but only points to these structures rather than storing the data. Each entry is 128 bytes in size.

The metadata contained about each structure can include the following:

  • Inode number
  • Access Control List (ACL)
  • Extended attribute
  • Direct/indirect disk blocks
  • Number of blocks
  • File access, change and modification time
  • File deletion time
  • File generation number
  • File size
  • File type
  • Group
  • Number of links
  • Owner
  • Permissions
  • Status flags
  •  
Commands used in inode 

1)    
listing of an inode number in the current directory
     
      $ ls –i
        
2)
find inode of a particular file
      
      $ ls –i filename
      
     eg:
           
         anusree@anusree-Inspiron-5547:~$ ls -i anu.py
         2098226 anu.py

        
3)
If you want to know more information than the inode number use "stat" command

      $ stat filename

eg:

         anusree@anusree-Inspiron-5547:~$ stat anu.py
        File: ‘anu.py’
        Size: 12            Blocks: 8          IO Block: 4096   regular file
        Device: 807h/2055d    Inode: 2098226     Links: 1
        Access: (0664/-rw-rw-r--)  Uid: ( 1000/ anusree)   Gid: ( 1000/        anusree)
       Access: 2015-04-19 22:24:20.447109534 +0530
       Modify: 2015-03-28 20:35:07.033135271 +0530
       Change: 2015-03-28 20:35:07.033135271 +0530
       Birth: -

      Both case , ie, $ ls -i anu.py and $ stat anu.py the inode number are same, 1596223 


        inode number can only change if the file is moved.
If the file is moved to a different directory, the commands are executed   again, the inode numbers are different :


      anusree@anusree-Inspiron-5547:~/Pictures$ ls -i anu.py
     1597693 anu.py



     anusree@anusree-Inspiron-5547:~/Pictures$ stat anu.py
     File: ‘anu.py’
     Size: 13            Blocks: 8          IO Block: 4096   regular file
     Device: 807h/2055d    Inode: 1597693     Links: 1
     Access: (0664/-rw-rw-r--)  Uid: ( 1000/ anusree)   Gid: ( 1000/   anusree)
     Access: 2015-04-20 19:01:03.854447830 +0530
     Modify: 2015-02-27 00:16:13.387166000 +0530
     Change: 2015-04-20 19:01:03.750447825 +0530
     Birth: -

      Now the inode number is 2098226 rather than 1597693. 


4)
You can also delete a file using its inode. Command is given bellow

 anusree@anusree-Inspiron-5547:~/Pictures$ find . -inum 1597693 -exec rm  -fi {} \;
rm: remove regular file ‘./anu.py’? yes



5)
To find the inode numbers of the directories, you can use the command “tree -a -L 1 --inodes / “. Output is given bellow:


anusree@anusree-Inspiron-5547:~/Pictures$ tree -a -L 1 --inodes /
/
|-- [1048577]  bin
|-- [11796481]  boot
|-- [13893633]  cdrom
|-- [   1025]  dev
|-- [11010049]  etc
|-- [1572865]  home
|-- [11796763]  initrd.img -> boot/initrd.img-3.16.0-30-generic
|-- [5242881]  lib
|-- [7864321]  lib64
|-- [     11]  lost+found
|-- [3145729]  media
|-- [18612225]  mnt
|-- [3932161]  opt
|-- [      1]  proc
|-- [2359297]  root
|-- [   1117]  run
|-- [19398657]  sbin
|-- [14942209]  srv
|-- [      1]  sys
|-- [12320769]  tmp
|-- [8650753]  usr
|-- [ 262145]  var
`-- [11796491]  vmlinuz -> boot/vmlinuz-3.16.0-30-generic

21 directories, 2 files

 

 (inode number for the specified directory in the brackets)


6)

To see files and subdirectories within a specific directory with its inode use the command ls -i directory

eg:
 find files and subdirectories of the directory Pictures

anusree@anusree-Inspiron-5547:~$ ls -i Pictures/
1591086 button_handler.png          

1591082 pipinstall.png                           
1589673 Screenshot from 2015-03-12 16:19:10.png
1594837 chrome_instaling error.png  

1587504 psc_last_grade_servents.png              
1589674 Screenshot from 2015-03-12 16:23:02.png
1587565 evnt.png                    

1591081 pygame.png                               
1574568 Screenshot from 2015-03-17 21:32:24.png
1580822 func.png                    

1575824 Screenshot from 2015-03-01 21:19:45.png  
1576883 Screenshot from 2015-04-01 21:43:11.png
1591254 mbox.png                    

1577519 Screenshot from 2015-03-10 15:05:56.png  
1595990 simplegui.png
1577152 mk_cron.png                 

1588832 Screenshot from 2015-03-12 12:03:21.png  
1580851 ss.png
1580268 mk_dirls.png                

1589516 Screenshot from 2015-03-12 15:23:00.png  
1596540 stepbyprocessofevet.png
1576825 mk_dir.png                  

1589671 Screenshot from 2015-03-12 15:24:42.png  
2098178 Wallpapers
1580383 mk_mode.png                 

1589670 Screenshot from 2015-03-12 15:25:52.png
1573185 pic                         

1589672 Screenshot from 2015-03-12 16:13:52.png
 













 

Saturday, 18 April 2015

Linux Manage file permissions and ownership



1)
Login as admin user
       su anusree

2)
Add new linux group named sale

       sudo groupadd sale

3)
Add new user s1 with home folder

      sudo useradd -m s1
      -m : create home folder

4)
Add another user s2 with home folder
      
      sudo useradd -m s2

5)
 Add the existing user s1 and s2 to the group sale
      
      sudo adduser s1 sale
      sudo adduser s2 sale
6)
Create a folder sale in /opt
      
      sudo mkdir sale

7)
Create a file named sale.txt in the folder /opt/sale
   
      sudo vim sale.txt

8)
Check the permissions, owner and group of the file sale.txt
     
       ls -l sale.txt
       -rw-r--r-- 1 root root 0 Apr 19 00:13 sale.txt
             |    |
             |    +----- group (root)
             +---------- user (root)

        here user is the root and group is root, here user have read and write     permission and user's in group root have only read permission, and other user's have read permission

9)
 I am going to change the group of the file sale.txt from root group to sale group

      sudo chown root :sale sale.txt
                         or
      sudo chown :sale  sale.txt

10)
I am going to give read and write permission to the user's in the group sale to access the file sale.txt

      sudo chmod g+rw sale.txt

11
 Now i am giong login as one of the user inthe group sale (eg: s1) and trying to read and write to the file sale.txt , and this should work because i already set the permission to read and write to the group sale
   
      su s1
     

12)
If you want to change the user (owner) of the file sale.txt from root to s1
       
      sudo chown s1:sale  sale.txt

13)
Check the owner or user of the file sale.txt 

      ls -l
      -rw-rw-r-- 1 s1 sale 41 Apr 18 22:59 sale.txt                               
             |    |
             |    +----- group (sale)
             +---------- user (s1)

Monday, 13 April 2015

ubuntu crontab How to start firefox

1)
First run
$crontab -e


2)
It will open a vim editor,  then enter following command and save it to open firefox window in every minute.

* * * * * DISPLAY=:0 firefox