English 中文(简体)
不能承认指挥权
原标题:Command cannot be recognized

I wanted to ask a likely very simple question regarding Linux (AlmaLinux-9.2)...

I unpacked the file and I wanted to execute the binary file nerdctl. However, I could not do it if I did not add ./ at the beginning of the command?

pic 1

It is because I need to move or link up this file to another folder /usr/local/bin, so it can be globally used.
But, how can I execute the file without adding ./?

Thanks in advance.

问题回答

In Linux, the reason you need to use ./ before executing a binary in the current directory is related to the PATH environment variable. The PATH variable tells the shell which directories to search for executable files.

The ./ before a command indicates to the shell to look in the current directory for the executable. By default, the current directory (.) is usually not part of the PATH for security reasons. If it were, malicious binaries could be disguised with common command names in directories, and you could inadvertently run them.

如欲操作<代码>nerdctl 在没有预先确定<代码>的情况下从任何地点指挥。

  1. Move or Symlink to a Directory in $PATH: Most system-wide binaries are stored in directories that are included in the PATH variable, such as /usr/local/bin, /usr/bin, etc. If you move or symlink your binary to one of these directories, you can call it from anywhere without the ./ prefix.

    sudo mv nerdctl /usr/local/bin/
    

    OR

    sudo ln -s /path/to/your/nerdctl /usr/local/bin/nerdctl
    
  2. Modify the PATH Variable: This is less recommended because it can introduce the security issues mentioned above, but you could add the directory containing nerdctl to the PATH variable.

    Add this to your ~/.bashrc or ~/.zshrc (depending on your shell):

    export PATH=$PATH:/path/to/the/directory
    




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签