Sunday, February 28, 2010

find command:

find command:

Find man page

Form of command: find path operators

Examples:

* Search and list all files from current directory and down for the string ABC:
find ./ -name "*" -exec grep -H ABC {} \;
find ./ -type f -print | xargs grep -H "ABC" /dev/null
egrep -r ABC *

* Find all files of a given type from current directory on down:
find ./ -name "*.conf" -print

* Find all user files larger than 5Mb:
find /home -size +5000000c -print

* Find all files owned by a user (defined by user id number. see /etc/passwd) on the system: (could take a very long time)
find / -user 501 -print

* Find all files created or updated in the last five minutes: (Great for finding effects of make install)
find / -cmin -5

* Find all users in group 20 and change them to group 102: (execute as root)
find / -group 20 -exec chown :102 {} \;

* Find all suid and setgid executables:
find / \( -perm -4000 -o -perm -2000 \) -type f -exec ls -ldb {} \;
find / -type f -perm +6000 -ls

Note: suid executable binaries are programs which switch to root privileges to perform their tasks. These are created by applying a "sticky" bit: chmod +s. These programs should be watched as they are often the first point of entry for hackers. Thus it is prudent to run this command and remove the "sticky" bits from executables which either won't be used or are not required by users. chmod -s filename

* Find all world writable directories:
find / -perm -0002 -type d -print

* Find all world writable files:
find / -perm -0002 -type f -print
find / -perm -2 ! -type l -ls

* Find files with no user:
find / -nouser -o -nogroup -print

* Find files modified in the last two days:
find / -mtime 2 -o -ctime 2

* Compare two drives to see if all files are identical:
find / -path /proc -prune -o -path /new-disk -prune -o -xtype f -exec cmp {} /new-disk{} \;

Partial list of find directives:



Directive Description
-name Find files whose name matches given pattern
-print Display path of matching files
-user Searches for files belonging to a specific user
-exec command {} \; Execute Unix/Linux command for each matching file.
-atime (+t,-t,t) Find files accessed more that +t days ago, less than -t or precisely t days ago.
-ctime (+t,-t,t) Find files changed ...
-perm Find files set with specified permissions.
-type Locate files of a specified type:
  • c: character device files
  • b: blocked device
  • d: directories
  • p: pipes
  • l: symbolic links
  • s: sockets
  • f: regular files
-size n Find file size is larger than "n" 512-byte blocks (default) or specify a different measurement by using the specified letter following "n":
  • nb: bytes
  • nc: bytes
  • nk: kilobytes
  • nw: 2-byte words


Tuesday, February 2, 2010

Installing FFMpeg on cpanel server.

Installing FFMpeg

1)yum install ffmpeg ffmpeg-devel

If you get package not found, then you will need to add few lines in the yum repository for dag packages installation. Create a file named dag.repo in /etc/yum.repos.d with the following contents on it

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux

baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1

then

yum install ffmpeg ffmpeg-devel

If everything is fine, then the installation should proceed smoothly

2)To check the FFmpeg working:

Finally, check the ffmpeg whether it is working or not.

> ffmpeg
> ffmpeg -formats
> ffmpeg --help
// This lists path of mpeg, its modules and other path information


ffmpeg -i Input.file Output.file

****Install FFMPEG-PHP Extension*****
FFmpeg-php is a very good extension and wrapper for PHP which can pull useful information about video through API interface. Inorder to install it you will need to download the source file and then compile and install extension in your server. You can download the source tarball : http://ffmpeg-php.sourceforge.net/

wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2

tar -xjf ffmpeg-0.5.2.1.tbz2

phpize

./configure
make
make install

****Editing PHP.INI

Once you have done that without any problems then you will see the php extension file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so and you will need mention that extension in php.ini file

nano /usr/local/lib/php.ini

Put the below two lines at the end of the php.ini file

[ffmpeg]
extension=ffmpeg.so

Then restart the server service httpd restart

****To check whether ffmpeg enabled with php, point your browser to test.php file. It should show the confirmation of installed ffmpeg php extension

// #test.php