Friday, April 24, 2009

Upgrading to Ubuntu 9.04 From 8.10 (Desktop)


Here is the tutorial for upgrading Ubuntu 8.10 (Intrepid Ibex) desktop to latest Ubuntu Linux 9.04 (Jaunty Jackalope) over the Internet.

Ubuntu Linux support direct upgrade Ubuntu 9.04 from Ubuntu 8.10.

Make sure you have all updates applied to Ubuntu 8.10 before you start upgrade. To do this visit:
System -> Administration -> Update Manager







Ubuntu Update Manager

Click on "Install Updates"

Network Upgrade for Ubuntu Desktops over the Network

You can easily upgrade over the network as follows:

Visit System > Administration > Update Manager




Click the Check button to check for new updates.

A message will appear informing you of the availability of the new release.

Click Upgrade.

Follow the on-screen instructions.

Upgrade Ubuntu Server 8.10 to 9.04

ubuntu logo

You can upgrade the server either from console or from network remotely.
Server
Be sure that you have all updates applied to Ubuntu 8.10 server before you upgrade. Type the following command to apply updates:
$ sudo apt-get update
$ sudo apt-get upgrade

WARNING! Backup important data, sql and configuration file before server running the following upgrade commands. The following discussion only applies to the SERVER edition. For Ubuntu 9.04 desktop upgrade click here.

Next, install update-manager-core if it is not already installed:
$ sudo apt-get install update-manager-core


Finally, start the upgrade tool, enter:

$ sudo do-release-upgrade


Now, just follow the on-screen instructions to upgrade your server over ssh session.

Thursday, April 23, 2009

Oracle buys Sun Microsystems



WASHINGTON - SOFTWARE developer Oracle has reached a US$5.6 billion(S$8.4 billion) deal to purchase Sun Microsystems, the two companies announced Monday in a joint communique.

'The acquisition of Sun transforms the IT industry, combining best-in-class enterprise software and mission-critical computing systems,' Oracle's chief executive Larry Ellison said in the statement.

'Oracle will be the only company that can engineer an integrated system - applications to disk - where all the pieces fit and work together so customers do not have to do it themselves,' he said.

'Our customers benefit as their systems integration costs go down while system performance, reliability and security go up.'

Sun chairman Scott McNealy hailed the merger as 'an industry-defining event.'

Company officials said Sun's board of directors have unanimously sanctioned the deal which is expected to close this summer pending approval from the company's stockholders and federal regulators.

Wednesday, April 22, 2009

Upgrade SuSE11.0 to SuSE11.1



Here are the three steps to do this with zypper (the command line package manager):


1. zypper update

Make sure your system is up to date

2. change repos

change all your repositories over to 11.1 recomend you just stick to oss non-oss and packman to avoid problems

3. upgrade

zypper dist-upgrade

Done, you should have now successfully upgraded your system to 11.1. You can check that with
cat /etc/SuSE-release

Analyze apache log with awk



Lets say we want to find the amount of times a specific ip address has hit your webserver,
on this example we are assuming your apache access_log is located in /usr/local/apache/logs

The full command would be:


awk '{print $1}' /usr/local/apache/logs/access.log | sort | uniq -c | sort -fr


and the output would be like this:

155 90.193.xx.xx
154 86.143.xx.xx
109 82.17.xx.xx
85 90.213.xx.xx
74 193.28.xx.xx

How to change the shell



The chsh command can be used to change your shell.

There are other options that may be used as well. To check the available shells on your system, use the following command:

chsh --list

which will produce a list similar to:

/bin/sh
/bin/bash
/sbin/nologin
/bin/ash
/bin/bsh
/bin/ksh
/usr/bin/ksh
/usr/bin/pdksh
/bin/tcsh
/bin/csh

To change the shell to csh, use the command:

chsh -s /bin/csh

To verify the current shell, use the command:

echo $SHELL

Note:
The above example is for the root user. Non-root users are prompted for their password before the shell is changed. These changes will take effect on the next login.

Tips for Cron



