How To Burn DVD’s from the command line

August 10, 2009

Suppose you want to burn the content of  /my/directory/datas at the root of the DVD, you need to type:

$ growisofs -dvd-compat -input-charset=ISO-8859-1 -Z /dev/hda -R -J -pad “/my/directory/datas”

Remember that input-charset is setted to the right value. If you do not define it, your default system charset will be used.

References

www.debuntu.org


Wget – the downloader for CLI

July 27, 2009

wget as all knows is a downloader for the CLI. It has all the features to be proclaimed as a wonderful download manager. hope anyone has encountered a situation where you want to download a set of files. Just create a file with all the download links and give it to wget.

Create the file

In FireFox use the copy link location command from the context menu (the menu you get while doing a right click. Please correct me if i am wrong ;) ) and paste it into a file.

WGET IN ACTION

$ wget -cvvv -i download.txt

This will download all the files specified in download.txt to the current location.

Options Explained.

-c – resume support if the server supports the same

-v – verbose mode, displays activity


Getting IP Address using awk

July 19, 2009

Useful for..

  • Scripts
  • Checking IP Address Often

Command

lenny-dhabba:/home/sameer# ifconfig eth1 | awk '/dr:/{gsub(/.*:/,"",$2);print$2}'
169.254.167.101

lenny-dhabba:/home/sameer# ifconfig | awk '/dr:/{gsub(/.*:/,"",$2);print$2}'
192.168.1.8

169.254.167.101

127.0.0.1

Tools

  • ifconfig command
  • awk

Explanation

The command used for finding IP Address is ifconfig, it produces lot of output, what we need is the IP Address of any interface or of all interfaces, for this, we send the output of ifconfig to another command line tool called awk. Awk’s job is to remove the unnecessary things from ifconfig’s output, for this we tell awk using a language it understands. From this language awk interprets it as:

  1. Find a line containing the string “dr” . As we know the second line in ifconfig output contains the IP Address.
  2. Next get the string near to inet addr
  3. Finally print that string

. Hence we get the desired output.

Disadvantages

  • Prints unnecessary new line characters in between
  • There are better ways to print the characters using perl

References


Command line history

July 19, 2009

To view the history of commands of a user.

history

The history of commands are stored in the file .bash_history of user home directory.

To clear complete command line history of a user temporarily for a session.

history -c

Or use space ie.” ” before a command to skip it from being in the history.


Get the total number of lines

July 18, 2009

If you want to know the total number of lines of files in a directory, execute the following line of script in your terminal. You can also save this command in a file and execute.

lines=0; for i in `find . -name “*.php”`; do line=`cat $i | wc -l`; let lines=$lines+$line; done; echo $lines

lines=0; for i in `find /var/www/wordpress -name “*.php”`; do line=`cat $i | wc -l`; let lines=$lines+$line; done; echo $lines

OR

find . -name “*.php” -print0 | xargs -0 wc -l | tail -n1


Get the count of files of a specific file type

July 18, 2009

To know the count of files of a particular type in a directory

find . -name “*.png” | wc -l

find /usr/share/images/ “*.jpg” | wc -l


Retrieve default gnome-panel

July 17, 2009

To retrieve gnome-panel to default if deleted (in etch) or from a customized one (in lenny atleast one panel remains).

gnome-session-remove gnome-panel
gconftool-2 --recursive-unset /apps/panel
gnome-panel &

Note : Commands should be executed in terminal of Gnome.


Migrate SVN repository

July 14, 2009

Steps to migrate SVN repository.

svnadmin dump <location_of_old_repo> > dump_filename

svnadmin load <location_of_new_repo> < dump_filename

Eg:

svnadmin dump /var/svn/myproject > /tmp/myproject.dump

svnadmin create /var/svn/mynewproject

svnadmin load /var/svn/mynewproject < /tmp/myproject.dump

To check everything is okay.

svnadmin verify /var/svn/myproject

svnadmin verify /var/svn/mynewproject


Rebuild deb package from installed files

July 14, 2009

To rebuild Debian package (.deb) from an installation

apt-get install dpkg-repack

dpkg-repack <package_name>

Eg:

dpkg-repack <apache>


Remove a service from all runlevels

July 14, 2009

To remove a service (daemon) from all runlevels.

update-rc.d -f remove <service_name>

Eg:

update-rc.d -f remove exim4


Follow

Get every new post delivered to your Inbox.