New answers tagged

0 votes

Error permission denied through ssh

it worked for me better chmod 600 ~/.ssh/*
user avatar
0 votes
Accepted

How to combine find and cp in linux to copy specific files

I would use xargs to copy all files. You can pipe the output to xargs which executes cp to all passed arguments. The Wikipedia article describes xargs better than I could do and you could look into ...
user avatar
  • 16
2 votes

Why does this screen session exit when the command is finished?

Using "bash -c" results in a non-interactive shell. You're creating a process tree as such: screen───bash───ls When ls finishes, bash has no further process and no further input and ...
user avatar
0 votes

What is the order that Linux's dynamic linker searches paths in?

The above answer is already very good, I will add one more. ld also uses DT_RUNPATH to find dynamic libraries. We can use the gcc -rpath compile option to write the dynamic library search path to the ...
user avatar
  • 111
1 vote
Accepted

How to use find and sed to replace certain sentences in files

You can do this in a two-step process, whereby in the first phase, using the TAB-delimited table file, we generate a set of grep & sed commands , and store them in a different hierarchy so that ...
user avatar
  • 5,313
0 votes

How to get mplayer to play from stdin?

8+ years later, I ought to post the solution I found. Use Python. AFAICT, this isn't possible in with standard Linux tools alone. If you're reading this - best to stop smashing your head against the ...
user avatar
1 vote
Accepted

Why are PATH variables different when running via sudo and su?

Q: "Why would the path be different when running via sudo?" Perhaps the best explanation is found in the Command environment section of man 5 sudoers: Since environment variables can ...
user avatar
  • 2,104
0 votes

run tomcat daemon with user other that root

Create a user account tomcat. Make sure it is a member of the group tomcat. Everywhere in the documentation where it says group permissions of "read", make them the same as the owner except ...
user avatar
  • 88.9k
6 votes

Command '“export' not found when starting a terminal app in Ubuntu

I wondered why your machine did not have the export command... then I noticed that your error message actually says “export. Your post was not code-formatted at first so the quotation mark was hard to ...
user avatar
  • 25.3k
2 votes
Accepted

why the journalctl --disk-usage not show the real log disk usage

journalctl only concerns itself with the systemd journal, normally stored in /run/log/journal and /var/log/journal. Other files in /var/log aren’t part of the systemd journal and aren’t counted by ...
user avatar
0 votes

Wired Xbox One Controller Shows in lsusb but stops detecting input in steam sometimes

I found out I can use jstest to achieve what I want. Ended up making a script like this: #!/bin/bash function xboxControllerReset() { device_id="$(docker run -it --rm --name my-running-script ...
user avatar
  • 101
0 votes

Service takes more than a minute to close

No, there is no easy way to do it. Usually, the application shutdown procedure consists of dumping memory cashes, closing files, sending other processes "i am closed" messages etc. It all ...
user avatar
  • 1,163
3 votes
Accepted

Why does running sudo systemctl stop ssh over ssh not immediately terminate the ssh session

When you connect, the SSH daemon (e.g. sshd) forks at least once. From now on your connection is handled by a separate process, not the listening daemon itself. systemctl stop ssh stops the listening ...
user avatar
1 vote

Automatically restart linux on hung task timeout dmesg

I found a answer on very good blog by Jethro Carr You just need to add to /etc/sysctl.conf: # Panic if a hung task was found kernel.hung_task_panic=1 # Reboot 5 seconds after panic kernel.panic=5 ...
user avatar
  • 1,035
2 votes
Accepted

Is there a difference in serial data formatting between Linux and Windows?

So after more looking I found that it was a problem with the driver. The solution was to update or install a patched version of the CH341 driver. Instructions found here. I don't fully understand what ...
user avatar
6 votes

Filtering find results by length

With the zsh shell, globs can be filtered by file type (here directory) using glob qualifiers, and with the extendedglob option on, you get a (#cX,Y) glob operator similar to ERE {X,Y}, so you could ...
user avatar
7 votes
Accepted

Filtering find results by length

You could use the ? wildcard five times: find ./directory -maxdepth 1 -type d -name '?????*' This requires matches to have at least five characters in their name.
user avatar
  • 63k
3 votes
Accepted

Jq substract 2 keys and add it to json

jq '.result = .end - .start' This reads the input JSON document and sets the top-level result key to the result of the subtraction of start from end. Example run: $ echo '{ "end": 10, "...
user avatar
  • 267k
11 votes
Accepted

What is correct or suggested approach to send the signal name through 'kill' command?

The most portable variant is kill -s TERM -- … That’s the form specified in POSIX with no extensions: -s followed by the signal’s name, as defined in signal.h, with no SIG prefix, or 0 for the “null” ...
user avatar
0 votes

sort numbers according to last number in line

sort -k 14b,14 file sort by the 14th column
user avatar
0 votes

How do I know if my microphone is mute or unmute when I have more than one microphone?

Your amixer -D 'hw:1' output actually shows the microphone state in the last line. Here's one way to extract that in a bash script: amixer -D "hw:1" sget Mic | awk -F "[\[\]]" '/\[...
user avatar
3 votes

Displaying users logged in today between two dates

Use last command with -s and -t or -p flags: -s, --since <time> display the lines since the specified time -t, --until <time> display the lines until the specified time -p, --...
user avatar
  • 20.6k
0 votes
Accepted

systemd: what is a "non-container" system?

Educated Guess: The term "Container systems" means in this case a docker or lxc container. The manpage tries to tell you, that on "non-container systems" (so a normal pc/server, or ...
user avatar
  • 217
1 vote

Why are the signal lists for kill, killall and pkill not the same?

The kill program and killall show the same set of signals: $ /bin/kill -l HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ ...
user avatar
0 votes

How to remove line with specific string from file

If that is the exact contents of the file, then here is an easy solution with GNU sed: sed '/^\/home\/user1\/$/d' file ^ marks the beginning of the line and $ marks the end of the line so it will ...
user avatar
  • 9,255
0 votes

How to remove line with specific string from file

If sed is an option $ sed -n '\|\(/\([^/]*/\)\{2\}\)\<|p' input_file /home/user1/dir1 /home/user1/dir2 /home/user1/dir1/dir11
user avatar
  • 1,081
