New answers tagged

0

Here's a concise solution that uses paste and sed: $ cat file1 'text_clear' => 'Clear', 'text_search' => 'Search', 'text_enabled' => 'Enabled', $ cat file2 emptied lost turned off $ paste file1 file2 | sed 's/=> \'.*\',\t\(.*\)/=> \'\1\',/' 'text_clear' => 'emptied', 'text_search' => 'lost', 'text_enabled' => ...


0

POSIXly (I think), you could use a sed loop to repeatedly replace the first non-x character following the 4-character prefix: $ md5sum input.txt | sed ' :a s/^\(....x*\)[^x]/\1x/ ta '


2

With GNU Sed, md5sum input.txt | sed 's/./x/5g' This simply skips substituting the 4 first characters of the string and performs the substitution for all other characters. A POSIX alternative with Awk (although there is probably something simpler), md5sum xad | awk '{ four=substr($0, 1, 4) rest=substr($0, 5) gsub(/./, "x", rest) print four,...


0

Try running ps aux --sort -rss as root. I have different outputs when I do ps aux --sort -rss | wc -l than when I do when I'm running as root. Further... this command I found helpful. ps -eo size,pid,user,command --sort -size | \ awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print &...


0

Tomas, new contributor the syntax is simply /folder/folder/folder/.../file you can have an almost unlimited number of subfolders... there technically is a limit and would depend on the file system such as XFS, EXT3, EXT4, BTRFS. simply put, everything just starts at / and is known as the root file system Any folder under / can be a mount point. do a df -h ...


0