In addition to Crontab tutorial here is the post for tips on cron.


Use of operators


An operator allows you to specifying multiple values in a field. There are three operators:

1. The asterisk (*) : This operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month.

2. The comma (,) : This operator specifies a list of values, for example: "1,5,10,15,20, 25".

3. The dash (-) : This operator specifies a range of values, for example: "5-15" days , which is equivalent to typing "5,6,7,8,9,....,13,14,15" using the comma operator.

Disabling Email output:

By default the output of a command or a script (if any produced), will be email to your local email account. To stop receiving email output from crontab you need to append >/dev/null 2>&1.

For example:

0 3 * * * /root/backup.sh >/dev/null 2>&1

To mail output to particluer email account let us say
rdx@nixtrix.co.cc you need to define MAILTO variable to your cron job:

MAILTO="rdx@nixtrix.co.cc"

0 3 * * * /root/backup.sh >/dev/null 2>&1

Task:

To list your crontab jobs use the command
type the following command:
# crontab -l

To remove or erase all crontab jobs use the command:
# crontab -r


Use special string to save time


Instead of the first five fields, you can use any one of eight special strings. It will not just save your time but it will improve readability.

Special string Meaning
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".


Run ntpdate every hour:

@hourly /path/to/ntpdate

Make a backup everyday:


@daily /path/to/backup/script.sh

