Home  >  Article  >  Operation and Maintenance  >  How to check the installation directory in linux

How to check the installation directory in linux

青灯夜游
青灯夜游Original
2022-03-24 14:45:2116333browse

How to view the installation directory in Linux: 1. Directly execute the "whereis software name" command to view the installation directory; 2. Execute the "ps -ef|grep software name" command to obtain the process number of the software running. Then execute the "ls -l /proc/process ID/cwd" command to view the installation directory.

How to check the installation directory in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Linux method to view the software installation directory

Method 1: whereis the software name

Query MySQL as an example

whereis mysql
# 结果
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

How to check the installation directory in linux

Method 2: ps -ef|grep software name and ls -l /proc/process No./cwd

If the installed software is already running, you can query it based on the software running process number

Take redis as an example

ps -ef|grep redis
# 结果
duni       2246      1  0 Feb19 ?        00:09:09 ./redis-server 127.0.0.1:6379

ls -l /proc/2246/cwd
# 结果,cwd后面不加/
lrwxrwxrwx 1 duni duni 0 Feb 19 17:46 /proc/2246/cwd -> /home/duni/DuniSoftware/redis-3.2.3/src

How to check the installation directory in linux

# The /proc file system is a mechanism used by the kernel and kernel modules to send information to processes (hence the name /proc). This pseudo file system allows you to interact with the kernel's internal data structures, obtain useful information about the process, and change settings on the fly (by changing kernel parameters). Unlike other file systems, /proc exists in memory rather than on the hard disk. The proc file system provides access interfaces to user space in the form of files. These interfaces can be used to obtain information about related components or modify the behavior of components at runtime, so it is a very convenient interface.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check the installation directory in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn