Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command which

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "the usage of the Linux basic command which". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Which

Search for a command in the environment variable PATH and return the execution file or script location of the command. Only the first result is displayed by default. This requires one or more parameters. For each of its parameters, it prints the full path to the executable that will be executed when the parameter is entered at the shell prompt. It does this by using the same algorithm as bash (1) to search for executable files or scripts in the directory listed in the environment variable path.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Which [options] [-] programname [...]

2. List of options

Option

Description

-v |-V |-- version

Display command version information

-- help

Show help documentation

-a |-all

Output all the results, not just the first one

-- read-alias |-I

Read aliases from stdin and report matching aliases on stdout.

-- skip-alias

Ignore "--read-alias"

-- read-function

Read functions from standard input, output in stdout

-- skip-functions

Ignore "--skip-functions"

-- skip-dot

Ignore directories in PATH that begin with a dot

-- skip-tilde

Skip directories in the path that begin with wavy lines and executables in the home directory.

-- show-dot

If the directory in the path starts with a dot and a matching executable is found for the path, ". / Programname" is printed instead of the full path.

-- show-tilde

When the directory matches the home directory, a wavy line is output. If you call this option as root, ignore this option

-- tty-only

If it is not on TTY, stop the processing option on the right.

3. Return value

It returns the number of failed parameters, or-1 if the Program name is not specified.

4. Examples

1) search instruction

[root@192 /] # which-a ls

Alias ls='ls-- color=auto' / / ls is an alias

/ bin/ls

2) Show all results

[root@192 /] # which-a ll

Alias ll='ls-l-color=auto'

/ bin/ls

/ usr/bin/which: no ll in (/ usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:

/ usr/local/bin:/usr/bin:/bin:/usr/local/src/jdk1.8.0_181/bin:/root/bin)

This is the end of the introduction to "the usage of the Linux basic command which". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report