Understanding /etc/crontab file and /etc/cron.d/* directories

/etc/crontab is system crontabs file. Usually only used by root user or daemons to configure system wide jobs. All individual user must must use crontab command to install and edit their jobs as described above. /var/spool/cron/ or /var/cron/tabs/ is directory for personal user crontab files. It must be backup with users home directory.

Typical /etc/crontab file entries:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

Additionally, cron reads the files in /etc/cron.d/ directory. Usually system daemon such as sa-update or sysstat places their cronjob here. As a root user or superuser you can use following directories to configure cronjobs. You can directly drop your scripts here. run-parts command run scripts or programs in a directory via /etc/crontab

Directory Description
/etc/cron.d/ Put all scripts here and call them from /etc/crontab file.
/etc/cron.daily/ Run all scripts once a day
/etc/cron.hourly/ Run all scripts once an hour
/etc/cron.monthly/ Run all scripts once a month
/etc/cron.weekly/ Run all scripts once a week


Here is a sample shell script (clean.cache) to clean up cached files every 10 days. This script is directly created at /etc/cron.daliy/ directory i.e. create a file called /etc/cron.daily/clean.cache:

#!/bin/bash
CROOT="/tmp/cachelighttpd/"
DAYS=10
LUSER="lighttpd"
LGROUP="lighttpd"

# start cleaning
/usr/bin/find ${CROOT} -type f -mtime +${DAYS} | xargs -r /bin/rm

# if directory deleted by some other script just get it back
if [ ! -d $CROOT ]
then
/bin/mkdir -p $CROOT
/bin/chown ${LUSER}:${LGROUP} ${CROOT}
fi

Job Automation under Linux/Unix machines



Cron
jobs are used to schedule commands to be executed periodically i.e. to setup commands which will repeatedly run at a set time, you can use the cron jobs.


crontab is the command used to install, deinstall or list the tables used to drive the cron daemon in Vixie Cron. Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. You need to use crontab command for editing or setting up your own cron jobs.

To edit your crontab file, type the following command:
$ crontab -e

Syntax of crontab

Your cron job looks like as follows:
1 2 3 4 5 /path/to/command arg1 arg2

Where,

* 1: Minute (0-59)
* 2: Hours (0-23)
* 3: Day (0-31)
* 4: Month (0-12 [12 == December])
* 5: Day of the week(0-7 [7 or 0 == sunday])
* /path/to/command - Script or command name to schedule

Same above five fields structure can be easily remembered with following diagram:

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)


Example(s)
If you wished to have a script named /root/backup.sh run every day at 3am, my crontab entry would look like as follows:

(a) Install your cronjob:
# crontab -e

(b)Append following entry:
0 3 * * * /root/backup.sh

Run five minutes after midnight, every day:
5 0 * * * /path/to/command

Run at 2:15pm on the first of every month:
15 14 1 * * /path/to/command

Run at 10 pm on weekdays:
0 22 * * 1-5 /path/to/command

Run 23 minutes after midnigbt, 2am, 4am ..., everyday
:23 0-23/2 * * * /path/to/command

Run at 5 after 4 every sunday
:5 4 * * sun /path/to/command

logout - Linux Man Page

SYNTAX
logout [n]

Exit a login shell.

Returns a status of n to the shell's parent.

A login shell, is your topmost shell, and is started when you log in.

When you terminate a login shell (via the commands `exit', `logout,' or the end of file [^D]), you are logged out completely.

Sub-Shells

A `sub-shell' is a shell created after login, either by loading a new shell or opening a window with a graphics interface. A sub-shell usually will not accept the command `logout' to terminate, you must use `exit' or ^D.
When you terminate a sub-shell, you are returned to the process or shell that created it.

Example (starting from a bash shell)
$ tcsh
% # now in the tcsh shell
% exit
$ # now back in the bash shell
$ logout

"We want the finest wines available to humanity. And we want them here and we want them now" - Bruce Robinson / Withnail and I

Related:

exit - Exit session
- End of File
logname - Print current login name
Equivalent Windows command: EXIT - Quit the CMD shell

ln - Linux Man Page

SYNOPSIS
ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
ln [OPTION]... TARGET (2nd form)
ln [OPTION]... TARGET... DIRECTORY (3rd form)
ln [OPTION]... -t DIRECTORY TARGET... (4th form)

DESCRIPTION
In the 1st form, create a link to TARGET with the name LINK_NAME. In
the 2nd form, create a link to TARGET in the current directory. In the
3rd and 4th forms, create links to each TARGET in DIRECTORY. Create
hard links by default, symbolic links with --symbolic. When creating
hard links, each TARGET must exist.

Mandatory arguments to long options are mandatory for short options
too.

--backup[=CONTROL]
make a backup of each existing destination file

-b like --backup but does not accept an argument

-d, -F, --directory
allow the superuser to attempt to hard link directories (note:
will probably fail due to system restrictions, even for the
superuser)

-f, --force
remove existing destination files

-n, --no-dereference
treat destination that is a symlink to a directory as if it were
a normal file

-i, --interactive
prompt whether to remove destinations

-s, --symbolic
make symbolic links instead of hard links

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
specify the DIRECTORY in which to create the links

-T, --no-target-directory
treat LINK_NAME as a normal file

-v, --verbose
print name of each linked file

--help display this help and exit

make numbered backups

existing, nil
numbered if numbered backups exist, simple otherwise

simple, never
always make simple backups

Basic Linux Commands





Command

Example

Description


cat


Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.


cat .bashrc

Sends the contents of the ".bashrc" file to the screen.

cd


Change directory


cd /home

Change the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home".


cd httpd

Change the current working directory to httpd, relative to the current location which is "/home". The full path of the new working directory is "/home/httpd".


cd ..

Move to the parent directory of the current directory. This command will make the current working directory "/home.


cd ~

Move to the user's home directory which is "/home/username". The '~' indicates the users home directory.

cp


Copy files


cp myfile yourfile

Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists.


cp -i myfile yourfile

With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten.


cp -i /data/myfile .

Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file.


cp -dpr srcdir destdir

Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.

dd

dd if=/dev/hdb1 of=/backup/

Disk duplicate. The man page says this command is to "Convert and copy a file", but although used by more advanced users, it can be a very handy command. The "if" means input file, "of" means output file.

df


Show the amount of disk space used on each mounted filesystem.

less

less textfile

Similar to the more command, but the user can page up and down through the file. The example displays the contents of textfile.

ln


Creates a symbolic link to a file.


ln -s test symlink

Creates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test.

locate


A fast database driven file locator.


slocate -u

This command builds the slocate database. It will take several minutes to complete this command. This command must be used before searching for files, however cron runs this command periodically on most systems.


locate whereis

Lists all files whose names contain the string "whereis".

logout


Logs the current user off the system.

ls


List files


ls

List files in the current working directory except those starting with . and only show the file name.


ls -al

List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp

more


Allows file contents or piped output to be sent to the screen one page at a time.


more /etc/profile

Lists the contents of the "/etc/profile" file to the screen one page at a time.


ls -al |more

Performs a directory listing of all files and pipes the output of the listing through more. If the directory listing is longer than a page, it will be listed one page at a time.

mv


Move or rename files


mv -i myfile yourfile

Move the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile".


mv -i /data/myfile .

Move the file from "myfile" from the directory "/data" to the current working directory.

pwd


Show the name of the current working directory


more /etc/profile

Lists the contents of the "/etc/profile" file to the screen one page at a time.

shutdown


Shuts the system down.


shutdown -h now

Shuts the system down to halt immediately.


shutdown -r now

Shuts the system down immediately and the system reboots.

whereis


Show where the binary, source and manual page files are for a command


whereis ls

Locates binaries and manual pages for the ls command.







Editors: emacs, vi, pico, jed, vim


whereis - Linux Man Page

SYNOPSIS
whereis [ -bmsu ] [ -BMS directory... -f ] filename ...

DESCRIPTION
whereis locates source/binary and manuals sections for specified files.
The supplied names are first stripped of leading pathname components
and any (single) trailing extension of the form .ext, for example, .c.
Prefixes of s. resulting from use of source code control are also
dealt with. whereis then attempts to locate the desired program in a
list of standard Linux places.

OPTIONS
-b Search only for binaries.

-m Search only for manual sections.

-s Search only for sources.

-u Search for unusual entries. A file is said to be unusual if it
does not have one entry of each requested type. Thus
`whereis -m -u *' asks for those files in the current direc-
tory which have no documentation.

-B Change or otherwise limit the places where whereis searches for
binaries.

-M Change or otherwise limit the places where whereis searches for
manual sections.

-S Change or otherwise limit the places where whereis searches for
sources.

-f Terminate the last directory list and signals the start of file
names, and must be used when any of the -B, -M, or -S options
are used.

EXAMPLE
Find all files in /usr/bin which are not documented in /usr/man/man1
with source in /usr/src:

example% cd /usr/bin
example% whereis -u -M /usr/man/man1 -S /usr/src -f *

FILES
/{bin,sbin,etc}

/usr/{lib,bin,old,new,local,games,include,etc,src,man,sbin,
X386,TeX,g++-include}

/usr/local/{X386,TeX,X11,include,lib,man,etc,bin,games,emacs}

pwd - Linux Man page

SYNOPSIS
pwd [OPTION]

DESCRIPTION
Print the full filename of the current working directory.

--help display this help and exit

--version
output version information and exit

NOTE: your shell may have its own version of pwd, which usually super-
sedes the version described here. Please refer to your shell's docu-
mentation for details about the options it supports.

COPYRIGHT
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

mv - Linux Man Page

SYNOPSIS
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options
too.

--backup[=CONTROL]
make a backup of each existing destination file

-b like --backup but does not accept an argument

-f, --force
do not prompt before overwriting

-i, --interactive
prompt before overwrite

--strip-trailing-slashes
remove any trailing slashes from each SOURCE argument

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY

-T, --no-target-directory
treat DEST as a normal file

-u, --update
move only when the SOURCE file is newer than the destination
file or when the destination file is missing

-v, --verbose
explain what is being done

--help display this help and exit

--version
output version information and exit

The backup suffix is `~', unless set with --suffix or SIM-
PLE_BACKUP_SUFFIX. The version control method may be selected via the
--backup option or through the VERSION_CONTROL environment variable.
Here are the values:

none, off
never make backups (even if --backup is given)

REPORTING BUGS
Report bugs to .

COPYRIGHT
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

more -Linux Man Page

SYNOPSIS
more [-dlfpcsu] [-num] [+/ pattern] [+ linenum] [file ...]

DESCRIPTION
More is a filter for paging through text one screenful at a time. This
version is especially primitive. Users should realize that less(1) pro-
vides more(1) emulation and extensive enhancements.

OPTIONS
Command line options are described below. Options are also taken from
the environment variable MORE (make sure to precede them with a dash
(``-'')) but command line options will override them.

-num This option specifies an integer which is the screen size (in
lines).

-d more will prompt the user with the message "[Press space to con-
tinue, 'q' to quit.]" and will display "[Press 'h' for instruc-
tions.]" instead of ringing the bell when an illegal key is
pressed.

-l more usually treats ^L (form feed) as a special character, and will
pause after any line that contains a form feed. The -l option will
prevent this behavior.

-f Causes more to count logical, rather than screen lines (i.e., long
lines are not folded).

-p Do not scroll. Instead, clear the whole screen and then display
the text.

-c Do not scroll. Instead, paint each screen from the top, clearing
the remainder of each line as it is displayed.

-s Squeeze multiple blank lines into one.

-u Suppress underlining.

+/ The +/ option specifies a string that will be searched for before
each file is displayed.

+num Start at line number num.

COMMANDS
Interactive commands for more are based on vi(1). Some commands may be
preceded by a decimal number, called k in the descriptions below. In the
following descriptions, ^X means control-X.

h or ? Help: display a summary of these commands. If you forget all
the other commands, remember this one.

SPACE Display next k lines of text. Defaults to current screen
size.

z Display next k lines of text. Defaults to current screen

f Skip forward k screenfuls of text. Defaults to 1.

b or ^B Skip backwards k screenfuls of text. Defaults to 1. Only
works with files, not pipes.

' Go to place where previous search started.

= Display current line number.

/pattern Search for kth occurrence of regular expression. Defaults to
1.

n Search for kth occurrence of last r.e. Defaults to 1.

! or :!
Execute in a subshell

v Start up an editor at current line. The editor is taken from
the environment variable VISUAL if defined, or EDITOR if
VISUAL is not defined, or defaults to "vi" if neither VISUAL
nor EDITOR is defined.

^L Redraw screen

:n Go to kth next file. Defaults to 1.

:p Go to kth previous file. Defaults to 1.

:f Display current file name and line number

. Repeat previous command

ENVIRONMENT
More utilizes the following environment variables, if they exist:

MORE This variable may be set with favored options to more.

SHELL Current shell in use (normally set by the shell at login
time).

TERM Specifies terminal type, used by more to get the terminal
characteristics necessary to manipulate the screen.

ls -Linux Man Page

SYNOPSIS
ls [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort.

Mandatory arguments to long options are mandatory for short options
too.

-a, --all
do not ignore entries starting with .

-A, --almost-all
do not list implied . and ..

--author
with -l, print the author of each file

-b, --escape
print octal escapes for nongraphic characters

--block-size=SIZE
use SIZE-byte blocks

-B, --ignore-backups
do not list implied entries ending with ~

-c with -lt: sort by, and show, ctime (time of last modification of
file status information) with -l: show ctime and sort by name
otherwise: sort by ctime

-C list entries by columns

--color[=WHEN]
control whether color is used to distinguish file types. WHEN
may be `never', `always', or `auto'

-d, --directory
list directory entries instead of contents, and do not derefer-
ence symbolic links

-D, --dired
generate output designed for Emacs' dired mode

-f do not sort, enable -aU, disable -ls --color

-F, --classify
append indicator (one of */=>@|) to entries

