Notes: Common methods for Linux to find the directory where the installation package is located

Source: Internet
Author: User

1. The which command finds out if the relevant command is already in the search path:

$which gcc //shows which directory the C compiler of GNC is installed in

Return:

/usr/bin/gcc

Note: If which does not find the command you are looking for, you can try Whereis, which searches for a larger range of system directories. The which command on some systems does not display files that the user does not have permission to execute.

$which IPPPD
/usr/bin/which:no IPPPD in (/bin:/usr/bin:/sbin:/usr/sbin)
$whereis IPPPD
IPPPD:/USR/SBIN/IPPPD
$ls-L/USR/SBIN/IPPPD
-rwx------1 root root 124924 Feb 3 2000/usr/sbin/ipppd

2. Locate command

The locate command is used to find a file that is faster than the search command, and it requires a database that is built by a daily routine work (crontab) program. Once we have established this database, we can easily search for the required files.

Run First: UpdateDB (in that directory can be placed in the crontab) after the SLOCATE.DB database generated under/var/lib/slocate/can be quickly found. Execute the #updatedb command directly at the command prompt.

$locate signal.h
/usr/include/asm/signal.h
/usr/include/linux/signal.h
/usr/include/signal.h
/usr/include/sys/signal.h

3. rpm

If the user knows they want to find the package name, you can use the following command directly. This command is only available on Linux versions that support RPM, such as Redhat,centos,fedora and SuSE.

$ rpm-q python//Find check if the system has python</p> installed <p>python-1.5.2-27

$rpm-qa| grep python//This is a combination of two commands

Other uses of RPM:

RPM-QA (list all installed packages)
RPM-E Package (remove a bundle)
RPM-QI Package (query for a bundle)
RPM-QF command (query the package name according to the program)
RPM-QL Package (query all installation files for a bundle)

4.yum

Yum has a lot of parameters, and here are the commands for finding packages. But only a specific hairstyle version is supported, the most commonly used command under CentOS

$yum List//list the package you specified, and then add the name of the package you want to find
$yum linst installed//list all installed packages
$yum info installed//list all installed package information

5.whereis

Whereis is the directory where files or commands are found

#whereis pwd//Find the directory where the PWD command resides

6. Find

This command can be used to find out if the system has the specified package installed, and more importantly, to find packages that are not very clear about the package name memory. And I think it's all supported by Linux and UNIX. Find a wide range of search, powerful, and collocation with regular expression, the effect is very good, but it is recommended to narrow the scope of the search, reduce system pressure, after all, when the system files, search time-consuming and resources.

$find/-name "python"//start looking for files and folders that contain the character "Python" from the root directory.

The detailed use of find has the following examples:
# Find. -maxdepth 1-name *.jpg-print-exec Convert in the current directory, look for a depth of one, look for a. jpg ending file, and convert it
# Find/-name *.rpm-exec chmod 755 ' {} ' \; Search for files ending with '. RPM ' and define their permissions
# Find/-name file1 Enter the root file system to search for files and directories from '/'
# Find/-perm-u+s lists all files in a system that use SUID control
# Find/-user User1 search for files and directories belonging to user ' User1 '
# Find/-xdev-name \*.rpm search for files ending with '. RPM ', ignoring removable devices such as optical drives, Czech disks, etc.
# find/home/user1-name ' *.txt ' | Xargs Cp-av--target-directory=/home/backup/--parents Find and copy all files ending with '. txt ' from a directory to another directory
# find/home/user1-name \*.bin in directory '/home/user1 ' search for files with '. Bin '
# find/usr/bin-type f-atime +100 Search execution files that have not been used in the last 100 days
# Find/usr/bin-type f-mtime-10 search for files created or modified within 10 days
# find/var/log-name ' *.log ' | Tar CV--files-from=-| bzip2 > log.tar.bz2 Find all files that end with '. Log ' and make a bzip package

Notes: Common methods for Linux to find the directory where the installation package is located

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.