New answers tagged

1 vote
Accepted

How to create multiple directories and populate them with files

The reason that what you're doing wrong doesn't work is because redirection and filename generation is handled by the shell, not by xargs. When you write foo > foo.out then the shell will run foo ...
0 votes

Unable to install new kernel in ubuntu server. "gzip: stdout: No space left on device" error even though abundant disk space

This happens when there is not much space left on /boot partition. The solution to this is to uninstall old kernels and free up space. You can get a list of the currently installed kernels [I] ~ ❯❯❯ ...
  • 347
0 votes

Does init script support something like systemd user service?

Any initscript can run any command as any user just by using su $user -c "/home/$user/onboot.sh". And that would just launch a user script on boot, to which they can run whatever they want. ...
  • 479
2 votes

How to create multiple directories and populate them with files

Can be a bit to use xargs in this manner. I suggest just a bit of shell instead. As follows for file in ./parent_{0..9}/child_{0..9}/test.txt do head -c 100 /dev/random > "$file" done ...
  • 479
0 votes

Change any listening binding port to another

The question is a bit confusing, but redir can be perhaps useful to you. It redirects incoming TCP connections to a specific port, to another specified IP address and port.
  • 26.5k
0 votes

Change any listening binding port to another

No. There is no way to change port from outside the application. It (application) must have some configuration ability to reassign the port it would listen. Said that - you can go by proxi way. Each ...
  • 2,285
0 votes

How do I type a vinculum?

Works for me: if I type Ctrl+Shift+u 0 3 0 5 space 3. But only only one space or enter between the unicode codepoint for the combiner (0305) and the character you want to combine it with.
  • 1,593
0 votes
Accepted

How to capture audio change in Linux?

$ grep closed /proc/asound/card*/pcm*/sub*/status command will give PCM device that is playing sound, so that helped me to capture audio change on some of outputs.
0 votes

Accidentally deleted yum.repos.d/ directory in my Amazon Linux AMI 2018.03 machine

You could: Fire up a new instance, copy the directory. Alternatively download distroname-repos.noarch.rpm package and simply reinstall it. sudo rpm --reinstall distroname-repos.noarch.rpm.
0 votes

Use xrandr to split display in two virtual screens

unfortunately, this is not working on linux with most window managers due to some open issues. The first is that xrandr does not allow to set multiple outputs on one monitor and that outputs without ...
0 votes

Ubuntu 22.04 restrict kernel upgrade

You can pin the kernel packages: sudo tee /etc/apt/preferences.d/nolinuxupgrades <<EOF Package: linux-* Pin: version * Pin-Priority: -1 EOF This will prevent future upgrades or installations of ...
2 votes

How can I make a loopback file descriptor in bash?

echo foo >${LOOPBACK_FD} cat <${LOOPBACK_FD} That will not work -- no matter how LOOPBACK_FD is created or opened, or if it's accessible via the filesystem or not. The cat will keep waiting for ...
0 votes

Linux based Operating System (distribution) for python, Maxima, C programming and jupyter notebook

Just about Linux distributions (other than the ones whose entire purpose is minimalism) typically come with Python (amongst other things) pre-installed. Your question is one of those where if you ask ...
  • 69.3k
0 votes

Cannot write to file in linux environment

Based on the information on offer, the problem seems to be that you don't have write permission to the current directory. This answer assumes that you need to run the script from the given directory ...
  • 3,852
0 votes

No route to host with nc but can ping

xhienne answer is absolutely correct, but even the reason might be the firewall, in case the issue happen with port 80/tcp often the reason this happens is due to the presence of a proxy server. ...
  • 2,000
2 votes

Print ONLY the next line after a match with awk

If sed is an option $ sed -En '/Artifacts were created:/{n;s/[^ ]* (.*)/\1/p}' <<< "$file" build-1.tar.gz
  • 2,139
2 votes
Accepted

Print ONLY the next line after a match with awk

Please try: awk '/Artifacts were created:/{p=1} NF{out=$2} END{if(p==1){print out}}' infile Although the pipe you presented is extracting the second filed of the line just following the match, not ...
2 votes

Print ONLY the next line after a match with awk

