Command mode ESC dd delete u undelete y yank (copy to buffer) p/P p before cursor/P after cursor Ctl-g show current line number shft-G end of file n shft-G move to line n /stuff/ search n repeat in same direction N repeat in opposite direction /return repeat seach forward ?return repeat seach backward "dyy Yank current line to buffer d "a7yy Yank next 7 lines to buffer a or :1,7ya a Yank [ya] lines 1,7 to buffer a :1,7ya b Yank [ya] lines 1,7 to buffer b :5 pu b Put [pu] buffer b after line 5 "dP Put the content of buffer d before cursor "ap Put the contents of buffer a after cursor :1,4 w! file2 Write lines 1,4 to file2 :1,3 :set nu Display line numbers :set nonum Turns off display :set ic Ignore Case :eEdit a file in a new buffer :g/ /p Print matching regular expression vim :split :split :sp :split new ctl-w To move between windows ctl-w+ ctl-w- To change size ctl+wv Split windows vertically ctl-wq Close window :only To view only 1 window vim dictionary - put the following command in ~/.vimrc set dictionary+=/usr/share/dict/words set thesaurus+=/usr/share/dict/words Now, after you type a word and to go back in the listing butter Scripting - you can script vi commands using ex. For example suppose you want to replace all occurrences of "one" with "two", then exit the file if there are changes. You would put the following in a file call script Contents of script %s/one/two/g|x If you want to run this on all files with the patten "example*" for i in $(ls example*); do ex - $i
Red Hat, Fedora, Gnome, KDE, MySQL, PostgreSQL, PostGIS, Slony, Zarafa, Scalix, SugarCRM, vtiger, CITADEL,OpenOffice, LibreOffice,Wine, Apache, hadoop, Nginx Drupla, Joomla, Jboss, Wordpress, WebGUI, Tomcat, TiKi WiKi, Wikimedia, SpamAssassin, ClamAV, OpenLDAP, OTRS, RT, Samba, Cyrus, Dovecot, Exim, Postfix, sendmail, Amanda, Bacula, DRBD, Heartbeat, Keepalived, Nagios, Zabbix, Zenoss,
Monday, October 18, 2010
vi and vim commands
What Network Services are Running
$ netstat -tanup or if you just want tcp services $ netstat -tanp or $ netstat -ap|grep LISTEN|less This can be helpful to determine the services running. Need stats on dropped UDP packets? $ netstat -s -u or TCP $ netstat -s -t or summary of everything $ netstat -s or looking for error rates on the interface? $ netstat -i Listening interfaces? $ netstat -l
awk - common awk commands.
Find device names "sd" or with major number 4 and device name "tty". Print the record number NR, plus the major number and minor number. $ awk '$2 == "sd"||$1 == 4 && $2 == "tty" { print NR,$1,$2}' /proc/devices Find device name equal to "sound". $ awk '/sound/{print NR,$1,$2}' /proc/devices Print the 5th record, first field, in file test $ awk 'NR==5{print $1}' test Print a record, skip 4 records, print a record etc from file1 $ awk '(NR-1) % 4 == 0 {print $1}' file1 Print all records except the last one from file1 $ tac file1|awk 'NR > 1 {print $0}'|tac Print A,B,C ..Z on each line, cycling back to A if greater than 26 lines $ awk '{ print substr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",(NR-1)%26+1,1),$0}' file1 Number of bytes in a directory. $ ls -l|awk 'BEGIN{ c=0}{ c+=$5} END{ print c}' Remove duplicate, nonconsecutive line. As an advantage over "sort|uniq" you can eliminate duplicate lines in an unsorted file. $ awk '! a[$0]++' file1 Or the more efficient script $ awk '!($0 in a) {a[$0];print}' file1 Print only the lines in file1 that have 80 characters or more $ awk 'length < 80' file1 Print line number 25 on an extremely large file -- note it has to be efficient and exit after printing line number 25. $ awk 'NR==25 {print; exit}' verybigfile
Using the "find" Command.
List only directories, max 2 nodes down that have "net" in the name $ find /proc -type d -maxdepth 2 -iname '*net*' Find all *.c and *.h files starting from the current "." position. $ find . \( -iname '*.c' -o -iname '*.h' \) -print Find all, but skip what's in "/CVS" and "/junk". Start from "/work" $ find /work \( -iregex '.*/CVS' -o -iregex '.*/junk' \) -prune -o -print Note -regex and -iregex work on the directory as well, which means you must consider the "./" that comes before all listings. Here is another example. Find all files except what is under the CVS, including CVS listings. Also exclude "#" and "~". $ find . -regex '.*' ! \( -regex '.*CVS.*' -o -regex '.*[#|~].*' \) Find a *.c file, then run grep on it looking for "stdio.h" $ find . -iname '*.c' -exec grep -H 'stdio.h' {} \; sample output --> ./prog1.c:#include./test.c:#include Looking for the disk-hog on the whole system? $ find / -size +10000k 2>/dev/null Looking for files changed in the last 24 hours? Make sure you add the minus sign "-1", otherwise, you will only find files changed exactly 24 hours from now. With the "-1" you get files changed from now to 24 hours. $ find . -ctime -1 -printf "%a %f\n" Wed Oct 6 12:51:56 2010 . Wed Oct 6 12:35:16 2010 Linux_and_Open_Source.txt Or if you just want files. $ find . -type f -ctime -1 -printf "%a %f\n" Details on file status change in the last 48 hours, current directory. Also note "-atime -2"). $ find . -ctime -2 -type f -exec ls -l {} \; NOTE: if you don't use -type f, you make get "." returned, which when run through ls "ls ." may list more than what you want. Also you may only want the current directory $ find . -ctime -2 -type f -maxdepth 1 -exec ls -l {} \; To find files modified within the last 5 to 10 minutes $ find . -mmin +5 -mmin -10
Monitor all Network Traffic Except Your Current ssh Connection
$ tcpdump -i eth0 -nN -vvv -xX -s 1500 port not 22 Or to filter out port 123 as well getting the full length of the packet (-s 0), use the following: $ tcpdump -i eth0 -nN -vvv -xX -s 0 port not 22 and port not 123 Or to filter only a certain host say 192.168.158.205 $ tcpdump -i eth0 -nN -vvv -xX port not 22 and host 192.168.158.205 Just want ip addresses and a little bit of data, then, use this. The "-c 20" is to stop after 20 packets. $ tcpdump -i eth0 -nN -s 1500 port not 22 -c 20 If you're looking for sign of DOS attacks, the following show just the SYN packets on all interfaces: $ tcpdump 'tcp[13] & 2 == 2'
Speed up SSH
Try setting up ssh client with compression and
use arcfour/blowfish encryption instead. Also avoid ipv6 lookup and
reuse connections using
socket:
Add below to ~/.ssh/config
socket:
Add below to ~/.ssh/config
Host *
Ciphers arcfour,blowfish-cbc
Compression yes
AddressFamily inet
ControlMaster auto
ControlPath ~/.ssh/socket-%r@%h:%p
Friday, October 15, 2010
Install your own git server on Cent OS / RHEL /Fedora
i386:
Now we want to checkout a copy of the new repository from a different server.
To add a new file to the repo:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
x86_64:rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
As root run this command:yum install git
Next I’m going to setup a new repository and make it accessible
over ssh:We’ll create a dummy file to get started. If you trying to clone (checkout) an empty git repository, you’ll just get errors:mkdir /home/rajat/repo #create directory for new repository
cd /home/rajat/repo
git init
touch firstfile
Add all files in this directory to your git repository:git add .
Commit the changes you’ve made to the repo:git commit
Next we’ll create a clone of the repo and configure it to
be public:you can copy your repo.git directory to where you want to make the repo publiccd /home/rajat
git clone --bare ./repo repo.git
touch repo.git/git-daemon-export-ok
Now we want to checkout a copy of the new repository from a different server.
git clone ssh://yourserveraddress/home/rajat/repo.git
You should now have a new directory labeled repo which contains the
file ‘firstfile’To add a new file to the repo:
Now we want to submit the changes back to the git server:cd repo
touch secondfile
git add .
git commit
git push
You’ll be prompted for your password.
:)
Linux / UNIX Delete or Remove Files With Inode Number
An inode identifies the file and its attributes such as file size, owner, and so on. A unique inode number within the file system identifies each inode. But, why to delete file by an inode number? Sure, you can use rm command to delete file. Sometime accidentally you creates filename with control characters or characters which are unable to be input on a keyboard or special character such as ?, * ^ etc. Removing such special character filenames can be problem. Use following method to delete a file with strange characters in its name:
Please note that the procedure outlined below works with Solaris, FreeBSD, Linux, or any other Unixish oses out there:
Find out file inode
First find out file inode number with any one of the following command:stat {file-name}
OR
ls -il {file-name}
Use find command to remove file:
Use find command as follows to find and remove a file:find . -inum [inode-number] -exec rm -i {} \;
When prompted for confirmation, press Y to confirm removal of the file.
Delete or remove files with inode number
Let us try to delete file using inode number.(a) Create a hard to delete file name:
$ cd /tmp
$
touch "\+Xy \+\8"
$ ls
(b) Try to remove this file with rm command:
$ rm \+Xy
\+\8
(c) Remove file by an inode number, but first find out the file inode number:
$ ls -il
Output:
981956 drwx------ 3 rajat admin 4096 2010-10-15 15:05 gconfd-viv 981964 drwx------ 2 rajat admin 4096 2010-10-15 15:05 keyring-pKracm 982049 srwxr-xr-x 1 rajat admin 0 2010-10-15 15:05 mapping-viv 981939 drwx------ 2 rajat admin 4096 2010-10-15 15:31 orbit-viv 981922 drwx------ 2 rajat admin 4096 2010-10-15 15:05 ssh-cnaOtj4013 981882 drwx------ 2 rajat admin 4096 2010-10-15 15:05 ssh-SsCkUW4013 982263 -rw-r--r-- 1 rajat admin 0 2010-10-15 15:49 \+Xy \+\8Note: 982263 is inode number.
(d) Use find command to delete file by inode:
Find and remove file using find command, type the command as follows:
$ find
. -inum 982263 -exec rm -i {} \;
Note you can also use add \ character before special character in filename to remove it directly so the command would be:
$ rm
"\+Xy \+\8"
If you have file like name like name "2009/12/31" then no UNIX or Linux command can delete this file by name. Only method to delete such file is delete file by an inode number. Linux or UNIX never allows creating filename like 2009/12/31 but if you are using NFS from MAC OS or Windows then it is possible to create a such file.
Remove Files and Directories with Special Characters
Today is going to be a practical tip. If you're managing many
Unix/Linux systems, sooner or later you come across files with
special characters – they can't be deleted with rm command
using standard approach and require a bit of trickery to be
successfully removed.
With filenames starting with hash (#), you'll get a different kind of error: your Unix shell will treat the rest of a filename (and anything that might follow it) as a comment because hashes are used to do it in shell scripts. That's why your cat command will not show any error but will not finish until you Ctrl+C it:
To make command ignore the leading dash (-) in a filename, use the — command line option:
So, if you start typing:
rajat-linux $ rm \#try
There's a few more tricks you can use for escaping special characters, but they're worth a separate post, so stay tuned! Until then, enjoy getting rid of annoying files with special characters in filenames!
Examples of files with special characters
Any language apart from English will probably have special characters in the alphabet, but for the purpose of today's exercise I'll give you more standard examples: files starting with dash (-) and hash (#) characters:rajat-linux$ ls -al -rw-r--r-- 1 rajat admin 0 Sep 25 05:50 #try -rw-r--r-- 1 rajat admin 0 Sep 25 05:48 -tryNow, if you try to access these files or remove them, you will get errors:
rajat-linux$ cat -try cat: invalid option -- r Try `cat --help' for more information. rajat-linux$ rm -try rm: invalid option -- t Try `rm ./-try' to remove the file `-try'. Try `rm --help' for more information.These errors happen because commands treat file names as command line options because they start with dash (-).
With filenames starting with hash (#), you'll get a different kind of error: your Unix shell will treat the rest of a filename (and anything that might follow it) as a comment because hashes are used to do it in shell scripts. That's why your cat command will not show any error but will not finish until you Ctrl+C it:
rajat-linux$ cat #try… and if you try removing such a file, you'll get a complaint from the rm command about missing command line parameters – because of the hash (#) sign, rm command receives no text as a parameter:
rajat-linux$ rm #try rm: missing operand Try `rm --help' for more information.
How to remove a file when filename starts with dash (-)
First I'm gonna show you how to make your Unix shell interpret any filename directly instead of trying to analyze it as a set of command line options.To make command ignore the leading dash (-) in a filename, use the — command line option:
rajat-linux$ rm -- -tryAs you can see, our file is gone:
rajat-linux$ ls -al -rw-r--r-- 1 rajat admin 0 Sep 25 05:50 #try
Using backslash to escape special characters in a filename
Another option we have is to use a backslash (\), which will make shell interpreter ignore the special functionality of a character which immediately follows it. To escape the hash (#) our second file has, we should therefore do the following:rajat-linux$ rm \#tryInteresting to know: bash shell has an auto-completion functionality built in. When you type a filename, just press Tab key to make it auto-complete the name for you. Speaking of special characters in particular, quite a few of them are recognized by auto-completion and get escaped automatically.
So, if you start typing:
rajat-linux $ rm #t… and then press Tab, bash will not only auto-complete the name, but escape the leading hash (#):
rajat-linux $ rm \#try
There's a few more tricks you can use for escaping special characters, but they're worth a separate post, so stay tuned! Until then, enjoy getting rid of annoying files with special characters in filenames!
Thursday, October 14, 2010
Xoops Installation on Cent OS/Fedora /RedHat with LAMP
What XOOPS stands for
XOOPS is an acronym of eXtensible Object Oriented Portal System. Though started as a portal system, XOOPS is in fact striving steadily on the track of Content Management System. It can serve as a web framework for use by small, medium and large sites.
A lite XOOPS can be used as a personal weblog or journal. For this purpose, you can do a standard install, and use its News module only. For a medium site, you can use modules like News, Forum, Download, Web Links etc to form a community to interact with your members and visitors. For a large site as an enterprise one, you can develop your own modules such as eShop, and use XOOP's uniform user management system to seamlessly integrate your modules with the whole system.
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
#yum install mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc phpmyadmin
#service httpd start
#service mysqld start
#/usr/bin/mysqladmin -u root password 'new-password'
#vi /etc/httpd/conf.d/phpMyAdmin.conf
http://youdomain.com/phpmyadmin
#wget http://sourceforge.net/projects/xoops/files/XOOPS%20Core%20%28stable%20releases%29/XOOPS%202.4.5/xoops-2.4.5.zip/download
#unzip xoops-2.4.5.zip -d /var/www/html/
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/mainfile.php
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/mainfile.dist.php
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/uploads/
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/include/license.php
#chmod 777 var/www/html/xoops-2.4.5/htdocs/xoops_data/caches/smarty_*
open firefox
http://yourdomain.com/xoops-2.4.5/htdocs/install/index.php
XOOPS is an acronym of eXtensible Object Oriented Portal System. Though started as a portal system, XOOPS is in fact striving steadily on the track of Content Management System. It can serve as a web framework for use by small, medium and large sites.
A lite XOOPS can be used as a personal weblog or journal. For this purpose, you can do a standard install, and use its News module only. For a medium site, you can use modules like News, Forum, Download, Web Links etc to form a community to interact with your members and visitors. For a large site as an enterprise one, you can develop your own modules such as eShop, and use XOOP's uniform user management system to seamlessly integrate your modules with the whole system.
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
#yum install mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc phpmyadmin
#service httpd start
#service mysqld start
#/usr/bin/mysqladmin -u root password 'new-password'
#vi /etc/httpd/conf.d/phpMyAdmin.conf
http://youdomain.com/phpmyadmin
#wget http://sourceforge.net/projects/xoops/files/XOOPS%20Core%20%28stable%20releases%29/XOOPS%202.4.5/xoops-2.4.5.zip/download
#unzip xoops-2.4.5.zip -d /var/www/html/
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/mainfile.php
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/mainfile.dist.php
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/uploads/
#chmod 777 /var/www/html/xoops-2.4.5/htdocs/include/license.php
#chmod 777 var/www/html/xoops-2.4.5/htdocs/xoops_data/caches/smarty_*
open firefox
http://yourdomain.com/xoops-2.4.5/htdocs/install/index.php
Wednesday, October 13, 2010
ffmpeg commands
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec – the leading audio/video codec library. FFmpeg is free software and is licensed under the LGPL or GPL depending on your choice of configuration options.
FFmpeg supports most of the popular formats, we don’t need to worry a lot about that. Formats supported by FFmpeg include MPEG, MPEG-4 (Divx), ASF, AVI, Real Audio/Video and Quicktime. To see a list of all the codecs/formats supported by FFmpeg, run the following command:
0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.
0.0
is display.screen number of your X11 server, same as the DISPLAY
environment variable. 10 is the x-offset and 20 the y-offset for the
grabbing.
Notice that `%d’ is replaced by the image number.
`img%03d.jpg' means the sequence `img001.jpg', `img002.jpg', etc…
If you have large number of pictures to rename, you can use the following command to ease the burden. The command, using the bourne shell syntax, symbolically links all files in the current directory that match
If you want to sequence them by oldest modified first, substitute
Then run:
The same logic is used for any image format that ffmpeg reads.
This
converts any media ffmpeg handles to flash. It would actually convert
anything to anything, it’s based on the file extension. It doesn’t do
ANY quality control, sizing, etc, it just does what it thinks is best.
Convert .flv to .3gp
Download YouTube videos as .flv and convert them to .3gp for your mobile phone.
Convert AVI to iPhone MP4
for 4:3 aspect:
for 16:9:
Create a video that is supported by youtube:
Takes an mpeg video and coverts it to a youtube compatible flv file.
The -r 25 sets the frame rate for PAL, for NTSC use 29.97
Adjust the bitrate (-ab) as necessary. If omitted FFmpeg will use a default of 64 kb/s.
Converting WMV to MP3 using FFMPEG
This will convert audio1.wmv file to audio1.mp3
Converting WMV to FLV using FFMPEG
This will convert audio1.wmv file to audio1.flv, this will generate only audio content
Converting AMR to MP3 using FFMPEG
This will convert audio1.amr file to audio1.mp3 having audio rate 22.05 Khz
Converting aac to mp3 using FFMPEG
This will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and Audio BitRate 32Khz
Converting aac to mp3 using FFMPEG with MetaData
This
will convert audio1.aac to audio1.mp3 having audio rate 22.05 Khz and
Audio BitRate 32Khz and will copy the meta data from .aac file to .mp3
file
Dumping Audio stream from flv (using ffmpeg)
To record both audio and video run ffmpeg with arguments such as these:
-vcodec,
you choose what video codec the new file should be encoded with. Run
ffmpeg -formats E to list all available video and audio encoders and
file formats.
copy, you choose the video encoder that just copies the file.
-acodec, you choose what audio codec the new file should be encoded with.
copy, you choose the audio encoder that just copies the file.
-i originalfile, you provide the filename of the original file to ffmpeg
-ss 00:01:30, you choose the starting time on the original file in this case 1 min and 30 seconds into the film
-t 0:0:20, you choose the length of the new film
newfile, you choose the name of the file created.
Hence you may concatenate your multimedia files by first transcoding them to these privileged formats, then using the humble
Merge files
Merge and convert to avi
Notice
that you should either use -sameq or set a reasonably high bitrate for
your intermediate and output files, if you want to preserve video
quality.
Also notice that you may avoid the huge intermediate files by taking advantage of named pipes, should your platform support it:
This assumes that there is a 10.2 sec delay between the video and the audio (delayed).
To extract the original video into a audio and video composites look at the command on extracting audio and video from a movie
Here is more information of how to use ffmpeg:
http://www.ffmpeg.org/ffmpeg-doc.html
ffmpeg is a multiplatform, open-source library for video and audio files. Useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.
The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
FFmpeg supports most of the popular formats, we don’t need to worry a lot about that. Formats supported by FFmpeg include MPEG, MPEG-4 (Divx), ASF, AVI, Real Audio/Video and Quicktime. To see a list of all the codecs/formats supported by FFmpeg, run the following command:
ffmpeg -formats
1. X11 grabbing
FFmpeg can grab the X11 display.ffmpeg -f x11grab -s cif -i :0.0 /tmp/out.mpg
ffmpeg -f x11grab -s cif -i :0.0+10,20 /tmp/out.mpg
ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
2. Convert Pictures To Movie
First, rename your pictures to follow a numerical sequence. For example, img1.jpg, img2.jpg, img3.jpg,… Then you may run:ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
`img%03d.jpg' means the sequence `img001.jpg', `img002.jpg', etc…
If you have large number of pictures to rename, you can use the following command to ease the burden. The command, using the bourne shell syntax, symbolically links all files in the current directory that match
*jpg
to the `/tmp' directory in the sequence of `img001.jpg', `img002.jpg' and so on.x=1; for i in *jpg; do counter=$(printf %03d $x); ln "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done
$(ls -r -t *jpg)
in place of *jpg
.Then run:
ffmpeg -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg
3. Video Conversions
Quick and dirty convert to flvffmpeg -i inputfile.mp4 outputfile.flv
Convert .flv to .3gp
ffmpeg -i file.flv -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y out.3gp
Convert AVI to iPhone MP4
ffmpeg -i [source].avi -f mp4 -vcodec mpeg4 -b 250000 -s 480?320 -acodec aac -ar 24000 -ab 64 -ac 2 [destination].mp4
ffmpeg -i source-xvid.avi -s 480x320 -aspect 4:3 -b 768k -ab 64k -ar 22050 -r 30000/1001 OUT.mp4
ffmpeg -i source-xvid.avi -s 480x320 -aspect 16:9 -b 768k -ab 64k -ar 22050 -r 30000/1001 OUT.mp4
ffmpeg -i mymovie.mpg -ar 22050 -acodec libmp3lame -ab 32K -r 25 -s 320x240 -vcodec flv mytarget.flv
The -r 25 sets the frame rate for PAL, for NTSC use 29.97
4. Audio Conversion
Convert RM file to mp3ffmpeg -i input.rm -acodec libmp3lame -ab 96k output.mp3
Converting WMV to MP3 using FFMPEG
ffmpeg -i audio1.wmv audio1.mp3
Converting WMV to FLV using FFMPEG
ffmpeg -i audio1.wmv audio1.flv
Converting AMR to MP3 using FFMPEG
ffmpeg -i audio1.amr -ar 22050 audio1.mp3
Converting aac to mp3 using FFMPEG
ffmpeg -i audio1.aac -ar 22050 -ab 32 audio1.mp3
Converting aac to mp3 using FFMPEG with MetaData
ffmpeg -i audio1.aac -ar 22050 -ab 32 -map_meta_data audio1.mp3:audio1.aac audio1.mp3
5. Audio Extraction
ffmpeg -i video.avi -f mp3 audio.mp3
ffmpeg -i input.flv -f mp3 -vn -acodec copy ouput.mp3
6. Record Audio and Video from webcam
To record video run ffmpeg with arguments such as these:ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
7. Copy Only A Part Of Video
Cut out a piece of film from a file. Choose an arbitrary length and starting time.ffmpeg -vcodec copy -acodec copy -i orginalfile -ss 00:01:30 -t 0:0:20 newfile
copy, you choose the video encoder that just copies the file.
-acodec, you choose what audio codec the new file should be encoded with.
copy, you choose the audio encoder that just copies the file.
-i originalfile, you provide the filename of the original file to ffmpeg
-ss 00:01:30, you choose the starting time on the original file in this case 1 min and 30 seconds into the film
-t 0:0:20, you choose the length of the new film
newfile, you choose the name of the file created.
8. Join Multiple Video Files
A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to join video files by merely concatenating them.Hence you may concatenate your multimedia files by first transcoding them to these privileged formats, then using the humble
cat
command (or the equally humble copy
under Windows), and finally transcoding back to your format of choice.mkfifo orig1.mpg mkfifo orig2.mpg ffmpeg -i input1.avi -sameq -y orig1.mpg ffmpeg -i input2.avi -sameq -y orig2.mpg
cat orig1.mpg orig2.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy merged.mpg
cat orig1.mpg orig2.mpg | ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame merged.avi
Also notice that you may avoid the huge intermediate files by taking advantage of named pipes, should your platform support it:
9. Removing Synchronization Problems Between Audio and Video
ffmpeg -i source_audio.mp3 -itsoffset 00:00:10.2 -i source_video.m2v target_video.flv
To extract the original video into a audio and video composites look at the command on extracting audio and video from a movie
Here is more information of how to use ffmpeg:
http://www.ffmpeg.org/ffmpeg-doc.html
ffmpeg is a multiplatform, open-source library for video and audio files. Useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.
Getting infos from a video file
ffmpeg -i video.avi
Turn X images to a video sequence
ffmpeg -f image2 -i image%d.jpg video.mpgThis command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.
Turn a video to X images
ffmpeg -i video.mpg image%d.jpgThis command will generate the files named image1.jpg, image2.jpg, …
The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4Explanations :
- Source : source_video.avi
- Audio codec : aac
- Audio bitrate : 128kb/s
- Video codec : mpeg4
- Video bitrate : 1200kb/s
- Video size : 320px par 180px
- Generated video : final_video.mp4
Encode video for the PSP
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4Explanations :
- Source : source_video.avi
- Audio codec : aac
- Audio bitrate : 32kb/s
- Video codec : xvid
- Video bitrate : 1200kb/s
- Video size : 320px par 180px
- Generated video : final_video.mp4
Extracting sound from a video, and save it as Mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3Explanations :
- Source video : source_video.avi
- Audio bitrate : 192kb/s
- output format : mp3
- Generated sound : sound.mp3
Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg
Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi
Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif
Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Convert .avi to dv
ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dvOr:
ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to mpeg for dvd players
ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpegExplanations :
- target pal-dvd : Output format
- ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
- aspect 16:9 : Widescreen
Compress .avi to divx
ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Compress Ogg Theora to Mpeg dvd
ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg
Compress .avi to SVCD mpeg2
NTSC format:ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpgPAL format:
ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg
Compress .avi to VCD mpeg2
NTSC format:ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpgPAL format:
ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg
Multi-pass encoding with ffmpeg
ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2
Find a webhost with ffmpeg enabled
Friday, October 8, 2010
Zimbra 6 on CentOS 5 Email and Calendars
Zimbra is a groupware system that provides email, calendaring, integrated antivirus
and spam filtering, and more for multiple domains. Available in several editions, this
guide will help you get the Open Source Edition installed on your CentOS 5
# yum install gmp compat-libstdc++-33 sysstat sudo libidn wget
Before proceeding, make sure your /etc/hosts file has valid entries. For reference, your file should resemble the following:
File: /etc/hosts
64 Bit OS
#wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz
32 Bit OS
# wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5.20100820051652.tgz
#tar -xzf zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz
#cd zcs-6.0.8_GA_2661.RHEL5_64.20100820052503
#./install.sh --platform-override
DNS ERROR resolving MX for archimedes.palegray.net It is suggested that the domain name have an MX record configured in DNS Change domain name? [Yes] No It is recommended (but not required) that the fully qualified domain name for your system (yeswedeal.com) have an MX record pointing to it. You may wish to visit your DNS control panel and add such a record now, or proceed if you won't be receiving mail for your FQDN on this system (for example, if you'll be receiving email for your base domain or others).
The install will continue, probably requiring a few minutes to perform various tasks. You'll be asked which components of the Zimbra package you'd like to install. For the purposes of this tutorial, choose the default values for each ("Y" or "N" depending on which letter is in the brackets).
Once the installation has completed, you'll be presented with an admin menu next.
After installation has completed, you'll need to start zimbra with the following command:
#service zimbra start
To have Zimbra start on every boot, enter the following command:
#chkconfig zimbra on
you may wish to reboot your Linode to make sure everything comes back up properly. After doing so, visit the Zimbra admin URL in your browser. It will be in the form https://yeswedeal.com:7071/. You'll need to accept the SSL certificate presented to access the admin panel, which you may then use to continue configuring your new Zimbra server. Enjoy!
# yum install gmp compat-libstdc++-33 sysstat sudo libidn wget
Before proceeding, make sure your /etc/hosts file has valid entries. For reference, your file should resemble the following:
File: /etc/hosts
127.0.0.1 localhost.localdomain localhost 10.30.56.8 mail.yeswedeal.com mail
64 Bit OS
#wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz
32 Bit OS
# wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5.20100820051652.tgz
#tar -xzf zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz
#cd zcs-6.0.8_GA_2661.RHEL5_64.20100820052503
#./install.sh --platform-override
You appear to be installing packages on a platform different than the platform for which they were built. This platform is CentOS5 Packages found: RHEL5 This may or may not work. Using packages for a platform in which they were not designed for may result in an installation that is NOT usable. Your support options may be limited if you choose to continue. Install anyway? [N] Y
You may receive a warning similar to the one shown below. Enter "Y" to proceed.
Before the install begins, you may receive a warning similar to the one shown below:
DNS ERROR resolving MX for archimedes.palegray.net It is suggested that the domain name have an MX record configured in DNS Change domain name? [Yes] No It is recommended (but not required) that the fully qualified domain name for your system (yeswedeal.com) have an MX record pointing to it. You may wish to visit your DNS control panel and add such a record now, or proceed if you won't be receiving mail for your FQDN on this system (for example, if you'll be receiving email for your base domain or others).
The install will continue, probably requiring a few minutes to perform various tasks. You'll be asked which components of the Zimbra package you'd like to install. For the purposes of this tutorial, choose the default values for each ("Y" or "N" depending on which letter is in the brackets).
Once the installation has completed, you'll be presented with an admin menu next.
Main menu 1) Common Configuration: 2) zimbra-ldap: Enabled 3) zimbra-store: Enabled +Create Admin User: yes +Admin user to create: admin@yeswedeal.com
******* +Admin Password UNSET +Enable automated spam training: yes +Spam training user: spam.abc@yeswedeal.com
+Non-spam(Ham) training user: ham.abcd@yeswedeal.com
+Global Documents Account: wiki@yeswedeal.com +SMTP host: yeswedeal.com
+Web server HTTP port: 80 +Web server HTTPS port: 443 +Web server mode: http +IMAP server port: 143 +IMAP server SSL port: 993 +POP server port: 110 +POP server SSL port: 995 +Use spell check server: yes +Spell server URL: http://yeswedeal.com:7780/aspell.php +Configure for use with mail proxy: FALSE +Configure for use with web proxy: FALSE 4) zimbra-mta: Enabled 5) zimbra-snmp: Enabled 6) zimbra-logger: Enabled 7) zimbra-spell: Enabled 8) Default Class of Service Configuration: r) Start servers after configuration yes s) Save config to file x) Expand menu q) Quit Address unconfigured (**) items (? - help) 3
Store configuration 1) Status: Enabled 2) Create Admin User: yes 3) Admin user to create: admin@yeswedeal.com
** 4) Admin Password UNSET 5) Enable automated spam training: yes 6) Spam training user: spam.abc@yeswedeal.com
7) Non-spam(Ham) training user: ham.abcd@yeswedeal.com
8) Global Documents Account: wiki@yeswedeal.com
9) SMTP host: yeswedeal.com 10) Web server HTTP port: 80 11) Web server HTTPS port: 443 12) Web server mode: http 13) IMAP server port: 143 14) IMAP server SSL port: 993 15) POP server port: 110 16) POP server SSL port: 995 17) Use spell check server: yes 18) Spell server URL: http://yeswedeal.com:7780/aspell.php 19) Configure for use with mail proxy: FALSE 20) Configure for use with web proxy: FALSE Select, or 'r' for previous menu [r] 4
You can configure various options here; but, the most important option is the one for setting the administrator password. Enter "4" to set it, choosing a strong password comprised of letters, numbers, and non-alphanumeric characters. After setting the admin password, enter "r" to return to the main menu. You will be asked to apply the new configuration. Type "a" and press enter. You may then allow the program to proceed with the remaining installation steps.
After installation has completed, you'll need to start zimbra with the following command:
#service zimbra start
To have Zimbra start on every boot, enter the following command:
#chkconfig zimbra on
you may wish to reboot your Linode to make sure everything comes back up properly. After doing so, visit the Zimbra admin URL in your browser. It will be in the form https://yeswedeal.com:7071/. You'll need to accept the SSL certificate presented to access the admin panel, which you may then use to continue configuring your new Zimbra server. Enjoy!
Monitor System Logs with Logwatch on Cent OS /RedHat /Fedora /Ubuntu
Logwatch is a utility used to monitor system logs and create reports. These
reports include failed login attempts, successful login attempts, and storage
space used/available.
For Fedora/CentOS/RedHat
#yum install logwatch
For Ubuntu
$sudo apt-get install logwatch
File: /usr/share/logwatch/default.conf/logwatch.conf
These directives tell Logwatch to email you reports in an HTML format.
The MailTo and MailFrom directives should be valid email addresses.
Issue the following command to test your logwatch installation:
For Fedora/CentOS/RedHat
#yum install logwatch
For Ubuntu
$sudo apt-get install logwatch
Configure Logwatch
Once you have installed Logwatch, you will need to configure it to email you the reports it generates. You are encouraged to look through the entire configuration, but you may safely use Logwatch after editing the lines below.File: /usr/share/logwatch/default.conf/logwatch.conf
Output = mail
Format = html
MailTo = rajat@yeswedeal.com
MailFrom = logwatch@yeswedeal.com
Issue the following command to test your logwatch installation:
logwatchOnce you have issued this command, you will need to check your email to make sure that logwatch is working. Be sure to check your spam folder as these emails may be seen as spam.
Adding a Cron Job for Logwatch
You can add a cron job for Logwatch in order to receive daily emails of new reports. You can add a new entry to your crontab by running crontab -e. The following example cron job runs Logwatch at 1 AM each day, issuing you an email report of the daily activity:# m h dom mon dow command 0 1 * * * /usr/sbin/logwatchCongratulations! You can now monitor system logs with Logwatch!
Thursday, October 7, 2010
Biggest installed packages in Fedora
Quick tip to see which are the biggest currently installed packages on your Fedora box:
You might also be interested in fslint:
It lists packages by size, and it will autoselect dependencies for packages you want to delete
rpm -qa --queryformat '%10{size}-%{name}-%{version}\n' | sort -k1,1n
You might also be interested in fslint:
yum install fslint
It lists packages by size, and it will autoselect dependencies for packages you want to delete
Subscribe to:
Posts (Atom)