Archive for category Ubuntu

Setting autoindent tab and shift width on vim/vi

Vim/vi is a real handy tool for updating any file on many linux destros including the favored ubuntu.
While working you might want to set the tab width [say 4 chars or whatever] along with shift size. Also how about to auto indent whenever you hit enter- all easy..
look for your vimrc – a config file for vim, it would be in

 /etc/vim/vimrc 

by default on ubuntu or
if you do

locate vimrc 

on your terminal it would show you the path,
Then do add the following lines in it

set autoindent
set shiftwidth=4
set tabstop=4

Well, you can change the the value of the tabs and shift as you want it..
happy vim’ing

, , ,

Leave a Comment

VI/VIM not colorizing syntax like html or php

I am brushing my old pc and installing ubuntu on it. As I was installing php-mysql and related packages I noticed that the vim/vi editor is not highlighting html or php syntaxes.
That would be it if you are running a bit older version of the ubuntu. Upgrading vim will take care of the problem:

sudo apt-get install vim-genome
sudo apt-get install vim

then go to the vimrc file and – it would be in /etc/vim/vimrc by default and uncomment the line syntax on

then you should get your vim rocking!

, ,

Leave a Comment

You will have to enable the component called ‘universe’

Have you got this message while using apt-get install on your ubuntu? if so, here is how to get away with it,
go to System->administration->Software Sources and the first tab you would see would be then check on the community maintained opensource (universe)
That would take of it.

, ,

Leave a Comment

Piping ls to cp in unix

Actually this would be a generic implementation. But, as an illustration, if you want to pass the result of ls [list command] to copy, cp, command in unix you can do

ls /some/directory | xargs -i cp {} /new/copy/directory

Just piping the list to cp so that cp can you the listed values to copy.
As you can see this can be implemented to a lot more commands like mv, rm …

, , ,

Leave a Comment

Finding size of the CPU on the Ubuntu – Do I have 32 or 64 bit

Use the command :
more /proc/cpuinfo.
Or you can use lshw for the whole part

Leave a Comment

find specific string from files in unix and show files

This would select and print on the terminal.
Say you want to examine gullele.wordpress.com from all index.html files that are residing in some directory and sub directory
then:
find . -name ‘index.html’ -exec ‘gullele.wordpress.com’ {} \; -print
would list all index.html files with the given content inside them.

, , , ,

Leave a Comment

Regular expression for file and directory listing

I guess ls is a laudable command in the Linux world – the fact that everything is a file, we exploit it in a daily manner.
One usage of the a helpful command on ls is grep for listing regex’d listing.
here is the the simplest command that can list all the files/directories with that start with ‘pe’
First we would be on the directory we want the listing, then we would pipe the listing to grep!

ls | grep "^pe\.*"

Even

ls | grep "^pe" 

would result the same.
One that contains pe would be

ls | grep "pe"

and the one that ends with pe would be

ls | grep "pe$"

Further reading Ubunutu help on grep

, , , , , , , , , , , , ,

Leave a Comment

Adding PECL package in Ubuntu

I remember once enjoying PECL (PHP Extension Community Library)on my machine flourishingly. All of the sudden, I was not able find it – here is how I find out.
Trying to play with the new MongoDb, I had to install the driver from the the repository as

sudo pecl install mongo

This time I got the wrong message of not having the pecl. It was easy though – just

sudo apt-get install php5-dev

As the PECL can be found inside it.
I have read some blogs complaining this one not working and passing the problem through installing the PEAR pachage – WHICH EVER IS EASIER.
Happy PECLing..

Leave a Comment

Adding Path to Environment in Ubuntu

After adding some software or programing language or whatever to ubuntu, mostly using the non-synaptic method, our command line would crave for the new terms ;) .
Here is how to add the new path to the environment
Lets use how to add the tomcat app server after we install it using the tar file.

1. Open the terminal : Application->Accessories->Terminal
2. use your favorite text editor to open /etc/environment in my case I would use view as vi /etc/environment
3. add the path on new line as CATALINA_HOME=”path/to/catalina”
4. save and exit!!
In most cases, the current shell would not see the effect and you may want to open another tab for that or you can use the export command

if we are appending to the existing path variable, we can use the export command as
export PATH = ${PATH}:/path/to/new/location – here the ${PATH} would maintain the existing path information and the colon would be the separator for the paths

, , , , , , , ,

Leave a Comment

Changing default Apache webroot in Ubuntu

By default the webroot for apache/php is in /var/www

To change this, say, to /home/user/workspace/public_html

1 Go to file: /etc/apache2/sites-available/default
2. Change the /var/www to /home/user/workspace/public_html – as simple as this!!

OR,

If you are changing root just to abscond some difficulty from your IDE or just for temporary purpose, you can use the symlik: just open your terminal and -
cd /home/user/workspace/public_html
ln -s /var/www/project project

, , ,

2 Comments

Follow

Get every new post delivered to your Inbox.