date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,305,731,391,000
When I run a command through strace utility I can see access errors such as access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) Now I've read somewhere that what's happening on the above line is that a linker is looking for optimized version of the command that I'm running but can't find ...
You probably don’t want to “solve” this problem; according to the Debian glibc manpage for ld.so, /etc/ld.so.nohwcap When this file is present the dynamic linker will load the non-optimized version of a library, even if the CPU supports the optimized version. It’s not installed by a package, it can be create...
Where to get "/etc/ld.so.nohwcap" file from? [duplicate]
1,305,731,391,000
While both are called "linker" and are used to link binaries, I can't really figure out how they differ from each other. Can anyone tell me their differences?
Without getting too technical: Both are "linkers", i.e. a tool that combines/loads a piece of compiled code with/into another piece of compiled code. ld is a static linker, while ld.so is a dynamic linker. The letters so are, I believe, short for "shared object", and you'll usually see it as a file name suffix of sha...
Difference between 'ld' and 'ld.so'?
1,305,731,391,000
I have an application that reads a file. Let's call it processname and the file ~/.configuration. When processname runs it always reads ~/.configuration and can't be configured differently. There are also other applications that rely on "~/.configuration", before and after, but not while processname is running. Wrappi...
In recent versions of Linux, you can unshare the mount namespace. That is, you can start processes that view the virtual file system differently (with file systems mounted differently). That can also be done with chroot, but unshare is more adapted to your case. Like chroot, you need superuser priviledged to unshare t...
Making a process read a different file for the same filename
1,305,731,391,000
With two files, one compiled and linked with gcc and the other manually with nasm and ld I get ELF 32-bit LSB shared object ... ELF 32-bit LSB executable ... What's the difference between these two things? I can see with readelf -h that one is Type: DYN (Shared object file) Type: EXEC (Executable file) I can see ...
It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN. You can disable the generation of PIE executables with gcc -no-pie If you're seeing this check the default options gcc i...
What is the difference between "LSB executable" (ET_EXEC) and "LSB shared object" (ET_DYN)?
1,305,731,391,000
I have a question about overwriting a running executable, or overwriting a shared library (.so) file that's in use by one or more running programs. Back in the day, for the obvious reasons, overwriting a running executable didn't work. There's even a specific errno value, ETXTBSY, that covers this case. But for quite...
It depends on the kernel, and on some kernels it might depend on the type of executable, but I think all modern systems return ETXTBSY (”text file busy“) if you try to open a running executable for writing or to execute a file that's open for writing. Documentation suggests that it's always been the case on BSD, but i...
Overwriting a running executable or .so
1,305,731,391,000
Running example C code is a painful exercise unless it comes with a makefile. I often find myself with a C file containing code that supposedly does something very cool, but for which a first basic attempt at compilation (gcc main.c) fails with— main.c:(.text+0x1f): undefined reference to `XListInputDevices' clang-3.7...
The question is how to determine what linker flag to use from inspection of the source file. The example below will work for Debian. The header files are the relevant items to note here. So, suppose one has a C source file containing the header #include <X11/extensions/XInput.h>. We can do a search for XInput.h using...
How can I find out what linker flags are needed to use a given C library function?
1,305,731,391,000
I use LD_PRELOAD to overwrite the read function. For a minimal test application it works fine, but if I test it with a larger application it does not work anymore. Also LD_DEBUG=all does not show anything at all: LD_DEBUG=all LD_PRELOAD=./lib.so ./big_app This just runs ./big_app and LD_PRELOAD has no effect. Is ther...
This answer is only valid for a GNU/Linux environment. From comments, OP's binary has privilege features added to it: capabilities. This switchs ld.so(8) into secure-execution mode which by default disables most dynamic-linker related environment variables, including LD_PRELOAD and LD_DEBUG. Secure-execution mode For...
LD_PRELOAD does not work and LD_DEBUG shows nothing
1,305,731,391,000
I'm trying to override malloc/free functions for the program, that requires setuid/setgid permissions. I use the LD_PRELOAD variable for this purpose. According to the ld documentation, I need to put my library into one of the standard search directories (I chose /usr/lib) and give it setuid/setgid permissions. I've d...
According to the ld documentation, I need to put my library into one of the standard search directories (I chose /usr/lib) That was the mistake. You should've put it in /usr/lib64 (assuming that your machine is a x86_64). I've just tried the recipe from the manpage on a Centos 7 VM (which should be ~identical to RHE...
LD_PRELOAD for setuid binary
1,305,731,391,000
I have Fedora 27. I am building something from source. (It is https://github.com/xmrig/xmrig-nvidia if that matters). Make gets to linking and then fails with this message: /usr/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status The packages libstdc++ and libstdc++-devel are installed. Their 32-b...
Okay, I found what file it's looking for using strace, and the answer was libstdc++.a , so I fixed it by installing the libstdc++-static package
Fedora 27 /usr/bin/ld: cannot find -lstdc++
1,305,731,391,000
I am wondering if I can keep the entries in /etc/ld.so.conf sorted. My ld.so.conf looks now like this: /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/lib64/Xaw3d /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/lib/Xaw3d /usr/x86_64-suse-linux/lib /usr/local/lib /opt/kde3/lib /usr/local/lib64 /opt/kde3/lib64 /lib64 /lib /usr/li...
The entries in /etc/ld.so.conf are searched in order. Therefore, order matters. This only matters if the same library name (precisely speaking, the same SONAME) is present in multiple directories. If there are directories that you are absolutely sure will never contain the same library then you can put them in the ord...
Is it OK to sort /etc/ld.so.conf
1,305,731,391,000
The NASM docs on "elf Extensions to the GLOBAL Directive" say, Optionally, you can control the ELF visibility of the symbol. Just add one of the visibility keywords: default, internal, hidden, or protected. The default is default of course. Where are these defined? and how does ld use them? I see access levels menti...
It seems from the NASM source these seem to correspond with the docs from Oracle "Linker and Libraries Guide", these seem to correspond to STV_DEFAULT, STV_INTERNAL, STV_HIDDEN, and STV_PROTECTED. Oracle says this: STV_DEFAULT The visibility of symbols with the STV_DEFAULT attribute is as specified by the symbol's b...
What are difference between the ELF symbol visibility levels?
1,305,731,391,000
In the man page for ld.so(8), it says that When resolving library dependencies, the dynamic linker first inspects each dependency string to see if it contains a slash (this can occur if a library pathname containing slashes was specified at link time). If a slash is found, then the dependency string is interpreted as...
If we (for the moment) ignore the gcc or linking portion of the question and instead modify a binary with patchelf on a linux system $ ldd hello linux-vdso.so.1 => (0x00007ffd35584000) libhello.so.1 => not found libc.so.6 => /lib64/libc.so.6 (0x00007f02e4f6f000) /lib64/ld-linux-x86-64....
How to link to a shared library with a relative path?
1,305,731,391,000
I am using a third party .NET Core application (a binary distribution used by a VS Code extension) that unfortunately has diagnostic logging enabled with no apparent way to disable it (I did already report this to the authors). The ideal solution (beside being able to disable it), would be if I could specify to system...
In short, have your library loaded by LD_PRELOAD override syslog(3) rather than connect(3). The /dev/log Unix socket is used by the syslog(3) glibc function, which connects to it and writes to it. Overriding connect(3) probably doesn't work because the syslog(3) implementation inside glibc will execute the connect(2) ...
How to prevent a process from writing to the systemd journal?
1,305,731,391,000
When using the ldd command there is an option, -u, to print unused direct dependencies as stated in the on-line help. For example: ldd -u /bin/gcc Unused direct dependencies: /lib64/libm.so.6 /lib64/ld-linux-x86-64.so.2 What are "unused direct dependencies"? Why are they unused? Why are they depend...
They are dependencies because the binary lists them as dependencies, as “NEEDED” entries in its dynamic section: readelf -d /usr/bin/gcc will show you the libraries gcc requests. They are unused because gcc doesn’t actually need any of the symbols exported by the libraries in question. In ld-linux-x86-64.so.2’s case,...
What does "unused direct dependencies" mean?
1,305,731,391,000
I didn't exactly find something about the following in the man-page. How is the supposed behavior in subprocesses spawned by a process which was itself spawned by stdbuf? E.g.: stdbuf -oL myprog From the code, I get that it sets LD_PRELOAD, and as far as I know, all environment variables are inherited in any subproce...
straceing the execve (with environ) and write system calls can help see what's going on: Here with the stdbuf of GNU coreutils 8.25. I beleive FreeBSD's stdbuf works similarly: exec and no fork: $ env -i strace -s200 -vfe execve,write /usr/bin/stdbuf -o0 /usr/bin/env /usr/bin/env > /dev/null execve("/usr/bin/stdbuf", ...
stdbuf supposed behavior for subprocesses
1,305,731,391,000
The dynamic linker can be run either indirectly by running some dynamically linked program or shared object (in which case no command-line options to the dynamic linker can be passed and, in the ELF case, the dynamic linker which is stored in the .interp section of the program is executed) or directly by running: /li...
Try using full path for ls: [ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 /usr/bin/ls afile [ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 ls ls: error while loading shared libraries: ls: cannot open shared object file [ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 anyinexistentcommandhere anyinexistentcommandhere: err...
How to run programs with ld-linux.so?
1,305,731,391,000
I know that ELF executable files need to have a visible _start subroutine where the execution begins. However, from what I can understand, the Kernel actually calls in ld-linux.so (or some other interpreter) and hand over the execution to it. So, my questions are: Who mandates the _start entrypoint? How does the kern...
The entry point is conventionally named _start, and is defined in the C runtime assembly routine that is linked into the executable. This short piece of code is responsible for setting up the stack, possibly calling C++ constructors, and finally calling main. The definitive answer to where a program starts execution i...
What mandates the _start entrypoint (kernel, ld-linux.so, etc.)?
1,305,731,391,000
I installed ATLAS (with Netlib LAPACK) in a Docker image, and now every time I run ldconfig, I get the following errors: ldconfig: Can't link /usr/local/lib//usr/local/lib/libtatlas.so to libtatlas.so ldconfig: Can't link /usr/local/lib//usr/local/lib/libsatlas.so to libsatlas.so Of course, /usr/local/lib//usr/local/...
For some reason, probably related to the way the libraries were built (and more specifically, linked), they’ve stored their installation directory in their soname: thus libtatlas.so’s soname is /usr/local/lib/libtatlas.so. ldconfig tries to link libraries to their soname, if it doesn’t exist, in the same directory: it...
ldconfig cannot link to specific files
1,305,731,391,000
I installed zeromq 3.2.5 from source $ wget http://download.zeromq.org/zeromq-3.2.5.tar.gz $ tar xf zeromq-3.2.5.tar.gz $ cd zeromq-3.2.5 $ ./configure && make -j4 $ sudo make install This installs libzmq.so.3 into /usr/local/lib: $ sudo updatedb $ locate libzmq.so.3 /usr/local/lib/libzmq.so.3 /usr/local/lib/libzmq...
When you add new libraries to the system directories you may need to refresh the linker cache with ldconfig This needs to be run as root. Without this command the runtime linker will have a stale idea of what libraries are available. You similarly need to do this if you decide to add new directories to the system lin...
ld can't find .so
1,305,731,391,000
I'm having trouble linking the Intel MKL libraries to use in building Julia with MKL support. I've had this problem with other projects as well, but here I'll focus on Julia. I have MKL installed in /opt/intel. I've tried: Running /opt/intel/bin/compilervars.sh intel64 Running /opt/intel/mkl/bin/mklvars.sh intel64 Ad...
LD_LIBRARY_PATH and files in /etc/ld.so.conf.d configure the runtime linker, not the linker used during builds. To build Julia with MKL, you should add USE_INTEL_MKL = 1 to Make.user run source /opt/intel/bin/compilervars.sh intel64 and build Julia from the same shell (so that the variables set by compilervars are ...
ld linker ignores LD_LIBRARY_PATH
1,305,731,391,000
There are at least two standards of Executable and Linkable Format (ELF), one of them System V Application Binary Interface AMD64 Architecture Processor Supplement (With LP64 and ILP32 Programming Models) Version 1.0 Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2 The old...
The TIS/ELF one covers ELF in general, while the System V ABI is a supplement which documents the x86_64 Application Binary Interface. The second document does not contain any information about x86_64 since the architecture didn't exist at the time it was written.
Different standards of ELF (SysV vs TIS) and Linux?
1,305,731,391,000
My shared library libnew.so uses some symbols form an already built third-party shared library libold.so. I would like to build an executable binary file that should be only linked against libnew.so. But it still needs to be linked against libold.so too. Otherwise, the linker complains about undefined reference to sy...
What is missing is that your linker command gcc -shared -Wl,-soname,libnew.so.1 -o libnew.so.1.0 *.o -L. -lold does not copy objects from libold.so, but refers to symbols in that file to tell the dynamic loader where it can obtain those symbols. Normally when someone is trying to suppress/hide a given library, they s...
How can I build my shared library (.so) so that symbols from a different shared library are also included? [closed]
1,305,731,391,000
I have an application that needs a modified LD_PRELOAD. I want to start the application using the originally provided rc script, so I can benefit from an automatically updated rc script on an update of the application. I can't modify the original rc script of course, because any change would be lost on the next update...
The best way is probably to create your own rc-script that you will use instead of the "official one". Otherwise, your rc-script probably includes an external "config" file if you check it. The include may look like this: . /etc/default/mydaemon-config So that you can edit /etc/default/mydaemon-config and do someth...
Automatically start an application with a modifed LD_PRELOAD?
1,305,731,391,000
I know that snipersim isn't a very typical "project" but this is more a linux/linking problem than anything else, so I think it goes here. I have also contacted the developers, but have yet to receive an answer. First, for quick explanation of what I'm trying to do: For my master thesis I am using the architectural si...
Cause It seems the '-pie' parameter breaks Sniper compilation. I tried adding it to my home machine and it fails with the exact same error. Removing it from the cluster line and the linker succeeds. As the user siblynx mentioned, OpenSUSE (at least the one in the cluster) enforces executables to use PIE when being lin...
Error while building snipersim: "relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC"
1,305,731,391,000
I am trying to install plexmediaplayer from source. This involves compiling libmpv.so.1 which I've done and installed under /usr/local/lib When I run plexmediaplayer, I get the following error: $ plexmediaplayer plexmediaplayer: error while loading shared libraries: libmpv.so.1: cannot open shared object file: No suc...
It turns out that I (badly?) configured apparmor for plexmediaplayer months ago, which caused the problem upon updating and recompiling.
Cannot find shared object file even though it's in library path
1,305,731,391,000
What is the difference between the 386 and 32 bit options in ld -V? elf32_x86_64 elf_i386 i386linux i386pep i386pe And, where can I find the documentation on these "emulation modes"
The “emulation” selects different linker scripts; you’ll find the scripts themselves in /usr/lib/ldscripts on your system. The emulations you’ve listed correspond to elf32_x86_64: ELF for x64-32, aka x32 — 32-bit x86-64 binaries elf_i386: ELF for i386 — 32-bit i386 binaries i386linux: a.out for i386 i386pep: PE+ for ...
GNU Linker differences between the different 32bit emulation modes?
1,305,731,391,000
I have one secret library built for CentOS 6.5 as a package. I can't build package for CentOS 7.4, make install fails on this line: $ gcc -static -O3 -Wno-long-long -funroll-loops -Wall -g -DLINUX testlib.c -o test-lib -L. -llsh -lstdc++ /usr/bin/ld: cannot find -lstdc++ /usr/bin/ld: cannot find -lc I tried to inves...
Try to install: libstdc++-static glibc-static Starting from Redhat 7/CentOS 7, static libraries was moved to an optional package. In CentOS 6 it was a part of: libstdc++-devel glibc-devel
How to investigate and fix missing libraries and/or skipping incompatible library?
1,305,731,391,000
Working with Fedora 35: I want to run a few different software packages that share a dependency, seemingly Qt. In the shell, I get this response, from Cadence and other software: ImportError: /lib64/libQt5Core.so.5: version `Qt_5_PRIVATE_API' not found (required by /usr/local/lib/python3.10/site-packages/PyQt5-5...
Thanks to the comment by @MarkusMüller, I traced back the issue to another package that had installed PyQt at an unexpected place. The solution was to remove the other package and its dependencies. Then reinstalling Cadence worked and it ran.
ImportError /usr/lib64/libQt5Core.so.5 - in several software packages
1,305,731,391,000
I just did some basic functions in asm that I compile in a shared library. Like : BITS 64 global foo section .text foo: mov rax, 1 ret I compiled with : nasm -f elf64 foo.S -o foo.o && gcc -shared foo.o -o libfoo.so I have a main of test : #include <stdio.h> int foo();...
You need to specify that the foo symbol corresponds to a function: [BITS 64] global foo:function section .text foo: mov rax, 1 ret
Compile shared library from asm code with current sources
1,305,731,391,000
I am trying to understand how to properly setup gcc to find stuff in my environmental variables. Currently I compiled some code, SDL and I added it to my .bashrc and sourced that .bashrc as well. Here's a simple hello program. #include "SDL.h" #include "SDL_ttf.h" #include "SDL_image.h" #include "SDL_mixer.h" #include...
You don't need any environment variables, just pass in right cflags and ldflags that SDL2 wants you to use: gcc main.c `pkg-config --cflags sdl2` -o main `pkg-config --libs sdl2` or either gcc main.c `sdl2-config --cflags` -o main `sdl2-config --libs` Remember: CFLAGS come before LDFLAGS, and LDFLAGS (and library sp...
Using gcc compile flags
1,305,731,391,000
Typically on Debian when you install things from the repository, they just work. It sets up things just fine and life is good. This is great for things that are up to date in the repository. I am building some tools that I would like to manually update from github or mercurial. using cmake or the configure script to b...
Xcode and Fink|Homebrew|MacPorts on Mac OS X have these complications (they just largely hide it from you). There are two aspects to this problem, compiling, and running. Compiling will require a variety of details for any library installed to a custom path. This info for some libraries can be provided by pkg-config, ...
building code from source and adding them to your path
1,672,869,171,000
It's observed that when running a program having setuid bit set, it won't receive some environment variables set on the shell (bash etc.). Several environment variables which get removed this way are LD_PRELOAD, LD_LIBRARY_PATH, LD_ORIGIN_PATH, LD_DEBUG_OUTPUT, LD_PROFILE, LD_USE_LOAD_BIAS, GCONV_PATH. As mentioned in...
Most of these variables are intended for the dynamic linker, or other components of the C library, and it’s the dynamic linker which takes care of removing them when starting setuid binaries. This is documented in the “ENVIRONMENT” section of man ld.so (for the GNU C library): For security reasons, if the dynamic lin...
Which component of linux remove filter environment variables on executing setuid program?
1,672,869,171,000
I'm trying to install KIWI on my RaspBerry Pi. When I attempt a pip install kiwi I get a linking failure, with /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: cannot find -lpython3.6m collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1 So I add the re...
ldconfig doesn’t configure ld, it configures ld.so, the dynamic linker/loader. ld is failing here because it’s looking for libpython3.6m.so; to provide that, you should install the relevant development package (presumably python3-devel).
'LD' can't find library to link, even though 'ldconfig -v' lists the file
1,672,869,171,000
Let's say I have a C++ file called dummy.cpp, and I need to compile it with g++ in such a way that it's being from stdin and g++ spits the compiled binary out to stdout. If only the stdin part is necessary the following command does the trick: $ g++ -x c++ -o dummy - < dummy.cpp Now adding the output part, as far as ...
As was mentioned in the comments, this is because the linker writes the file in stages and then fills in entries in the header area with the sizes and offsets. The ELF format has these values in the early part of the file to make finding the appropriate sections easy and efficient, and as a result, it's natural for t...
Linker error by g++ when compiling to stdout
1,672,869,171,000
/lib # ./ld-musl-x86_64.so.1 --list /usr/lib/libEGL.so.1 ./ld-musl-x86_64.so.1 (0x7f2b06797000) libdl.so.2 => ./ld-musl-x86_64.so.1 (0x7f2b06797000) libm.so.6 => ./ld-musl-x86_64.so.1 (0x7f2b06797000) libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x7f2b06000000) libc.so.6 =...
In musl, the dynamic loader (ld-musl-x86_64.so.1) is the same binary as C library. All the libraries which are shipped in the musl C library (libc, libpthread, librt, libm, libdl, libutil, libxnet, as you discovered) are resolved using the dynamic loader, since it’s already loaded. Tying the loader to the library in t...
musl ld maps libc.so.6 to ld-musl-x86_64.so.1
1,672,869,171,000
As suggested by Zac Anger, i copy this question over here: I have a yocto recipe in which I copy/install some stuff to an image. After that, I want to add a line to the /etc/ld.so.conf file like this, so that the dynamic loader finds my library files: do_install(){ # install some stuff... echo /opt/myStuff/lib >>...
I suppose you want that addition in the /etc/ld.so.conf of your target system, but echo /opt/myStuff/lib >> /etc/ld.so.conf would change that file on your build host. Fortunally, this gives an error. Your target rootfs is $D, so your file would be unter $D/etc/ld.so.conf, but more generally, the file doesn't need to ...
How do I edit '/etc/ld.so.conf' in a yocto recipe?
1,672,869,171,000
I am attempting to install rejoystick, and when I run make, I get this: Making all in src make[1]: Entering directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src' make[2]: Entering directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src' /bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -std=iso9899:...
The build is missing -lX11; to work around that, run ./configure LIBS=-lX11 && make
Make error: DSO missing from command line
1,672,869,171,000
I am testing how dynamic linking works with RUNPATH variable, and trying to run bash in a minimal chroot directory: $ find dir_chroot/ -type f dir_chroot/bin/bash dir_chroot/lib/x86_64-linux-gnu/libc.so.6 dir_chroot/lib/x86_64-linux-gnu/libdl.so.2 dir_chroot/lib/x86_64-linux-gnu/libtinfo.so.5 dir_chroot/lib64/ld-linux...
Apparently, ld-linux-x86-64.so.2 is statically linked, at least it is on my system: >ldd ld-linux-x86-64.so.2 statically linked unlike libc.so.6,libdl.so.2 and libtinfo.so.5 >ldd libc.so.6 libdl.so.2 libtinfo.so.5 libc.so.6: /lib64/ld-linux-x86-64.so.2 (0x000056469847a000) linux-vdso.so.1 => (0x00007ffe95185000) l...
Cannot chroot bash after setting RUNPATH in ld-linux-x86-64.so.2 with patchelf 0.6 and 0.8
1,672,869,171,000
I am attempting to get madplay installed on my shared host I've run: ./configure --prefix=$HOME CPPFLAGS="-I /home/dir/include" LDFLAGS="-L /home/dir/lib" and then "make", but on that on run into an error I can't understand: /home/dir/lib: file not recognized: Is a directory collect2: ld returned 1 exit status make[2...
You should leave out the space between -L and /home/dir/lib in the LDFLAGS setting. As it is the compiler assumes that -L has no argument and /home/dir/lib is a source file. You should probably also remove the space after the -I option, as per the directives for gcc options directory search.
Failed make when installing madplay source
1,672,869,171,000
I try to get a more up to date version of bash from LinuxMint. I have a chroot with Debian Sid in my box. What I try to do in a bash wrapper script, early in my PATH #!/bin/bash LD_LIBRARY_PATH=/path/to/chroot/usr/lib/x86_64-linux-gnu:/path/to/chroot/lib:/path/to/chroot/lib64:/path/to/chroot/var/lib:/path/to/chroot/u...
OK, found a workaround that avoid me to compile bash and the need to maintain it in the future: from chroot # apt install bash-static Then, my upgrade script on LinuxMint: #!/bin/bash if mount | grep -q "/home/sid-chroot"; then chroot /home/sid-chroot <<< 'apt-get -yy update; apt-get -yy upgrade' else debian...
Hacking LD_LIBRARY_PATH to use a recent bash from a chroot
1,672,869,171,000
I'm trying to install mopidy-spotify on my freebox delta that allow me to install vm and is arm64 based After many problems, i've manage to get most of the dependencies working and to get rid of most of the errors. But am still struggling on libspotify when trying to compile pyspotify. I've compiled successfully (i th...
You're most likely trying to mix 32 bit and 64 bit libraries. 32 bit applications must be linked against 32 bit libraries whereas 64 bit applications must be linked against 64 bit libraries. You can run file /usr/local/lib/libspotify.so to check if your library has been compiled for 32 bit or 64 bit. You can instruct ...
pyspotify compilation ld error
1,672,869,171,000
CSAPP says Linux systems provide a simple interface to the dynamic linker that allows application programs to load and link shared libraries at run time. #include <dlfcn.h> void *dlopen(const char *filename, int flag); Returns: pointer to handle if OK, NULL on error Does dlopen() performs dynamic linking by invokin...
dlopen is provided by libdl, but behind the scenes, with the GNU C library implementation at least, the latter relies on symbols provided by ld-linux.so to perform the dynamic linking. If dlopen is called from a dynamically-linked program, ld-linux.so is already loaded, so it uses those symbols directly; if it’s calle...
Does `dlopen()` performs dynamic linking by invoking dynamic linker `ld-linux.so`?
1,672,869,171,000
This question is in continuation of How does compiler lay out code in memory, which is posted at stack-overflow. I have few questions with respect to ld (GNU) utility available in Linux. Whenever a program is run in the shell, say ./a.out, the shell uses ld to load the program represented by a.out. How does the she...
The shell doesn’t know, the kernel does. See What types of executable files exist on Linux? and the linked articles for details. The kernel loader loads the binary, and if necessary, its interpreter (which is ld.so for dynamic binaries). Each implementation of ld.so is format-specific. Yes, either by adding a binary ...
Is loader for a particular "executable format" configurable in Linux?
1,672,869,171,000
I am running cmake and it is passing a flag to my linker that is unrecognized (-rdynamic), and it's causing an error. I cannot figure out where it is getting this flag from, so I want to just filter it out. I can specify -DCMAKE_LINKER=<linker>, so what I would like to do is set <linker> to a program that reads its co...
This bash script loops through its arguments, ignoring those matching the string "-rdynamic", and adding any others to an array. Once it runs out of arguments, it executes ld with the filtered list. #!/bin/bash declare -a finalopts finalopts=() for o in "$@"; do if [ "$o" = "-rdynamic" ] ; then continue...
Filter out command line options before passing to a program
1,672,869,171,000
I have an executable but when I run it I get "No such file or directory" $ chmod a+x bin $ file bin bin: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, not stripped $ ./bin bash: ./bin: No such file or directory Notice that this executable is in fact ELF 64-bit...
This is because I forgot to include the -dynamic-linker options in the call to ld -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 Calling it as such, ld -m elf_x86_64 -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -o bin makes it work fine. For more information from a similar problem with 32-b...
Running a custom-compiled executable returns "No such file or directory"
1,672,869,171,000
I'm using Archlinux. After a recent update, I find that the gdbus doesn't work and it presents a symbol lookup error: ➜ tidedra@ZgrArch ~ gdbus gdbus: symbol lookup error: /usr/lib/libgobject-2.0.so.0: undefined symbol: g_string_free_and_steal Then I thought it was probably a problem about the version of library, s...
I know what's wrong. I checked my PATH and I found that /opt/miniconda/bin was before /usr/bin, which means when I call gdbus in the terminal, it calls /opt/miniconda/bin/gdbus actually, instead of /usr/bin/gdbus, and as you can see, the version of some linked libraries of miniconda gdbus is inconsistent with others. ...
gdbus symbol look up error
1,672,869,171,000
Suppose /usr/lib/x86_64-linux-gnu/ contains libfoo: libfoo.so.2 -> libfoo.so.2.0.0 (symbolic link) libfoo.so.2.0.0 Notably missing is libfoo.so. Suppose there is a program /usr/local/bin/sillyprog that compiles things using something like gcc somefile.c -lfoo. Every time I try to use sillyprog, it will fail with /us...
One option would be to create a link with the correct name to the library in a directory you control. Then you can use the LIBRARY_PATH and LD_LIBRARY_PATH environment variables to point to this directory. These variables influence where the linker and loader look for libraries when compiling or running a program res...
How to link using -lfoo when there are versioned names of libfoo but no libfoo.so
1,672,869,171,000
I am trying to build SimGear from the FlightGear project using the download_an_compile.sh script (which uses CMake to build the binaries). The build went fine so far, but when the script tried linking the built object file together to a library, I get tons of //usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2: warning: und...
At least in Debian (and derivatives thereof), a shared library's development files are split off into a separate binary package: If there are development files associated with a shared library, the source package needs to generate a binary development package named libraryname-dev, or if you need to support multiple ...
Weird linking issue with libldap using cmake
1,672,869,171,000
After installing the an RPM on centos8 I found that the package manager dnf - inexplicably stopped working with a cryptic error: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/libdnf/common_types.py", line 14, in swig_import_helper return importlib.import_module(mname) File "/usr/lib64/pyt...
why is /usr/lib64 not earlier on the search path than entries in ld.so.conf In the absence of any other configuration, the system library paths are the last entries on the search path. I cannot find where /usr/lib64 is configured. Is it hard-coded into LD or the kernel? It’s hard-coded in ld.so, the dynamic linker...
dnf broken by installation - how does /usr/lib64 get on the search path and why isn't it earlier?
1,672,869,171,000
I run Fedora 30 on my laptop. Yesterday I tried to install wine using the following commands: $ sudo dnf config-manager --add-repo https://dl.winehq.org/wine-builds/fedora/30/winehq.repo $ sudo dnf -y install winehq-stable The installation seemed to work, but when I try to launch winecfg $ winecfg /opt/wine-stable/bi...
I fixed this by giving $ sudo sysctl -w vm.mmap_min_addr=0 I found this solution here: https://wiki.winehq.org/Preloader_Page_Zero_Problem
Operation not permitted - libwine.so.1
1,672,869,171,000
I have f30 installed 3 weeks and I keep seeing this error when I try to compile C++ of maybe fortran code. It is an error connected to ld : error: ld returned 126 exit status I've tried to look into it and so far I have no explanation. What I can share is that ld resides in /usr/bin which is a soft link from /etc/alte...
I don't really know why it happened or if it could be fixed otherwise or if it will have an effect somewhere else but I just reinstalled binutils and it seems it solved it. So just type sudo yum reinstall binutils and it should be ok.
Cannot execute ld : error 126
1,672,869,171,000
What are these files /lib/x86_64-linux-gnu/ldscripts/elf32_x86_64.xs /lib/x86_64-linux-gnu/ldscripts/elf_x86_64.xs /lib/x86_64-linux-gnu/ldscripts/elf_i386.xs /lib/x86_64-linux-gnu/ldscripts/elf_iamcu.xs /usr/lib/x86_64-linux-gnu/ldscripts/elf32_x86_64.xs /usr/lib/x86_64-linux-gnu/ldscripts/elf_x86_64.xs /usr/lib/x86_...
They're used to generate an "shlib" script you can see the comment below here # Generate 5 or 6 script files from a master script template in # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 # script files is actually used depends on command line options given # to ld. (SCRIPT_NAME was set in the e...
What is the .xs and .x* files in ldscripts?
1,470,312,180,000
I have installed an SSL certificate from Let's Encrypt with Certbot on my Apache server with Debian 8 following this tutorial from Let's Encrypt's own documentation: https://certbot.eff.org/#debianjessie-apache $ certbot --apache You need to specify the domains where you want to install the certificates for, but I on...
UPDATE: You can now do this by passing the --expand flag (see docs): --expand tells Certbot to update an existing certificate with a new certificate that contains all of the old domains and one or more additional new domains. See this answer for an example. In short: you can't. The domains you specify during the in...
Certbot add www domain to existing domain certificate
1,470,312,180,000
I have certbot installed and successfully use it to encrypt my homepage. Now i tried to setup an email system for my website using dovecot and postfix. I got it mostly running, only problem is, that thunderbird gives me a warning about the adress being fraudulent because I use the ssl key of mysite.com for imap.mysit...
You have to use the --expand option of certbot --expand tells Certbot to update an existing certificate with a new certificate that contains all of the old domains and one or more additional new domains. With the --expand option, use the -d option to specify all existing domains and one or more new domains. Example : ...
How can I add subdomains to letsencrypt using certbots?
1,470,312,180,000
I have an Ubuntu-server 16.04 VPS and Nginx. Now I'm implementing HTTP1 (without TLS, utilizing port 80) but I desire to go "one step forward" and work with HTTP2 (with TLS, utilizing port 443), for all my (Wordpress) websites. Assuming I adjusted my environment, this way: 1. Firewall ufw app list # Choose Nginx HTTPS...
It's easy to create and update Let's Encrypt cerificates with dehydrated (https://github.com/lukas2511/dehydrated). You have to add /.well-known/acme-challenge/ location for each site as Let's Encrypt service will look on challenge responses under this location to verify that you are the owner of sites you have reques...
Automating OpenSSL certificates creation, Let'sEncrypt signing, and site dir associating, in an Nginx environment
1,470,312,180,000
The whole day, I am fixing bugs in mainly TLS area, but this question is not specifically about TLS. Well, I have one web server with a few web sites, each with its own SSL certificate. But to the point, I managed to install Certbot version 0.19.0 on my Debian 9.2 like this: Adding backports to the sources: deb http:...
The actual command run by cron is: test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew It starts by testing some files test -x /usr/bin/certbot -a \! -d /run/systemd/system which translates in does /usr/bin/certbot exist and is executable (-x /usr/bin/certbo...
How to validate / fix an error in Certbot renewal cron
1,470,312,180,000
I am trying to install a Let's Encrypt certificate on a Oracle Linux Server 7.6. Since the server does not have a public IP, I had to validate via DNS.I followed the instructions here https://github.com/joohoi/acme-dns-certbot-joohoi and the validation worked and I got the certificate. How do I now install the certifi...
I believe this should be comparable to CentOS 7.6. The path etc/ssl/certs is simply a symbolic link to /etc/pki/tls/certs/. The certificate is divided into two parts, the first which you have already mentioned is the *.crt file which contains the public key and shall be placed in /etc/pki/tls/certs/ which is in my cas...
Install Let's Encrypt SSL certificate on Oracle Linux Server
1,470,312,180,000
Is there a way to use certbot and letsencrypt certificate for multiserver setup without having to manually copy the certificates from one node to another? I have a domain name example.com which is resolved to 192.0.2.1 in Americas and to 192.0.2.2 in Asia. I run certbot from American server and it successfully generat...
In the end I used solution described here. In a couple of words: Use a single node for certificate generation Use nginx proxy to forward /.well-known/ from all frontends to the node from step 1 Copy with scripts certificates to all frontend servers
Certbot for multiserver configuration
1,470,312,180,000
I would like to create a shell script for getting let's encrypt certificates: #!/bin/bash sudo docker run -it --rm -p 443:443 -p 80:80 --name certbot \ -v "/etc/letsencrypt:/etc/letsencrypt" \ -v "/var/lib/letsencrypt:/var/lib/letsencrypt" \ quay.io/letsencrypt/letsencrypt:latest certonly But now I have t...
Don't reinvent the wheel if you don't have too. Someone else, several people actually, has already created a script to automate the process of getting and renewing letsencrypt certificates using a shell script. LetsEncrypt includes a list of third-party clients here. Because the OP asked about a shell script, this is ...
Is it possible to get letsencrypt certificates with a shell script?
1,470,312,180,000
Assuming I am not close on which web server to use, Apache or Nginx but I still want to be over with the SSL certification procedure, can I install a Let'sEncrypt ssl certificate before I configure a virtual host?
Yes, you can get a Let's Encrypt SSL certificate before your webserver is up and running. Let's Encrypt accepts two kinds of domain validation: Provisioning a DNS record under example.com, or Provisioning an HTTP resource under a well-known URI on http://example.com/ (Source.) You can use the first challenge. All...
Can I install a Let'sEncrypt ssl certificate before I configure a virtual host?
1,470,312,180,000
I started using letsencrypt when there was an "official" client called letsencrypt. I now want to change to acme-client - that is, the C implementation. I think I manage to configure my sites, and find the certificates for them, but I get the error acme-client: https://acme-v01.api.letsencrypt.org/acme/new-authz: bad ...
Another solution, much easier, is to re-register the account using acme-client -DAvv <domain> after having opened port 80 and configured httpd to answer calls with the additional location "/.well-known/acme-challenge/*" { root "/acme" root strip 2 }
Switching from letsencrypt (client) to acme-client - where is my account key?
1,470,312,180,000
# cat /etc/letsencrypt/options-ssl-apache.conf # Baseline setting to Include for SSL sites using Let's Encrypt certificates SSLEngine on # Intermediate configuration, tweak to your needs SSLProtocol -all +TLSv1.1 +TLSv1.2 #SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256...
You will want to use the certonly command: Authenticators are plugins used with the certonly command to obtain a certificate. The authenticator validates that you control the domain(s) you are requesting a certificate for, obtains a certificate for the specified domain(s), and places the certificate in the /e...
How to configure the Certbot not to include options-ssl-apache.conf into my VirtualHosts?
1,470,312,180,000
I've been trying to get a Let's Encrypt certificate, key and chain to work. But I have also done some stuff that I know I didn't need to before I realized what to do. Port 443 wasn't open so I've also been doing some stuff with "ports.conf" but I've changed that back to how it was, I think. I modified the default-ssl....
Make sure to allow ports 80 and 443 in your router. Make sure to forward ports 80 and 443 to your server. Make sure to have punched holes in your firewall: sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT sudo iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT Define VirtualHost for port 443 (as well as ...
Apache problems when trying to set up SSL (Debian)
1,470,312,180,000
Apache webserver on Rocky Linux 9, with SSL certs obtained from LetsEncrypt. This is the config of a specific virtual host "myvhost", but the problem arises for all vhosts on my server: /etc/httpd/conf.d/myvhost.conf: <VirtualHost *:80> ServerName myvhost.example.org DocumentRoot "/var/www/html/myvhost" ...
Run this and inspect the output: for f in $(grep -l -e SSLDirective -e :80 /etc/httpd/conf.d/*.conf) do printf '\n== %s ==\n' "$f" grep -hE 'SSLCertificate|SSLDirective|VirtualHost|Server(Name|Alias)' "$f" | sed -e 's/#.*//' -e '/^[[:space:]]*$/d' done Debian derivatives will need to change /etc/http...
Why is my web server serving HTTPS content on port 80?
1,470,312,180,000
I've followed the guidance from other Stack answers- there's a gazillion related to this- in building my openssl verify command to validate my Let's Encrypt certs, shown below: openssl verify -show_chain /etc/letsencrypt/live/mail.example.com/chain.pem /etc/letsencrypt/live/mail.example.com/cert.pem But it fails wit...
openssl verify -show_chain /etc/letsencrypt/live/mail.example.com/chain.pem /etc/letsencrypt/live/mail.example.com/cert.pem This command is wrong. It will try to verify all the given certificates independently from each other, i.e. not build a trust chain and verify the first. Instead the command should have been:...
Let's Encrypt Certs Fail "openssl verify" Verification
1,470,312,180,000
I have a some internally available servers (all Debian), that share a LetsEncrypt wildcard certificate (*.local.example.com). One server (Server1) keeps the certificate up-to-date and now I'm looking for a process to automatically distribute the .pem-files from Server1 to the other servers (e.g. Server2 and Server3). ...
I've settled on an rsync-only user, that can only rsync data to a predefined directory using ssh-keys (https://gist.github.com/jyap808/8700714). I rsync the files with script that runs after successful letsencrypt deployments. On the receiving servers, I have an inotifywait service running that moves the files to the ...
How to distribute HTTPS certificate/key securely and automatically on internal servers
1,470,312,180,000
So, one of my servers is behind NAT, and since there is already a publicly accessible apache server going on my LAN, I decided to access it from the outside with different ports, and remap them to the standard port of the apache on this new machine I want to get a cert on. I did that with classic port forwarding via m...
It's not possible to use non-standard port, as conforming ACME server will still try to contact default 80 / 443 for http-01 / tls-sni-01 challenges. E.g.certbot has a separate options for to listen to non-standard port, but that still doesn't help to pass the challenge: certonly: Options for modifying h...
Changing the port letsencrypt tries to connect on
1,470,312,180,000
I'm currently trying to share and use my wildcard certificate from letsencrypt with NFS, but the servers who are supposed to use it, cannot do so. To my Setup: I have 3 VM's (in future maybe 4) running. One is a Reverse-proxy, that receives all http and https traffic and redirects them to my Mail server and my Kanboar...
Because the daemons in list run as root (mail and web listen on port <1024) and those daemons try to read from NFS they will have problem because usually NFS shares are done w/o option no_root_squash. The idea is NFS map local (on client) root user as anonymous user with ID not 0. And local root user will have no acce...
Letsencrypt Wildcard certficate with NFS. [U 18.04]
1,470,312,180,000
Recently I've changed logs configuration for letsencrypt, because there was no given one and I have files: letsencrypt.log letsencrypt.log.1 letsencrypt.log.10 letsencrypt.log.10.gz letsencrypt.log.11 letsencrypt.log.11.gz letsencrypt.log.12 letsencrypt.log.12.gz letsencrypt.log.13 letsencrypt.log.13.gz letsencrypt.lo...
Ok, so I've managed to make proper log rotate: /var/log/letsencrypt/*.log { weekly rotate 9 compress delaycompress missingok create 644 root root } So the difference is that I've removed notifempty.
Logs gzipped and not gzipped
1,470,312,180,000
I am trying to install a Let's Encrypt SSL certificate to my website using Securing Apache with Let's Encrypt on CentOS 7. My web server is (include version): Apache (cPanel) My hosting provider is: GoDaddy followed this link for that and STEP-1 and STEP-2 were successful with the understanding that no firewall has be...
What's the problem with doing this?: sudo yum install mod_ssl sudo a2enmod ssl (restart apache then)
Unable to install Let's Encrypt certificate on CentOS 7
1,470,312,180,000
I have an Ubuntu mail server running postfix version 3.6.4. I configured postfix to use ssl by adding the following lines to /etc/postfix/main.cf: # TLS parameters smtpd_tls_cert_file = /etc/letsencrypt/live/host-name.domain.name/fullchain.pem smtpd_tls_key_file = /etc/letsencrypt/live/host-name.domain.name/privkey.pe...
Checking the mail logs will have a line similar to this if postfix is receiving email with encryption... 2022-08-11T19:17:07.707481+01:00 eth6 postfix/smtpd[8401]: Anonymous TLS connection established from mail[1.2.3.4]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signat...
How do I check if my postfix email server is using SSL?
1,470,312,180,000
I have a valid letsencrypt certificate that is used by apache server. <IfModule mod_ssl.c> <VirtualHost *:443> ServerName mydomain.com SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem Include /et...
If you run ps auxw | grep httpd you'll see that while most of the apache webserver processes are owned by www-data, there is one process owned by root. This is the master process which (amongst other things) reads the certificate at startup. Further, if you have a look in the directory /etc/letsencrypt/live you'll fin...
how to access TSL certificate locally
1,375,515,548,000
I have recently discovered that if we press Ctrl+X Ctrl+E, bash opens the current command in an editor (set in $VISUAL or $EDITOR) and executes it when the editor is closed. But it doesn't seem to be documented in the man pages. Is it documented, and if so where?
I have found it out now. I should have read it more carefully before asking this. The man page says: edit-and-execute-command (C-xC-e) Invoke an editor on the current command line, and execute the result as shell commands. Bash attempts to invoke $VISUAL, $EDITOR, and emacs as t...
Where is the bash feature to open a command in $EDITOR documented?
1,375,515,548,000
Currently, I have the following in my .zshrc: bindkey '^[[A' up-line-or-search bindkey '^[[B' down-line-or-search However, this only seems to match the content of my current input before a space character occurs. For example, sudo ls / will match every line in my history that begins with sudo, while I would like it t...
This is the documented behavior: down-line-or-search Move down a line in the buffer, or if already at the bottom line, search forward in the history for a line beginning with the first word in the buffer. There doesn't seem to be an existing widget that does exactly what you want, so you'll have to make your own....
ZSH: search history on up and down keys?
1,375,515,548,000
I was just typing something along the lines of: mv foo/bar/poit/zoid/narf.txt Suddenly I realized, damn, I have to type large parts of that parameter again: mv foo/bar/poit/zoid/narf.txt foo/bar/poit/zoid/troz.txt Even with tab completion, that's quite a pain. I know I can copy-paste the parameter by mouse-selecting...
If I've planned ahead, I use brace expansion. In this case: mv foo/bar/poit/zoid/{narf,troz}.txt Here is another approach using the default readline keyboard shortcuts: mv foo/bar/poit/soid/narf.txt: start Ctrl-w: unix-word-rubout to delete foo/bar/poit/soid/narf.txt Ctrl-y, Space, Ctrl-y: yank, space, yank again t...
How to repeat currently typed in parameter on Bash console?
1,375,515,548,000
I was play around at the bash prompt, and pressed ESC followed by { , after which , the shell showed all the files for completion, in a fileglob string. Eg : If I had typed bash C followed by ESC+{ , the shell would show this : bash CHECK{,1,2{,23{336{,66666},6},3{,6}}} auto-completing all the Possible files & Directo...
To find out about a key binding. In bash: $ bind -p | grep -a '{' "\e{": complete-into-braces "{": self-insert $ LESS='+/complete-into-braces' man bash complete-into-braces (M-{) Perform filename completion and insert the list of possible com‐ pletions enclosed within braces so the list is av...
ESC + { : What is it and where I can know more about it?
1,375,515,548,000
Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to prevent commands in the history from being modified when they're reused and edited. There are questions like this one, but ...
Turns out revert-all-at-newline is the answer. I needed to include set revert-all-at-newline on in my ~/.inputrc file, since using the set command at the bash prompt had no effect. (Then, of course, I had to start a new shell.) Also, I found that ~/.inputrc is loaded instead of /etc/inputrc if present, which means t...
How to stop bash editing the history when I reuse and modify an entry?
1,375,515,548,000
The first two chars were repeated while I use Tab to do completion. In the screenshot below, cd is repeated. I have tried rxvt-unicdoe, xterm, terminator. All these terminal emulators have this issue. Zsh version 5.0.2, config file on-my-zsh
If the characters on your command line are sometimes displayed at an offset, this is often because zsh has computed the wrong width for the prompt. The symptoms are that the display looks fine as long as you're adding characters or moving character by character but becomes garbled (with some characters appearing furth...
First characters of the command repeated in the display when completing
1,375,515,548,000
Putting on Debian 8.3 stty werase '^H' or on Arch Linux 2/2016 stty werase '^?' in .bashrc (for example) makes Ctrl-Backspace delete the last word in the terminal. Still it's not the same behavior as in modern GUI applications (e.g. Firefox): It deletes the last whitespace-separated word, and not the last word separ...
There are two line editors at play here: the basic line editor provided by the kernel (canonical mode tty line editor), and bash's line editor (implemented via the readline library). Both of these have an erase-to-previous-word command which is bound to Ctrl+W by default. The key can be configured for the canonical mo...
Ctrl-Backspace and Ctrl-Delete in bash
1,375,515,548,000
One of my favorite tricks in Bash is when I open my command prompt in a text editor. I do this (in vi mode) by pressing ESC v. When I do this, whatever is in my command prompt is now displayed in my $EDITOR of choice. I can then edit the command as if it were a document, and when I save and exit everything in that tem...
In bind -p listing, I can see the command is called edit-and-execute-command, and is bound to C-xC-e in the emacs mode.
Opening Your Command Prompt In A Text Editor - What Is This Called?
1,375,515,548,000
I am not sure how to word this, but I often I find myself typing commands like this: cp /etc/prog/dir1/myconfig.yml /etc/prog/dir1/myconfig.yml.bak I usually just type out the path twice (with tab completion) or I'll copy and paste the path with the cursor. Is there some bashfoo that makes this easier to type?
There are a number of tricks (there's a duplicate to be found I think), but for this I tend to do cp /etc/prog/dir1/myconfig.yml{,.bak} which gets expanded to your command. This is known as brace expansion. In the form used here, the {} expression specifies a number of strings separated by commas. These "expand" the ...
Bash command to copy before cursor and paste after?
1,375,515,548,000
How to configure zsh such that Ctrl+Backspace kills the word before point? How to achieve that Ctrl+Delete kills the word after point? I use urxvt as terminal emulator.
I'll focus on Ctrl+Delete first. The zsh command to delete a whole word forwards is called kill-word. By default it is bound to Alt+D. How to make Ctrl+Delete do it too depends on which terminal emulator you are using. On my system, this works in xterm and Gnome Terminal: bindkey -M emacs '^[[3;5~' kill-word and for...
zsh kill Ctrl + Backspace, Ctrl + Delete
1,375,515,548,000
I'd like to run the command foo --bar=baz <16 zeroes> How do I type the 16 zeroes efficiently*? If I hold Alt and press 1 6 0 it will repeat the next thing 160 times, which is not what I want. In emacs I can either use Alt-[number] or Ctrl-u 1 6 Ctrl-u 0, but in bash Ctrl-u kills the currently-being-typed line and ...
Try echo Alt+1Alt+6Ctrl+V0 That's 6 key strokes (assuming a US/UK QWERTY keyboard at least) to insert those 16 zeros (you can hold Alt for both 1 and 6). You could also use the standard vi mode (set -o vi) and type: echo 0Escx16p (also 6 key strokes). The emacs mode equivalent and that could be used to repeat more tha...
How do I input n repetitions of a digit in bash, interactively
1,375,515,548,000
I would like to be able to copy and paste text in the command line in Bash using the same keyboard bindings that Emacs uses by default (i.e. using C-space for set-mark, M-w to copy text, C-y, M-y to paste it, etc.). The GNU Bash documentation says that Bash comes with some of these key bindings set up by default. For...
It doesn't highlight the selection, but otherwise I think it works fine. Try running $ bind -p | grep copy-region-as-kill to make sure that C-x C-r actually worked. It should say: "\ew": copy-region-as-kill After that, it should work fine. Example: $ abc<C-Spc><C-a><M-w> def <C-y> gives me $ abc def abc If you eve...
Copy and set-mark in Bash as in Emacs?
1,375,515,548,000
I use zsh's menu-based tab completion. I press Tab once, and a list of possible completions appears. If I press Tab again, I can navigate this list with the arrow keys. However, is it possible to navigate them with the vi-like H, J, K, L keys instead? I use emacs mode for command-line input, with bindkey -e in ~/.zshr...
Yes, you can by enabling menu select: zstyle ':completion:*' menu select zmodload zsh/complist ... # use the vi navigation keys in menu completion bindkey -M menuselect 'h' vi-backward-char bindkey -M menuselect 'k' vi-up-line-or-history bindkey -M menuselect 'l' vi-forward-char bindkey -M menuselect 'j' vi-down-line-...
Can I navigate zsh's tab-completion menu with vi-like hjkl keys?
1,375,515,548,000
I notice some sample bash for loops are spread out over multiple lines in examples for VARIABLE in file1 file2 file3 do command1 on $VARIABLE command2 commandN done (eg here http://www.cyberciti.biz/faq/bash-for-loop/) How do I enter a newline in the bash terminal (I use putty) ? When I press enter at the...
When you press Enter at the end of: for VARIABLE in file1 file2 file3 The shell can't execute anything since that for loop is not finished. So instead, it will print a different prompt, the $PS2 prompt (generally >), until you enter the closing done. However, after > is displayed, you can't go back to edit the first ...
How to input / start a new line in bash terminal?
1,375,515,548,000
How do I handle the backspaces entered, it shows ^? if tried & how read counts the characters, as in 12^?3 already 5 characters were complete(though all of them were not actual input), but after 12^?3^? it returned the prompt, weird. Please help! -bash-3.2$ read -n 5 12^?3^?-bash-3.2$
When you read a whole line with plain read (or read -r or other options that don't affect this behavior), the kernel-provided line editor recognizes the Backspace key to erase one character, as well as a very few other commands (including Return to finish the input line and send it). The shortcut keys can be configure...
How to handle backspace while reading?
1,375,515,548,000
I'm using zsh on Gentoo x64, and when I type sudo vim /path/to/file from my home folder, zsh asks: zsh: correct 'vim' to '.vim' [nyae]? I want to run vim not my .vim folder. How do I fix this? My guess is that setopt autocd is causing this. Odd thing is, if I don't add sudo, zsh doesn't ask to correct anything.
try alias sudo='nocorrect sudo'.
zsh wants to correct vim to .vim
1,375,515,548,000
Zsh has a bit of completion-related automation that's nice most of the time: after pressing Tab, a space is inserted automatically (or some other appropriate character such as , inside braces). I want to keep this feature except in one case: when I type & or | after pressing Tab, I don't want the space to be removed. ...
This feature can be tuned with ZLE_REMOVE_SUFFIX_CHARS and ZLE_SPACE_SUFFIX_CHARS shell parameters. If the ZLE_REMOVE_SUFFIX_CHARS variable is set, it should contain a set of characters that, when typed, will cause automatic suffixes from the completion to be removed. If ZLE_REMOVE_SUFFIX_CHARS is unset, the default ...
Keep the space after completion for some characters in zsh
1,375,515,548,000
Under Bash some behavior of Alt+d has been driving me crazy since years and I figured out that maybe it could be fixed with a setting. If I'm at a terminal and issue a command like this: ...$ cat >> ~/notesSuperLongFilename.txt and then if I want, say, to issue : ...$ scp ~/notesSuperLongFilename.txt I'd like to g...
I don't know who's "responsible" for that Alt+d behavior: I don't know if it's the terminal or if it's the shell (Bash in my case). It's bash, specifically the default command-line editing setup. Here is a nice page on what commands can be bound, and how to change the default bindings. The default binding for Alt-d...
The shell's "delete word" shortcut deletes too many characters
1,375,515,548,000
Xubuntu 13.10 Say I paste a command, something like sudo apt-get install abc yxz 123 DEF MMM KKK into the terminal. Then I suddenly had a change in mind and thus I would like to delete the last 3 packages without using backspace. Is there a way to mark them, as in using something like ctrl + shift + left?
Assuming you are using the "usual" bash with emacs bindings, using Ctrlw should work. To delete three words either press Ctrlw three times or preceed it with Alt3 or ESC3. For more shortcuts have a look at this list.
How can I delete input in the terminal?
1,375,515,548,000
I have the following path : $ vim /path/to/some/where If I press Ctrl + w, It removes entire text to first space. The result would be : $ vim How do I delete just the word next of last slash with comination keys?
Try Alt + Backspace. From bash documentation: backward-kill-word (M-DEL) Kill the word behind point. Word boundaries are the same as backward-word.
How to delete a word next of last slash
1,375,515,548,000
If I want to move a file called longfile from /longpath/ to /longpath/morepath/ can I do something like mv (/longpath)/(longfile) $1/morepath/$2 i.e. can I let the bash know that it should remember a specific part of the input so I can reuse it later in the same input? (In the above example I use an imaginary rememb...
You could do this: mv /longpath/longfile !#:1:h/morepath/ See https://www.gnu.org/software/bash/manual/bashref.html#History-Interaction !# is the current command :1 is the first argument in this command :h is the "head" -- think dirname /morepath/ appends that to the head and you're moving a file to a directory, so ...
Is it possible to name a part of a command to reuse it in the same command later on?
1,375,515,548,000
Often I fail to find something with reverse-i-search but want to keep what I have already written. For example, typing pdflatex fails to complete to pdflatex mydocument.tex. If I then cancel it with Ctrl+c or Ctrl g, the pdflatex part is deleted as well. How can I cancel it in a way that keeps my input?
Instead of cancelling just use ALT+F (or on Ubuntu alternatively CTRL+-> to move the cursor to the end of the first word and then press CTRL+K to delete everything to the end of the line. Now you are ready to complete your command.
How to cancel and keep reverse-i-search?
1,375,515,548,000
Thanks to a question on superuser.com, I found out about this utterly convenient rlwrap tool. It satisfies my needs (i.e. add command history to another cmdline tool), but I was wondering how I can use it to add command history to a 'compound' shell command, like the prototypical $> while read line; do echo "i read $l...
Have you tried rlwrap sh -c 'while read line; do echo "i read $line"; done' rlwrap needs a command it can run, which a () syntax-induced subshell is not. sh -c ... is a command however. Replace sh with bash or whatever shell you prefer.
Is there a convenient way to wrap a bash command list into rlwrap?
1,375,515,548,000
If I unintentionally add a newline in a command, as far as I can tell, the only way to undo it is to press Ctrl+c and type the command again. For example: $ cat 'John's File' > ^C $ cat "John's File" This is annoying if the original command is long. Is there a way to delete the newline and remove the > prompt so that...
Is there a way to delete the newline ... ? Actually: No. But there are excellent workarounds. As you have already introduced an Enter, the line has been stored in the list of commands executed. Press ControlC to get out of the command, then, without re-typing, press up-arrow. The command entered appears again, and c...
How can I undo an accidental newline in bash?
1,375,515,548,000
I (ab)use Alt + . to recover the last argument in a previous command (I'm using ZSH): for example, $ convert img.png img.pdf $ llpp (alt + .) # which produces llpp img.pdf but sometimes I review a pdf with llpp $ llpp pdffile.pdf& and then if I try to do something else with pdffile.pdf I run into troubles $ llpp (`...
ESC-. (insert-last-word) considers any space-separated or space-separable shell token¹ a “word“, including punctuation tokens such as &. You can give it a numeric argument to grab a word other than the last one. Positive arguments count from the right: Alt+1 Alt+. is equivalent to Alt+., Alt+2 Alt+. grabs the previous...
Alt + . (dot) shows &, instead of a previous argument
1,375,515,548,000
I have a couple of questions regarding the emacs-like keyboard bindings in Zsh. As background to all the questions: I have Emacs-like keybinding activated with bindkey -e (activated by default) Copying and region highlighting: In Emacs, if you run C-space (set-mark), select a region and then copy it using M-w, Emacs p...
To deactivate the selection, run set-mark-command with a negative argument: ESC - Ctrl+Space. To copy the region and deactivate the selection, write a function that performs the two actions, then declare it as a widget with zle -N and bind that widget to a key. copy-region-as-kill-deactivate-mark () { zle copy-regio...
Adding more Emacs-like bindings to ZSH's line editor (ZLE)
1,375,515,548,000
file1.txt: hi wonderful amazing sorry superman superhumanwith loss file2.txt : 1 2 3 4 5 6 7 When i try to combine using paste -d" " file1.txt file2.txt > actualout.txt actualout.txt : hi 1 wonderful 2 amazing 3 sorry 4 superman 5 superhumanwith 6 loss 7 But i want my output to look like this desired OUT.txt : hi ...
awk 'FNR==1{f+=1;w++;} f==1{if(length>w) w=length; next;} f==2{printf("%-"w"s",$0); getline<f2; print;} ' f2=file2 file1 file1 Note: file1 is quite intentionally read twice; the first time is to find the maximum line length, and the second time is to format each line for the final concatenation with cor...
Adjust gap between 2 columns to make them look straight
1,375,515,548,000
The Ctrl+R works for root (well toor) however I cannot find why it does not work for user. User .zshrc: setopt AUTO_CD setopt CORRECT_ALL setopt EXTENDED_GLOB # History SAVEHIST=10000 HISTSIZE=10000 HISTFILE=~/.zsh/history setopt APPEND_HISTORY setopt EXTENDED_HISTORY setopt INC_APPEND_HISTORY setopt HIST_FIND_NO_DUPS...
If you have $EDITOR = vi* or VISUAL = vi* when zsh starts up, zsh uses vi insertion mode as the default keymap. Otherwise zsh uses emacs mode. You presumably set EDITOR (or VISUAL) to vim in your init file, but have no such setting when running as root, so you're seeing the vi mode map, in which history search is on ^...
zle - I cannot find why Ctrl+R does not work for non-root