Tag Info

New answers tagged

0

None of the methods (ls, lsof or cat) in the other answers work for me. If I do: $ nano test.txt This is my winner,: $ pgrep -f -l test 3074 nano test.txt Or, in order to obtain only the PID to use it in programming: $ pgrep -f test 3074 Tested on Kali Linux v1.0.6 (Debian based). Compared to a simple ls, I must admit it is not a so portable ...


1

In order to invoke a command by name, you need to put that symbolic link in one of the directories on the command search path. The environment variable PATH lists the directories in the command search path. The command in your question creates a symbolic link in the current directory, which is not useful. For system-wide commands not provided in a package, ...


0

Aren't you compiling it wrong? Shouldn't it be like: g++ `pkg-config --cflags opencv` -o test.cpp test or g++ `pkg-config --cflags opencv` test.cpp -o test


7

If you bundle your binaries into your own RPMs then it's trivial to get a list of what they are and where they were installed. Example $ rpm -ql httpd| head -10 /etc/httpd /etc/httpd/conf /etc/httpd/conf.d /etc/httpd/conf.d/README /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/userdir.conf /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.modules.d ...


4

An obvious suggestions is to name your binaries or your packages in a special way. So for example you could prefix them with cm-, per your initials as given in this post. If you are installing rpms they need to go into /usr/bin (if they are user level executables), per the FHS. They should not go into /usr/local/bin for example. That is for local installs ...


0

As an option you could create wrapper for your script (a .py file): For example, you have a script runme.py so you can create new file runme to wrap the script: #!/usr/bin/env python import runme and then call the runme.py functionality just by invoking runme in the shell. That is useful for multiplatform scripts, cause on Windows platform you can ...


1

Binaries not part of the system or distribution are usually in /usr/local/bin the directory is usually in the standard $PATH so that your binaries will be found.


3

With GNU find, you could call: find /some/dir -mindepth 1 -maxdepth 1 -type f \ \( -executable -printf 'X%p\0' -o -printf 'F%p\0' \) -o \ -type d -printf 'D%p\0' The output will be a NUL-delimited (NUL is the only character that may not appear in a file path) list of records, the first letter of which identifies the type (X, F, D for executable ...


0

I've just found this ptrace-based chroot reimplementation: PRoot. The bind function is just what i was looking for! This is more reliable than replacing strings in the executable + can be easily used in scripts...


3

perl -pe 's:/usr/share/nmap/:/other/dir/nmap/:g ' /path/to/executable > new-executable /other/dir/nmap should be the same length as /usr/share/nmap. You can pad with / characters if not: perl -pe 's:/usr/share/nmap/:/other//////dir/:g ' /path/to/executable > new-executable The new path cannot be longer. You always have the option to create ...


1

Reference @slm's answer ... A third way to do this might be to create a chrooted sandbox environment for running the executable in which everything other than the executables you want to remap are directed to the real thing. But it would be complicated. But I would advise getting hold of the source code and recompiling. (Or if this is proprietary code, ...


0

There are only 2 methods I'm aware of where you'll be able to accomplish something like this. The 1st involves creating a link in the location that has been hardcoded into the executable. So in your example a link would need to be created at /usr/share/nmap/ re-pointing to whatever other location you want. This approach will require root privileges and ...


0

What I did in a previous life was to carefully edit an executable to replace strings (the replacement must be shorter, fill up with zero characters!), using a binary editor (e.g. hexl-mode in emacs/xemacs). If an executable contains fixed paths, they can often be overridden with environment variables (like TMPDIR, EDITOR/VISUAL, or similar) or by giving ...


0

If you can run python in your shell, the following (ridiculously long) one-liner can be used as well: python -c 'import os;import sys;output = lambda(x) : sys.stdout.write(x + "\n"); paths = os.environ["PATH"].split(":") ; listdir = lambda(p) : os.listdir(p) if os.path.isdir(p) else [ ] ; isfile = lambda(x) : True if os.path.isfile(os.path.join(x[0],x[1])) ...


1

How about this find ${PATH//:/ } -maxdepth 1 -executable The string substitution is used with Bash.


0

In any POSIX shell, without using any external command (assuming printf is built in, if not fall back to echo) except for the final sorting, and assuming that no executable name contains a newline: { set -f; IFS=:; for d in $PATH; do set +f; [ -n "$d" ] || d=.; for f in "$d"/.[!.]* "$d"/..?* "$d"/*; do [ -f "$f" ] && [ -x "$f" ] && printf ...


5

this is not an answer, but it's show binary,command which you could run compgen -c (assuming bash) Other useful compgen -a # will list all the aliases you could run. compgen -b # will list all the built-ins you could run. compgen -k # will list all the keywords you could run. compgen -A function # will list all the functions you could run. compgen -A ...


1

With zsh: whence -pm '*' Or: print -rl -- $commands (note that for commands that appear in more than one component of $PATH, they will list only the first one). If you want the commands without the full paths, and sorted for good measure: print -rl -- ${(ko)commands} (that is, get the keys of that associative array instead of the values).


2

I came up with this: IFS=':';for i in $PATH; do test -d "$i" && find "$i" -maxdepth 1 -executable -type f -exec basename {} \;; done



Top 50 recent answers are included