The original requirement asked for a value from the last non-whitespace line after a match. Here, when you find a match trigger, set a flag. When the flag is set wait for the end of file and then ...
  • 93.8k
0 votes

bound, but not listening process

It might be the case that your IP:port combination is held by a client socket, sometimes it happens due to bad luck (the local port for a client socket is the randomly-generated "ephemeral port&...
  • 231
2 votes

Can't change bridge subnet or create network on Docker

That's because your existing bridge network has a /16 mask configuration, meaning that the available network range is from 10.10.0.1 to 10.10.255.254 so your new network belongs to that range. You ...
  • 6,802
0 votes
Accepted

VLANs in bare metal servers

Can I create a VLAN between A and B? Sure! If you have two virtual machines attached to the same virtual bridge, you can just create your desired VLAN interfaces. E.g, if I have two virtual machines, ...
  • 27.3k
0 votes

ldm_parse_tocblock(): Cannot find Tocblock, database may be corrupt

I know this is an old question, but this just happened to me. I have Fedora 36 with Windows 11 dual boot, and this seems to be related to having dynamic disks (on NTFS). I had older HDDs and just ...
0 votes
Accepted

Local filesystem mounted as remote by systemd in OL8.6

Provided nothing on /u vitally depends on /, you can force /u to mount before other local filesystems. One method would be to add the x-systemd.before=local-fs.target option in fstab. E.g.: /dev/...
0 votes

How to read a file and write in to another file using a shell script

If file1.txt contains something (its file size is non-zero), you want that something to go into file2.txt: if [ -s file1.txt ]; then cp file1.txt file2.txt fi If file1.txt is empty (or missing), ...
  • 281k
0 votes
Accepted

How to read a file and write in to another file using a shell script

The reason it isn't working is the for loop. When you have no value in the file, there is nothing for the for loop to iterate over, so it doesn't even start and, therefore, the if is never evaluated. ...
  • 221k
0 votes

Tool that measures single command CPU/Memory usage?

Simply use the GNU version of the time utility with some custom format : Something like time --format="%E %M" some_executable might well basically fit your needs, but do check the man page (...
  • 3,899
2 votes

Unable to pull directory from remote host to local using rsync

Use rsync -a instead of plain rsync. Without the -a (--archive) flag you will neither copy recursively nor will you get file metadata. At a minimum, the file modification time (mtime) that's copied ...
  • 93.8k
2 votes
Accepted

rsync fails to work with -o StrictHostKeyChecking=no option

Rsync doesn't take ssh -o options on its command line. You have to put ssh options into an ssh command string you pass to rsync's -e option. Something like: /bin/rsync -rv -e 'ssh -o ...
  • 1,692
1 vote

How do I mount an ext4 partition created on a recent system, on a ten-year-old 2010 CentOS system?

I needed to use an old rescue environment (~2014?) to fix the grub bootloader on a modern system and had the same problem. The solution for me was to mount the filesystem without the journal at all: # ...
2 votes
Accepted

Unable to pull directory from remote host to local using rsync

According to rsync --help: --recursive, -r recurse into directories So when you want to copy a directory, you have to add -r or --recursive option to rysnc: /bin/rsync -rv myremoteuser@...
0 votes

How to Create ISO / Installation Image from Our Own LFS(Linux From Scratch) Operating System in Qemu? I want to Make my Qemu.qcow2 image my Host OS

Rizwan's answer might be your solution. LFS could import RPM packages. You might want to look at this.
0 votes
Accepted

Using result of find command as input in scp to backup a remote server to my local machine

I can´t make work with a single command, but with two it worked Command A: ssh jenkins@192.168.1.10 'cd /var/lib/jenkins/jobs; find . -name config.xml ! -path '*/backup*' | rsync -avz --files-from=- . ...
0 votes

Why does Linux list USB Host Controller' vendor as "Linux Foundation"?

Linux has an abstraction that lets Host Controller Drivers share code. As a comment in drivers/usb/core/hcd.c says: * USB Host Controller Driver framework * * Plugs into usbcore (usb_bus) and lets ...
  • 3,019
1 vote
Accepted

Problems with openssl

I fixed this by doing: sudo cp /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /opt/dell/dcc/libcrypto.so.3 I assume you have an DELL Notebook and there are some tweaks automatically installed by Ubuntu, ...
  • 26
1 vote

Sed replace the middle string

With zsh, assuming list doesn't contain $, ` nor \ characters: $ cat list 22<>22 3<>33 134423<>4 $ cat data test dev too $ () {print -rC1 -- ${(e)${(f)"$(<list)"}//'<&...
1 vote

the output between zsh and bash

A variable that doesn't exist in the environment doesn't have any value, so there is nothing there to print. It isn't that variables magically get the value 0, if they are not defined, they are not ...
  • 221k
0 votes

Finding the PORT NUMBER of the process using a specific PID?

One can use lsof with the -i (only list IPv4/6), -P (no port names), and -n (no hostnames) arguments, and then grep the PID: sudo lsof -i -P -n | grep <PID> This will present you with all ports ...
  • 11
2 votes

What happened to a sleep command after server shutdown?

The sleep command will get killed on shutdown. You should use at which will survive a reboot. e.g. echo "sh run_my_script.sh" | at now+5hours
  • 21.1k
2 votes

What happened to a sleep command after server shutdown?

1- if the job gets deleted, you will have to submit job again. The sleep command will be killed so how much time elapsed will be lost 2- If servers gets rebooted before 18000 seconds have passed, job ...
  • 5,475
0 votes

Running thousands of curl background processes in parallel in bash script

try this shellscript for batch concurrent curl requesting: cat curlpool.sh #!/bin/bash # usage: ./curlpool.sh "-d '{ \"id\": 1, \"jsonrpc\": \"2.0\", \"method\&...
  • 101
1 vote

Sed replace the middle string

change <> to one character | delimiter: $ sed -s 's/<>/|/g' asdf1 > asdf2 $ cat asdf2 22|22 3|33 134423|4 combine 2 files into one file, using same one character | delimiter: $ paste -...
  • 169
1 vote
Accepted

Sed replace the middle string

You can assign to an array the list of strings that will replace to <>. In a file called list.txt you should have: test dev too And in a file called data.txt you should have: 22<>22 3<&...
0 votes

pivot_root() in user namespace fails with EINVAL

My interpretation of the Linux kernel source is that the target of a pivot_root must have been mounted from within the user namespace that it's in. MNT_LOCKED seems to primarily be set by ...
0 votes

How to search file name just created by some one on Linux server

If you want today as in after midnight, this should work (not DST safe!): find /path/to/directory -name \*.tar -mmin "-$(( $(date "+10#%H * 60 + 10#%M") ))" The time calculation ...
  • 5,809
0 votes

How to take input from a file and redirect the output of that input to another file

Your description is rather vague, to say the least. What I take from it: you want to see the content of file1 on screen and put it into file2 in one step. tee file2 <file1
  • 5,809
1 vote
Accepted

extract links from webpages which require interaction

For your specific example, you would be better served by using the github API, rathern than trying to scrape the web page. E.g: curl https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases/tags/...
  • 27.3k
0 votes

Help with Find command: Find files or folders that start with a space (ore more than one space) on linux

With zsh: autoload -Uz zmv zmv -n '(**/) ##(*)(#qD/)' '$1$2' (remove -n from dry-run if happy)
6 votes

Parameter Substitution inside Indirect expansion

In bash, you'll need an intermediary variable: first=hello second_hello=finally intermediary=second_$first printf '%s\n' "${!intermediary}" Though you can always do it the standard way ...
1 vote
Accepted

dnsmasq dhcp not listening on port 67

An IPv4 DHCP server will need to be able to send & receive broadcast packets addressed to destination 255.255.255.255, which requires (as far as I know) the use of a raw socket. See ss -A raw -lpn ...
  • 72.5k
7 votes
Accepted

Help with Find command: Find files or folders that start with a space (ore more than one space) on linux

find . -depth -name ' *' -exec sh -c ' for pathname do newname=${pathname##*/} newname=${newname#"${newname%%[! ]*}"} newpathname=${pathname%/*}/$newname ...
  • 281k

Top 50 recent answers are included