Wednesday, August 30, 2006

 

locate command in Linux

find is pretty complex with lots of option when you just want to know where a file exists and whether it exists, you can then use locate, it is cool ...

say you are looking for a file xyz.xyz, you just type
locate xyz.xyz or locate x*.x* and boom you get the exact of path of all matching files

some usefull options in locats command

The -q option would suppress any other error messages as well

$ locate "*.dat" -q
You could use the -n option to limit the number of returned results to a specific number. E.g. you could ask for only 10 search results by the following command

$ locate "*.c" -n 10
This would return the first 10 files that end in .c that Linux finds.

You could use the -i option in case you wanted to perform a case insensitive search. The case of the filenames would not be considered

$ locate INDEX.HTML -i

 

changing to a non root user

when you are logged on as a normal user and you want to change to a different user you need to execute the following command.

you first log in to the linux box as user1
than at command prompt type the following command
user1@/>sudo bash
password :
now at the prompt type the following
root@>su user2

user2@> --- now u are user 2

 

sudo bash

sudo bash a specil case of using su, it changes you to super user, but with more power than just using su.

 

source .bashrc

When you are logging on as a user who dose not have a home folder to place his .bashrc in, they you can place .bashrc in any folder where the user has access to and use the command source .bashrc to get the same effect as you would have the .bashrc in your home folder.

This page is powered by Blogger. Isn't yours?