The running system (or more correctly a process in the running system) has a "root directory", referred to by /. Each filesystem (mounted partition) also has a root directory, often inode 2. The root directory of each filesystem may be mount on some directory of some other filesystem. (OK, on Linux, you could multiply mount it, and mount it on a ...


3

The -connect flag for openssl s_client takes a host:port, but you're providing a URL. So your openssl s_client command is failing with an error like this: s_client: -connect argument or target parameter malformed or ambiguous But you discard this error message with 2>/dev/null, so it doesn't show up in your output. When the openssl s_client command ...


1

No, there is no 1:1 map from system calls to library calls and vice versa. For example, most if not all arithmetic functions (e.g. sin) don’t call any system calls; others such as posix_spawn use multiple system calls. Going the other way, some system calls such as init_module don’t have any corresponding library call and need to be called “manually” through ...


1

Counter-example getpwent(3) invokes many system calls


1

Note that writing a POSIX operating system from scratch is way beyond the scope of this site. Note also that the title and the actual question don't match. If you want to know how the getdents system call works in Linux, look at the code, it seems you already did that for other parts. But getdents is not that important, and early UNIX systems didn't have it. ...


0

Try below command and I hope this will get resolved your issue: lvextend -An -r -L +10G /dev/mapper/root


1

To analyze the tcpdump from command line, tcpparse command can be used. Eg: # tcpparse tcpdump_file.pcap 6 192.235.93.41 132 > 192.168.20.119 1544 74 6 192.168.20.119 57604 > 192.235.93.41 1194 66 6 192.168.20.119 57604 > 192.235.93.41 1194 110 6 192.235.93.41 1194 > 192.168.20.119 57604 66 6 192.235.93.41 1194 > 192.168.20.119 57604 122 6 ...


2

You could always switch to ksh93 (whose syntax bash has borrowed in the first place for most things) which has multidimensional arrays. var=( (a b) (c d) ) Use as: $ print -r -- "${var[0][1]}" b To loop over all the elements: for i in "${!var[@]}"; do for j in "${!var[$i][@]}"; do print -r "var[$i,$j]=${var[$i][$...


3

Another awk solution: $ awk -F"'" -v OFS="'" '(getline line < "file2")==1{$4=line} 1' file1 'text_clear' => 'emptied', 'text_search' => 'lost', 'text_enabled' => 'turned off', This relies on the fact that each input line has 2 single quote characters before the field to be replaced. If you want to ...


1

Your mke2fs -n run indicates the encrypted volume /dev/mapper/luks-077248fb-b2bf-4ddb-9762-3c69af031c2c contains a LVM physical volume, not simply a filesystem. So the next steps after unlocking the encrypted volume (using cryptsetup luksOpen manually, if necessary) should be to scan for LVM components and then activate them if they are in good condition. ...


-1

man link according below man page of link, it shows that link only work for files, which means link can not create a target for a directory. LINK(1) User Commands LINK(1) NAME link - call the link function to ...


4

Another awk approach, using match and substr: $ awk -v pat="'[^']*'" -v q="'" -v file2='File2' ' BEGIN{OFS=FS=" => "} match($2,pat) && ((getline str < file2) > 0) { $2 = substr($2,1,RSTART-1) q str q substr($2,RSTART+RLENGTH) } 1 ' File1 'text_clear' => 'emptied', 'text_search' => 'lost'...


9

code.awk: BEGIN{j=1} NR==FNR{a[NR]=$0;next} sub(/=> '.*',$/,"=> '"a[j]"',"){++j} 1 awk -f code.awk file2 file1 > file3 Line by line explanation: Initialize j=1. Put each line of file2 in the array a. In file1, for each line, try to substitute a string matching the => '.*',$ regex by the concatenation of => ' a[j] ',. If ...


0

The most likely reason that the space wasn't feed up is because you have an open file handle. The space will only be freed up when nothing is holding the file open. So restart the spp the file belonged to and the space will probably become available. Run lsof to see open files. There is a post on removing files which haven't freed their space You can also ...


1

This finds the first 5 pids on my machine using libnss_files-2.23.so. $ for p in /proc/[0-9]* do test -d $p/map_files && sudo ls -l $p/map_files | awk -vpid=$(basename $p) -vname=libnss_files-2.23.so -F '->' \ '$2 ~ name {print pid; exit}' done | head -5 1114 1155 12066 12148 12156 These days on Linux, find all ...


2

chvt 1 causes vt 1 to become visible, but doesn't affect where subsequent commands run. cmatrix -B runs on the same terminal where the original shell is running. If you want to run cmatrix on another terminal, you have to let the system know that this is what you want to do. Use openvt to run a program on a different virtual console. Pass the -s option if ...


0

Solution to my problem: Reset the sources file to default Delete /etc/apt/sources.list file, then recreate again. Open Software and Packages, check the sources there...


0

#! /bin/bash while read line do string="${string},${line}" done < file_column.txt echo ${string#","} > file_row.txt This works. The while read construction is more portable as it uses only Bash syntax and the builtin read.


4

You have to use the right delimiter (comma) with the -d parameter: cat file Art 14f adr a24 paste -sd, file Art,14f,adr,a24


0

Move it all back, except for what should be in /var. Here is what I have in /var, hope it helps. (I am on Debian 10.) drwxr-xr-x 2 root root 4.0K Oct 21 07:56 backups/ drwxr-xr-x 17 root root 4.0K Aug 12 17:37 cache/ drwxr-xr-x 60 root root 4.0K Aug 12 17:37 lib/ drwxrwsr-x 2 root staff 4.0K May 13 2019 local/ lrwxrwxrwx 1 root root 9 Aug 5 2019 ...


0

As @peschke mentioned I had to set net.ipv4.ip_forward = 1


0

Preinstalled on Ubuntu: Cheese. Worked for me. (As Gabriel Staples pointed out in a comment.)


0

I think you are either missing the Real-time patch or using the Linux kernel source with the RT patch: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git/ See also Linux Foundation wiki Real-time page


2

You can run these commands, if x86_64 and 64-bit, the answer would be yes: $ lscpu | grep Arch Architecture: x86_64 $ lscpu | grep mode CPU op-mode(s): 32-bit, 64-bit From 32-bit, 64-bit CPU op-mode on Linux lscpu is telling you that your architecture is i686 (an Intel 32-bit CPU), and that your CPU supports both 32-bit ...


4

bash searches every directory in $PATH (from first to last) every time you run a command, trying to run the command out of that directory. It either succeeds or fails. So if /tmp/dir1 is in your $PATH, and a.out is in that directory, you can try to run a.out - bash will try to run /tmp/dir1/a.out, and that succeeds because you have execute permission. csh ...


0

What keeps you from doing sed "s/\"/\'/g" | sed "s/ /' '/"? Edit: To build on the comments by @ilkkachu and @BarBar1234, it might be more helpful, assuming you have a file, to do the following: sed "s/\"/\'/g" <filename> > edited brands=( 'Alfa Romeo' 'Ford' ... ) for brand in "${brands[@]}&...


0

Portably, you can use: lsof -ad 1 -p "$pid" To see what's open on fd 1 (stdout) of process of id $pid. If that's open to a pipe or another inter-process communication channel, on Linux, you can add the -E option to see what process is at the other end.


1

Davmail will give you an IMAP/POP3 → M365 Exchange Online interface with OAuth (Modern Authentication). It's a Java application, but you can use Amazon Corretto rather than Oracle Java to avoid licensing costs.


2

You were very close in showing the output of /proc/$pid/fd/1. As you saw, that will show you the output which is sent to stdout. But to see whenceforth standard output is being sent, you simply need to look at the target of that symbolic link: $ sleep 20 & pid=$! [1] 88972 $ readlink -f /proc/$pid/fd/1 /dev/pty0 $ sleep 20 > /dev/null & pid=$! [...


0

You can use dos2unix utility to avoid configuration changes. I used this way and it worked for me. remote_hostname=`ssh -t ${sys_ip} 'uname -n'|dos2unix`


4

You can use the variable SSH_ASKPASS for that. connect.sh #!/bin/bash pwd="mypassword" if [ ! -t 1 ]; then # The output is not going to stdout, assume the invoke is from SSH_ASKPASS printf "%s\n" "$pwd" exit 0 fi # SSH_ASKPASS will be used only if DISPLAY is defined export DISPLAY=:0 # Set the SSH_ASKPASS program to ...


0

/usr/include/linux contains the kernel headers for the kernel's user-space interfaces but compiling the modules requires the headers for all kernel interfaces. The former is just a limited sub-set of the latter. Usually, when the appropriate package is installed, in modern distributions, a /lib/modules/$(uname -r)/build (or /lib/modules/$(uname -r)/source) ...


0

The --kernel-source-path option requires the headers for an installed kernel, not /usr/include/linux/. Normally you do it this way: sudo ./NVIDIA-Linux-x86_64-430.09.run --kernel-source-path=/lib/modules/${kernel-version}/source


0

Instead of saving it in init.d, try adding the script in /etc/rc.local EG: open /etc/rc.local, then path_to_binary path_to_scipt


0

To provide some background information, the following is from Ctrl-h k Ctrl-t: C-t runs the command transpose-chars (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’. It is bound to C-t. (transpose-chars ARG) Interchange characters around point, moving forward one character. With prefix arg ARG, effect is to take character ...


0

No, XMonad does not have any functionality to blank/sleep your screen The screen sleep/blank settings are completely managed by X. Depending on your operating system, certain defaults will be set for screen blanking after N minutes of inactivity. Debian-based systems will blank the screen after 10 minutes. The reason you're not noticing this with desktop ...


3

I think if you change your crontab line as follows, you will get what you want - or at least what I think you want. If it doesn't do as you wish, leave a comment. You may also wish to edit your question to clarify your objective. Prototype crontab entry for test/eval: * * * * * { cat hellofile_NOFILE.txt ; echo $(date) | tee -a error_log; } >> /home/pi/...


5

Most simply: 0 10 * * * { date; date >&2; test.sh; } >> output_log 2>> error_log It might also be interesting to use the ts utility from Moreutils, which will prepend a timestamp to every line: SHELL=/bin/bash 0 10 * * * test.sh > >(ts >> output_log) 2> >(ts >> error_log) (Note the use of /bin/bash, as the most ...


0

Since your LVM is on a LUKS-encrypted partition, the LVM root volume UUID will not be visible until the encryption is unlocked. By default, Debian/Ubuntu GRUB configuration may refer to several things located on the root filesystem, including: font file /usr/share/grub/unicode.pf2 GRUB background image, e.g. /usr/share/desktop-base/futureprototype-them/grub/...


0

An update: Apparently I came across another post elsewhere which seemed to imply that busybox needs to be statically linked and not dynamic, which seemed to be the issue for me as well. I changed the build config to make it static linking and then the kernel panic disappeared. I now am able to reach the Kernel console successfully, but I have a strange ...


1

From description of yes: Repeatedly output a line with all specified STRING(s), or 'y' so, yes yes no outputs: yes no yes no yes no ... but you want yes no You could try to put a newline in your string: yes 'yes no' | bash test.sh Or, as you only need it once and not repeatedly, feed it to your script manually: printf '%s\n%s\n' yes no | bash test.sh


0

Use mountpoint to check if /mnt/mmcblk0p4 is a mount point and take the appropriate action in your script (mount, wait, ...). For example, this will echo "Yes" if /mnt/mmcblk0p4 is a mountpoint: $ mountpoint /mnt/mmcblk0p4 && echo "Yes"


1

nftables aims to replace ebtables + iptables: most features are also available at the bridge level the same way they are available at the IP level without using br_netfilter (including stateful IP firewalling at bridge level, with kernel >= 5.3). Here's a ruleset (let's call it bridgemss.nft) to load on HostA and HostB with nft -f bridgemss.nft: table ...


0

With sed you can try something like this, though as mentioned in a comment the right tool would be jq: sed '/token/s;[^: ]*$;\"'"$HOME"'\";' settings.json Output: { "token": "/home/user" "role": 766507041757069351, "channel": 766507042113847383, }


5

If you didn't reboot : You should probably use : lsof -a +L1 can help you find out which deleted (rm'd) files still have opened "file handles" (ie, some program still points to it and thus the file itself is not deleted yet from the filesystem, even though its last name entry has been deleted by rm). The offset will hint at the largest files ...


Top 50 recent answers are included