--file-type
likewise, except do not append `*'

-G, --no-group
in a long listing, don't print group names

-h, --human-readable
with -l, print sizes in human readable format (e.g., 1K 234M 2G)

--si likewise, but use powers of 1000 not 1024

-H, --dereference-command-line
follow symbolic links listed on the command line

--dereference-command-line-symlink-to-dir
follow each command line symbolic link that points to a direc-
tory

--hide=PATTERN
do not list implied entries matching shell PATTERN (overridden
by -a or -A)

--indicator-style=WORD
append indicator with style WORD to entry names: none (default),
slash (-p), file-type (--file-type), classify (-F)

-i, --inode
print the index number of each file

-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN

-k like --block-size=1K

-l use a long listing format

-L, --dereference
when showing file information for a symbolic link, show informa-
tion for the file the link references rather than for the link
itself

-m fill width with a comma separated list of entries

-n, --numeric-uid-gid
like -l, but list numeric user and group IDs

-N, --literal
print raw entry names (don't treat e.g. control characters spe-
cially)

-o like -l, but do not list group information

-p, --indicator-style=slash
append / indicator to directories

-q, --hide-control-chars
print ? instead of non graphic characters

-r, --reverse
reverse order while sorting

-R, --recursive
list subdirectories recursively

-s, --size
print the size of each file, in blocks

-S sort by file size

--sort=WORD
sort by WORD instead of name: none -U, extension -X, size -S,
time -t, version -v

--time=WORD
with -l, show time as WORD instead of modification time: atime
-u, access -u, use -u, ctime -c, or status -c; use specified
time as sort key if --sort=time

--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso,
locale, +FORMAT. FORMAT is interpreted like `date'; if FORMAT
is FORMAT1FORMAT2, FORMAT1 applies to non-recent files
and FORMAT2 to recent files; if STYLE is prefixed with `posix-',
STYLE takes effect only outside the POSIX locale

-t sort by modification time

-T, --tabsize=COLS
assume tab stops at each COLS instead of 8

-u with -lt: sort by, and show, access time with -l: show access
time and sort by name otherwise: sort by access time

-U do not sort; list entries in directory order

-v sort by version

-w, --width=COLS
assume screen width instead of current value

-x list entries by lines instead of by columns

-X sort alphabetically by entry extension

-Z, --context
print any SELinux security context of each file

-1 list one file per line

--help display this help and exit

--version

Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.

COPYRIGHT
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


locate - Linux Man Page



SYNOPSIS

locate [-d path | --database=path] [-e | --existing] [-i | --ignore-case ] [--version] [--help] pattern...
DESCRIPTION
This manual page documents the GNU version of locate. For each given pattern, locate searches one or more databases of file names and displays the file names that contain the pattern. Patterns can contain shell-style metacharacters: `*', `?', and `[]'. The metacharacters do not treat `/' or `.' specially. Therefore, a pattern `foo*bar' can match a file name that contains `foo3/bar', and a pattern `*duck*' can match a file name that contains `lake/.ducky'. Patterns that contain metacharacters should be quoted to protect them from expansion by the shell. If a pattern is a plain string --- it contains no metacharacters --- locate displays all file names in the database that contain that string anywhere. If a pattern does contain metacharacters, locate only displays file names that match the pattern exactly. As a result, patterns that contain metacharacters should usually begin with a `*', and will most often end with one as well. The exceptions are patterns that are intended to explicitly match the beginning or end of a file name. The file name databases contain lists of files that were on the system when the databases were last updated. The system administrator can choose the file name of the default database, the frequency with which the databases are updated, and the directories for which they contain entries; see updatedb(1L).
OPTIONS

-d path, --database=path
Instead of searching the default file name database, search the file name databases in path, which is a colon-separated list of database file names. You can also use the environment variable LOCATE_PATH to set the list of database files to search. The option overrides the environment variable if both are used. The file name database format changed starting with GNU find and locate version 4.0 to allow machines with diffent byte orderings to share the databases. This version of locate can automatically recognize and read databases produced for older versions of GNU locate or Unix versions of locate or find.
-e, --existing
Only print out such names that currently exist (instead of such names that existed when the database was created). Note that this may slow down the program a lot, if there are many matches in the database.
-i, --ignore-case
Ignore case distinctions in both the pattern and the file names.
--help
Print a summary of the options to locate and exit.
--version
Print the version number of locate and exit.


ENVIRONMENT

LOCATE_PATH
Colon-separated list of databases to search.