1 vote
Accepted

How to remove line with specific string from file

Use anchors to mark the beginning and end of the line: ^ for the beginning and $ for the end. So it would go like this: $ grep -v '^/home/user1/$' file /home/user1/dir1 /home/user1/dir2 /home/user1/...
user avatar
3 votes
Accepted

How to install software with outdated set of libraries into a new system without conflicts?

The idea of virtual machine is not a good choice, because the software is the only purpose of workstations it is being installed so I need to provide full computational power of it to software. That'...
user avatar
9 votes

Why are the signal lists for kill, killall and pkill not the same?

The programs you mention (kill, killall and pkill) with high probability have different authors. And each author decide how to provide help to the user. You can't expect they will have same command ...
user avatar
  • 12.9k
13 votes
Accepted

Why are the signal lists for kill, killall and pkill not the same?

Why are the signal lists for kill, killall and pkill not the same? Most likely, because they were implemented differently, with different frames of mind, at different times, by different persons. You ...
user avatar
  • 67.4k
2 votes

Disable service version detection

You'll find that cups simply, by itself, happily delivers the version in the <title> attribute of the HTML page it delivers when you request / via HTTP on port 631. That's read from the ...
user avatar
7 votes

Why does the Linux kernel not use rust?

You just need to wait a few weeks: if all goes well, version 5.19 of the kernel will include some Rust code. As for why the kernel in general doesn’t use Rust, there are a number of reasons, the first ...
user avatar
2 votes

Swap lines in a file

Using Raku (formerly known as Perl_6) [Adds extra blank line at end]: raku -ne 'my ($L1,$L2,$L3,$L4) = (get) xx 4; .put for $L3, $L1, $L2, $_, ($L4 // "");' #OR raku -e 'my @a.=push($_) ...
user avatar
  • 1,098
1 vote

Find how many words in a file contain a number in them?

I suspect you're not getting any matches because your shell is interpreting the brackets using its own syntactic rules. They need to be in quotes. But even if it weren't for that problem, yours would ...
user avatar
  • 7,107
0 votes

Is there a utility that interprets /proc/interrupts data over time?

