Tizag.com Webmaster Tutorials - A collection of webmaster tutorials from HTML to PHP.

Thursday, August 29, 2013

Linux Quick Commands




Directory ::
pwd           current directory

Directory Listing ::
ls               list all files in current directory
ls -a           list all files in current directory includes hidden files
ls -al          list all files in current directory includes hidden files with permission, ownership and size
ls -al a*      list all files in current directory includes hidden files with permission, ownership and size matching a [Case]
ls -S          list all files in current directory sorts files by their size
ls -r           list all files in current directory sorts files in reverse order
ls -R          list all files in current directory recursively below the sub-directory
ls -F          list all files in current directory with extension 


Copy ::
cp original_file new file                            inside same directory
cp original_file /dir/dir/                             to a different directory
cp original_file /dir/dir/new_file                 to a different directory with new name
cp /dir/dir/original_file .                            from a different directory to current location

Move ::
mv filename /dir/                   move a file from current location to different location        
mv /dir/filename .                  move a file from different location to current location
mv original_file new_file         rename a file in same location


    -i (interactive) — Prompts you if the file you have selected overwrites an existing file in the destination directory.

    -f (force) — Overrides the interactive mode and moves without prompting. Be very careful about using this option.

    -v (verbose) — Shows the progress of the files as they are being moved. 



Delete ::

rm filename          deletes the file
rmdir dirname/      deletes directory [If directory is empty]
rm -rf /dir/             deletes directory and all its contents
   -i (interactive) — Prompts you to confirm the deletion.
  •    -f (force) — Overrides interactive mode and removes the file(s) without prompting.
  •    -v (verbose) — Shows the progress of the files as they are being removed.
  •    -r (recursive) — Deletes a directory and all files and subdirectories it contains.    


    find . -name foo   Finds the file foo in the current directory
    locate tree        Finds all file(s)/directory(ies) with tree. Can be tree.txt or btree
    mdfind kind:folder "farm-animal-type"

File Permission ::
rw------- (600) Only the owner has read and write permissions.
-rw-r--r-- (644) Only the owner has read and write permissions; the group and others have read only.
-rwx------ (700) Only the owner has read, write, and execute permissions.
-rwxr-xr-x (755) The owner has read, write, and execute permissions; the group and others have only read and execute.
-rwx--x--x (711) The owner has read, write, and execute permissions; the group and others have only execute.
-rw-rw-rw- (666) Everyone can read and write to the file. (Be careful with these permissions.)
-rwxrwxrwx (777) Everyone can read, write, and execute. (Again, this permissions setting can be hazardous.) 
     r — file can be read
     w — file can be written to
     x — file can be executed (if it is a program)
    - (dash) — specific permission has not been assigned

Directory Permission ::
drwx------ (700) Only the user can read, write in this directory.
drwxr-xr-x (755) Everyone can read the directory; users and groups have read and execute permissions. 
    d — a directory
    - (dash) — a regular file (rather than directory or link)
    l — a symbolic link to another program or file elsewhere on the system 

Identities
   u — the user who owns the file (that is, the owner)
   g — the group to which the user belongs
   o — others (not the owner or the owner's group)
   a — everyone or all (ug, and o)
Permissions
   r — read access
   w — write access
   x — execute access
Actions
   + — adds the permission
   - — removes the permission
   = — makes it the only permission      

chmod o+w filename.txt      tells the system you want to give others write permission to the file filename.txt
chmod go-w filename.txt   tells the system you are removing group and others write permission to the file.

    g+w — adds write access for the group
    o-rwx — removes all permissions for others
    u+x — allows the file owner to execute the file
    a+rw — allows everyone to read and write to the file
    ug+r — allows the owner and group to read the file
    g=rx — allows only the group to read and execute (not write) 


chmod +x dir  # Set a directory to be listable
chmod +x file # Set a file to be executable
To change the owner of a file/directory recursively (affecting all descendants):
chown -R username           dir # Recursively set user
chown -R username:groupname dir # Recursively set user and group
To change permissions bits of all files in a directory, recursively:
find dir -type f -exec chmod 644 {} ';' # make all files       rw-r-r-
To change permissions bits of all directories:
find dir -type d -exec chmod 755 {} ';' # make all directories rwxr-xr-x

It would be nice if you could just do this:
chmod -R 755 dir


Grep ::
Finding relevant word and exclusion of  irrelevant word.

grep Exception logfile.txt                                     look for Exception 
grep Exception logfile.txt | grep -v ERROR             -v option to exclude 
grep -c "Error" logfile.txt                                     -c option to count the word
grep --context=6 myword logfile.txt                     show additional six lines after matching 
egrep 'Error|Exception' logfile.txt                         search for either Error or Exception by executing just one command
grep Lin file1 file2 file3                                      search the three files for any line that contains the string Lin: 
grep 'Linux is' file1 file2 file3                              search for the phrase Linux is: 
grep 'Linux is' *                                                  search for the phrase Linux is: in all files in the current directory 


Monday, August 26, 2013

Motivating People in your Team - Keep right people in your team to increase productivity.

The skilled manpower is regularly increasing in the country. If you are a team manager your motive should be always to hire better employees.
If your team member is leaving you for better prospect it is better to say him good bye.
Keep recruiting and training people regularly.If in a project/module you require 10 people to work, then train 12-14 people.
Also your team members should be multitasking.

As a manager my challenge is not only to hire good people but to train them as a leader.

Leadership is a mindset it is not a designation. Leadership mind is a great mind it never gets stuck. It is continuously learning from all situation which never gets stuck whenever  there is problem but seek an alternative to find a different method.


How does Sam Dana Danda Bhed works in the theory of Motivation

Sama [Consultation] :: Whenever you see an employee is not working initially listen to him.Listen to his side of the story. We can get a whole picture if we listen or communicate directly.


Dana [Reward] :: Rewarding employees sufficiently increases in order to get the work done. The reward can be monetary incentive or vacation or promotion. Or we can give as "Most Productive Person Award".

Danda [Punishment] :: Many employees may not perform in spite of rewards. Therefore a stronger step is punishment for those employees may be warning, pay-cut, demotion or even suspension. Even while punishing the wrong give an opportunity to learn and improve. Slapping a person is not only a physical injury but an emotional injury. Punishment within a right limit are always respected and honored.

Bheda [Split] :: This step is not encouraged at all. In smaller firms a  non-performing employee may ask to leave the organization.


Delegating Work

Right Person for Right Job - A mistake at this stage can create a real frustration at long run.

A well written CV can impress everyone but there is a big difference between promises and actual delivery of work. Give yourself time before passing any kind of judgement on anyone. Observe an employee at-least for 3 months before assigning him a responsible task.

Different situation and circumstance can change one's productivity.

Leaders quality to Motivate Employees ::

  1. Always listen to both parties together and separately
  2. Announce the verdict Unemotionally
  3. Difference between right and wrong.
  4. Encourage new Ideas
  5. Never misuse your power.
  6. Never be partial