The newly developed utility pw ("Pipe Watch") can monitor anything that produces voluminous output, with useful interactive features such as triggering, filtering, split panes and more. This ...
user avatar
  • 6,656
-1 votes

Error when installing Red Hat Enterprise Linux 8.2 via VirtualBox

If the host OS is Windows, you may want to disable the Hyper-V supervisor: https://docs.microsoft.com/en-us/troubleshoot/windows-client/application-management/virtualization-apps-not-work-with-hyper-v ...
user avatar
1 vote

Show all onu in an OLT ZTE

Well, You can try "expect" my brother. I will give you a functional example: #!/usr/bin/expect -f spawn telnet A.B.C.D expect "sername:" send "user1\r" expect "assword:" ...
user avatar
0 votes

Swap lines in a file

perl one liner perl -lne ' print reverse $_, /./ ? (<>.<>, $,.<>) : (); ' file -n reads files line by line and the line is held inside the $_ variable. the builtin reverse in a ...
user avatar
  • 5,313
-1 votes

Error when installing Red Hat Enterprise Linux 8.2 via VirtualBox

Seems like the source from where you download the images is unreliable. The best site to download RHEL is RedHat web site. You may need to create free development account for this.
user avatar
  • 12.9k
1 vote

Can't remove directory by node number

Solved! It took over a year, but I found a solution. It turns out the directory in question was on a Networked Attached Storage device. So I used ssh to connect directly to the device, and when I ...
user avatar
1 vote
Accepted

Linux - count words with more than a certain length of characters

After you mentioned your professor, I'm a bit worried we're doing your homework for you, but you can try: egrep -wo '[[:alnum:]]{5,}' filename.txt | wc -w This looks for spans of 5 or more ...
user avatar
  • 7,107
2 votes

Grub install with encrypted Boot partition

grub-install is expecting to find /boot, but cannot, because according to your lsblk, it's at /mnt/boot... so you aren't chrooted into the new installation at this time. But I agree with Sheldon: ...
user avatar
  • 66.8k
0 votes

How to merge arrays from multiple arrays in two JSON with JQ

If the keys are not always the same across the document this one will do the job: jq --slurp ' reduce (.[] | to_entries | .[]) as {$key, $value} ( {}; .[$k] += $v ) ' file*....
user avatar
  • 101
0 votes

How to pass a parameter in a command without run the parameter content?

This: function denyCheck(){ is a mix of the standard function declaration func(), and ksh's function func. Bash supports the combination, other shells might not, but there's no reason to do it. Just ...
user avatar
  • 115k
1 vote

Access Virtual Console via SSH

You can change your virtual terminal and start X11 like this: sudo chvt 1 # change to virtual terminal 1 sudo startx # start X11 Note that chvt also allows you to run fim (and probably ...
user avatar
0 votes

How to set up Hardware RAID on Linux Server for Access from Windows as a NAS

Ok, that was easy. Just ignore the fact that it is a RAID, since the RAID functionality is handled by the RAID controller and is shown to Ubuntu/Linux as a single drive. Without this in search query ...
user avatar
  • 1
1 vote

all possible matched pairs and associated information

Using any awk in any shell on every Unix box: $ cat tst.awk BEGIN { FS=OFS="," } { map[NR] = $0 } END { n = split(map[1],a) printf "%s%s%s%s", "ID1", OFS, "...
user avatar
  • 21.9k
0 votes
Accepted

Grub install with encrypted Boot partition

I'm pretty sure that the ESP must be a simple (FAT-formatted) partition, not wrapped by LVM. While you can encrypt your boot partition, an encrypted ESP inside LVM is not gonna fly. i am trying to do ...
user avatar
  • 77
0 votes
Accepted

How to pass a parameter in a command without run the parameter content?

Should rather be: cmd_canonical_path() { local cmd_path cmd_path=$(command -v -- "$1") && cmd_path=$(readlink -e -- "$cmd_path") && [ -x "$cmd_path&...
user avatar
1 vote

Swap lines in a file

With sed: sed '/^Delegate/{N;N;N;s/\(.*\)\(\n.*\n.*\n\)\(.*\)/\3\2\1/;}' Or, making use of the hold space: sed -ne '/^Delegate/{h;n;N;G;x;n;G;}' -e p
user avatar

Top 50 recent answers are included