socat does not honor sourceport option Posted: 18 Jun 2022 06:45 PM PDT I am trying to send a udp packet from a specific port: $ echo hello | socat - UDP-DATAGRAM:192.168.1.255:11111,broadcast,sourceport=22222 But a random port is used instead: # tcpdump -vvvv -ttttt -nienp0s31f6 udp tcpdump: listening on enp0s31f6, link-type EN10MB (Ethernet), snapshot length 262144 bytes 00:00:00.000000 IP (tos 0x0, ttl 64, id 40649, offset 0, flags [DF], proto UDP (17), length 34) 192.168.1.17.35829 > 192.168.1.255.11111: [udp sum ok] UDP, length 6 How can I send a (broadcast) udp packet from a specific port? N.B. I also tried sending a unicast udp packet with socat, but sourceport wasn't honored there either. |
How to create heredocs on RAM instead of disk? Posted: 18 Jun 2022 07:05 PM PDT Saving following script in a file: cat <<EOF | wc -l $HOME abc $(hostname) EOF and executing it gives the following error: $ ./a.sh ./a.sh: line 1: cannot create temp file for here-document: No space left on device My Debian thinks that there is no space left on the device (which is not true, but it's out of our context). However I have a plenty of RAM space. Since my tools (scripts) also refuse to work because of this error, I'm unable to resolve the actual "no space left" issue. What can I do to make my scripts use the RAM for the "heredoc" handling process in order to get them working at least, so that I can move forward to resolve the actual problem by using my tools? |
How to pipe grep and keep headers? Posted: 18 Jun 2022 05:53 PM PDT In the example below, I have the right selection, but not the headers, and conversely. How can I have both? $ ps aux | grep 'gpart' erwann 200603 0.0 0.0 2608 72 pts/3 S 12:57 0:00 /bin/sh /usr/sbin/gparted root 200608 0.0 0.0 2608 1056 pts/3 S 12:57 0:00 /bin/sh /usr/sbin/gparted root 200693 0.0 0.0 2608 68 pts/3 S 12:57 0:00 /bin/sh /usr/lib/udisks2/udisks2-inhibit /usr/sbin/gpartedbin root 200700 1.9 0.2 264960 18620 pts/3 SLl 12:57 8:31 /usr/sbin/gpartedbin root 202327 99.8 0.0 2520 64 pts/3 R 13:36 400:07 gpart -s 512 /dev/sdc erwann 214723 0.0 0.0 9032 716 pts/4 S+ 20:17 0:00 grep --color=auto gpart $ ps aux | tee >(head -n1) >(grep 'gpart') > /dev/null USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND |
How to filter results from a csv file based on patterns in columns 1 and 7 using sed? Posted: 18 Jun 2022 05:08 PM PDT I'm trying to write a shell script that scans both columns 1 and 7 for user-specified values, with $3 being matched in 7th column and $2 being a year matched in first column (and $1 the filename). I can match the 7th col just fine, but keep receiving the error 'sed: -e expression #1, char 7: unknown command: `2' when attempting to add the variable to match in first column. I have to use sed instead of awk for this unfortunately. Here's what I have thus far: sed -n "/"$2",[^,],[^,],[^,],[^,],[^,]*,"$3"/p" "$1" what should I try to fix this? I'm quite a noobie so all help is welcome. Tried shellcheck but it hasn't helped. The script runs fine when scanning 7th column but adding the $2 aspect causes errors. Edit: Adding more context. An example invocation would be: ./script.sh file.csv "2014/2015" "Grand Forks" Sample of csv being used (the".." is an empty column, didn't want to break rows into separate lines): 2014/2015,School,Public School,51,Boundary,511202,Christina,..,..,.. 2014/2015,School,Public School,51,Boundary,511202,Christina,..,..,.. 2014/2015,School,Public School,51,Boundary,511202,Grand Forks,..,..,.. 2014/2015,School,Public School,51,Boundary,511202,Other,..,..,.. With the desired output being: 2014/2015,School,Public School,51,Boundary,511202,Grand Forks,..,..,.. Thanks in advance |
Transparently Rate Limiting ANY Connection that is Already In-Progress Posted: 18 Jun 2022 03:19 PM PDT Let's say I begin a large download, and about an hour into it, I find that it is consuming too much of my overall bandwidth. Is there any way to rate limit that particular connection "after the fact"? I've seen tools that will allow you to control a download's speed if you begin the download using those tools, but I'm interesting a way to rate limit a download of ANY connection (even if it is already in progress). How can this be done? |
Ancient VGA card causes freeze Posted: 18 Jun 2022 02:46 PM PDT I am a recovering Window user evaluating Linux Mint (19.3 Cinnamon 4.4.8) as a replacement OS for my venerable HP 505B Desktop. But apparently the installed Nvidia VGA card (GeForce 6150SE nForce 430) occasionally causes a freeze up and reboot. It appears that Nouveau driver (v: kernel) is installed (instead of Nvidia driver I think). As a Linux newbie I can only run <inxi -G> successfully but not much else. Is there any hope of fixing this situation for a nice guy newbie like me :-) Bewildered Bob |
libvirt copy and paste breaks regularly Posted: 18 Jun 2022 02:22 PM PDT I havent been able to identify the cause (besides it seeming to happen with cloned VMs - though I've tried changing the Spice ports to be different, and also tried using VNC on one and Spice on another), and while I thought using VNC instead resolved it, but the copy and paste functionality keeps going out. (this is on a Kubuntu host and guests, but also happens with a Lubuntu guest). Restarting libvirtd resolves the issue, but I have to reopen all the VM windows. Sometimes copying several times will fix the issue, so I thought it might be a problem with the text not making it into the copy buffer. The middle click buffer doesnt work either. I did just notice that when pressing ctrl-c to copy several times in a hose, the c letter was typed in a guest, so maybe the control key is not registering somehow. I can copy and paste within the host and within the guests just fine, its just going between that fails, which I do surprisingly regularly. Any ideas on how to troubleshoot this any further? Or if possible, reset (or jog) just this part of libvirtd without restarting the whole thing? (I opened an issue with Virt-manager when I thought that just using VNC would fix it here: https://github.com/virt-manager/virt-manager/issues/379, but havent made any further progress there.) |
Why us ROKU TV connecting to my PC through my router? Posted: 18 Jun 2022 02:03 PM PDT I noticed this connections "HisenseRokuTV-SXP.lan" in my arp list of connections. That seems pretty sketchy, as even though I'm using the TV as a monitor through HDMI, they are only connected through my router. I checked my GLi.net router for a button to isolate APs, like my DD-WRT router has, but didnt find one (so I just blocked it for now). I can route the TV through my DD-WRT router for that, but I feel like my firewall shouldn't have allowed that (maybe it did when it was disabled). So how should I set my firewall to block such a connection? I'm using UFW on Kubuntu 22.04, and have incoming blocked and forwarding allowed (for VMs). I only have two rules in iptables to allow established connections (not sure if there are better rules for this). iptables -I INPUT 1 -i lo -j ACCEPT iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT |
Exclude patterns from glob match Posted: 18 Jun 2022 04:19 PM PDT My directory looks like this: $ ls total 0 -rw-r--r-- 1 user user 0 Jun 18 22:44 file0 -rw-r--r-- 1 user user 0 Jun 18 22:44 file1 -rw-r--r-- 1 user user 0 Jun 18 22:44 file2 -rw-r--r-- 1 user user 0 Jun 18 22:44 file3 -rw-r--r-- 1 user user 0 Jun 18 22:44 file4 -rw-r--r-- 1 user user 0 Jun 18 22:44 file5 -rw-r--r-- 1 user user 0 Jun 18 22:44 file6 -rw-r--r-- 1 user user 0 Jun 18 22:44 file7 -rw-r--r-- 1 user user 0 Jun 18 22:44 file8 -rw-r--r-- 1 user user 0 Jun 18 22:44 file9 Using bash globbing, I want to match file2 to file6 , excluding file3 . Since I could not find an and operator for matching multiple patterns, I figured I just use DeMorgan's law that a AND b is equivalent to !(!a OR !b) and write !(!(file[2-6])|file3) which works as expected: $ echo !(!(file[2-6])|file3) file2 file4 file5 file6 Is there an easier, more direct way to achieve this? |
How to source a script code (set a variable) from another shell? Posted: 18 Jun 2022 02:51 PM PDT I tried to use FreeBSD. The FreeBSD root user uses csh by default. user@freebsd-13:~ $ echo $SHELL /bin/csh I know that setting a variable via $() does not work in csh . root@freebsd-13:~ # export test=$(echo hello3) Illegal variable name. I want to do something like that root@freebsd-13:~ # sh -c "export test=$(echo hello3)" Illegal variable name. root@freebsd-13:~ # And it does not work either... Another attempt: root@freebsd-13:~ # sh -c "export test=`echo hello5`" root@freebsd-13:~ # echo $test test: Undefined variable. root@freebsd-13:~ # sh -c "echo "$test"" test: Undefined variable. root@freebsd-13:~ # root@freebsd-13:~ # /bin/sh -c "export test=`echo hello3`" root@freebsd-13:~ # echo $test test: Undefined variable. root@freebsd-13:~ # /bin/sh -c "echo "$test"" test: Undefined variable. root@freebsd-13:~ # Tried to source it: root@freebsd-13:~ # . sh -c "export test=$(echo hello3)" Illegal variable name. root@freebsd-13:~ # root@freebsd-13:~ # . sh -c "export test=`echo hello3`" .: Command not found. root@freebsd-13:~ # root@freebsd-13:~ # source sh -c "export test=`echo hello3`" sh: No such file or directory. root@freebsd-13:~ # root@freebsd-13:~ # source /bin/sh -c "export test=`echo hello3`" Unmatched '"'. root@freebsd-13:~ # source /bin/sh -c "export test=$(echo hello3)" Illegal variable name. root@freebsd-13:~ # root@freebsd-13:~ # source /bin/sh -c "export test="$(echo hello3)"" Illegal variable name. root@freebsd-13:~ # How should it be done properly? |
Avoid symlink race rcondition with "mv" in Bash Posted: 18 Jun 2022 03:59 PM PDT I want to safely write to a destination file (as root, unter common Linux'es) with "echo" (or catany other Bash built-in stuff) like this echo "foo" > /destination/dir/filename But the problem is that /destination/dir could be accessible for normal system users, so there is the risk of symlink conditions. I read all the "how to" for preventing TOC-TOU stuff when using C, so NOT checking for symlink/remove it and open then (the common recommendations seems to be to open() with O_NOFOLLOW). But all of this (access to kernel open() and it's flags) is not possible via Bash (or am I wrong?). Then I got the idea of - creating a tempfile with mktemp
- chown+chmod the tempfile appropriately
- write the contents to write to the tempfile
- move the tempfile to the destination dir with the Bash param "-T"
So as some Bash peudo-code (without error checking at some places) TEMPFILE=$(mktemp) chown root:root $TEMPFILE chmod 0600 $TEMPFILE echo "contents" > $TEMPFILE mv -T $TEMPFILE /destination/dir/filename I just tested it with "/destination/dir/filename" to be a symlink to a system file, but it worked: "mv" did move the tempfile correctly to the "filename", the symlink was removed (which is was I intended), no file was overwritten. Is there anythink I missed out with regards to security/race conditions etc.? Thanks :-) |
Remove all characters from string, except specific multibyte range Posted: 18 Jun 2022 06:07 PM PDT How would one use sed or another tool to remove all characters except a specific multibyte range? For instance, the range \xd8\xa0 - \xd9\x8a covers Arabic characters encoded in UTF-8. This was my naive hopeful attempt at using sed: $ echo "Peace be upon you. السلام عليكم. שלום עליכם. Paz sobre vosotros." | sed -n -e 's|[^\xd8\xa0-\xd9\x8a]||p' sed: -e expression #1, char 25: Invalid range end Had sed understood multibyte characters, that should have left us with the string: السلام عليكم I have considered using iconv to convert to some Arabic-specific encoding, use sed , then convert back. However the work that I'm doing is non-trival, such as I might want to preserve both Arabic and Hebrew, so I'd like to keep everything in UTF-8 for the entire time if possible. If sed cannot work with multibyte characters, what should I use? I've searched for both sed and perl solutions with no luck. Note that I've tried to add a UTF-8 tag to the question, but unix.SE changes that to a Unicode tag. There is no Unicode here, these are encoded strings stored on disk. I think that there should be a separate UTF-8 tag. |
What is the linux command to find exact size of a file in KB as reflected in WinSCP? Posted: 18 Jun 2022 04:39 PM PDT I need to find size of a file abc.log which shows size as 1KB when I view it from WinSCP. These are my attempts so far - stat -c%s abc.log - output is 2 (giving size of file content which is 2 bytes) wc -c abc.log - output is 2 ls -l abc.log - showing size as 2 du -h abc.log - output is 4.0K (this means disk space occupied by abc.log , right?) du -b abc.log - output is 2 du -k abc.log - output is 4 But what command would give me output as 1k or 1 at least as that is the size which is showing under the "Size" column in WinSCP? (On copying the file in Windows machine also it is showing 1KB ) I have tried find -name abc.log -size 1k and it gave me output as abc.log meaning that it has detected the size of abc.log as 1kB . I am not understanding where 1k is appearing from because even commands like du are not showing 1k . But I need a command such that when I pass filename as input it would give me the file size exactly as shown in WinSCP and as detected by the find command. |
Trying to boot linux from live usb for the first time, stuck on GRUB command line Posted: 18 Jun 2022 02:16 PM PDT I'm trying to install openSUSE Tumbleweed to replace Windows 11 on my machine. I've created a live USB stick containing openSUSE Tumbleweed, and set it as the first and only boot option in the UEFI. Booting from the USB brings up GRUB command line: Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists possible device or file completions. >grub Entering ls command outputs: (proc) (hd0) (hd0,mdos1) (hd1) (hd1,gpt5) (hd1,gpt4) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) And entering the ls command to show the root partitions for every device name and index, i.e. ls (hd0,1)/ , outputs: error: ../ ../grub-core/kern/fs.c:121:unkown filesystem except for (hd1,gpt1) , where entering the command ls (hd1,1)/ outputs: efi/ System Volume Information/ I'm not sure where to go from here to successfully boot into openSUSE TW, any suggestions? |
Updating my kali 2017 to 2022 Posted: 18 Jun 2022 05:02 PM PDT I newly installed kali Linux on my machine as main OS, when I tried sudo apt update && sudo apt full-upgrade to latest version of kali Linux, it downloaded, when I rebooted there's no update yet, still Stuck in 2017.1 |
Kali failed to start file system check on /dev/mapper/hostname--vg-home Posted: 18 Jun 2022 05:03 PM PDT Kali Linux 5.16.0 Lenovo ThinkPad G580 Intel i3 3110M @2.40GHz Mem: 8192MB whenever booting I am greeted with the message that the OS is in "Emergency Mode and that the root account is locked. I am instructed that I could use various commands '*journalctl -xb to view system logs. "systemctl reboot"...' to reboot' None of the commands can be executed, I am caught in a loop wherein all I can do is press enter over and over. After investigating the system log this information is returned: "[Failed] Failed to start File System check on /Dev/mapper/hostname--vg-home [Depend] Dependency failed for /home. [Depend] Dependency failed for Local File Systems. Mounting arbitrary Executable File Formats File System..." All I can decipher here is that there is an issue with an I/O device and so the kernal cannot find the block which contains home directory within the hard disk? As you can probably tell I am a Linux n00b. This was a second hand laptop, I enjoy experimenting with the Kali tools as a Cybersecurity students and I want to learn how to fix this issue. Things I have tried.. I have tried using decent search engines like Google and yandex to search for the failed and depend statements hoping to find some helpful forum posts. Including registering and searching for this on this website. Some posts which only vaguely seem to address the emergency mode issue seem to veer away from the issue or are on a level of expertise which seems to be way over my head. I have tried booting Kali from a partition made using Rufus on a USB, but each time I try it says it cannot locate the media device ): One time I figured out how to access TTY to execute shell commands but for the life of me I can't find the correct button to interrupt the boot process to launch TTY again so I can noodle around using a shell. Please, I humbly ask for you help. Thank you. |
Please help! Sub-process /usr/bin/dpkg returned an error code (1) Installing MySQL on Ubuntu Posted: 18 Jun 2022 03:04 PM PDT I'm trying to install mysql with Ubuntu and I've spent the last 3 days purging MySQL and redownloading to no avail. Most of the solutions I found didn't work for me, and they are all some variation of deleting MySQL and redownloading. Ive tried manually going into the files and manually deleting all MySQL related files too. Any help would be appreciated! I've also tried reinstalling some dpkg files but as you can tell I'm pretty new to this. alvin@DESKTOP-DAIIHEJ:~$ sudo apt-get install mysql-server [sudo] password for alvin: Reading package lists... Done Building dependency tree Reading state information... Done mysql-server is already the newest version (8.0.27-0ubuntu0.20.04.1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up mysql-server-8.0 (8.0.27-0ubuntu0.20.04.1) ... invoke-rc.d: could not determine current runlevel * Stopping MySQL database server mysqld [ OK ] Renaming removed key_buffer and myisam-recover options (if present) Cannot open /proc/net/unix: No such file or directory Cannot stat file /proc/1/fd/5: Operation not permitted Cannot stat file /proc/1/fd/10: Operation not permitted Cannot stat file /proc/1/fd/6: Operation not permitted Cannot stat file /proc/10/fd/7: Operation not permitted Cannot stat file /proc/10/fd/10: Operation not permitted Cannot stat file /proc/10/fd/5: Operation not permitted mysqld will log errors to /var/log/mysql/error.log mysqld is running as pid 143 dpkg: error processing package mysql-server-8.0 (--configure): installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1 No apport report written because the error message indicates its a followup error from a previous failure. dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-8.0; however: Package mysql-server-8.0 is not configured yet. dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured Errors were encountered while processing: mysql-server-8.0 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1) This is my error log 2022-01-27T22:38:25.061002Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.27-0ubuntu0.20.04.1). 2022-01-27T22:38:25.981554Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu). 2022-01-27T22:38:26.615434Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27-0ubuntu0.20.04.1) starting as process 206 2022-01-27T22:38:26.629831Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-01-27T22:38:26.648358Z 1 [ERROR] [MY-012585] [InnoDB] Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB. 2022-01-27T22:38:26.648440Z 1 [Warning] [MY-012654] [InnoDB] Linux Native AIO disabled. 2022-01-27T22:38:26.787334Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-01-27T22:38:26.848746Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock' 2022-01-27T22:38:26.946919Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2022-01-27T22:38:26.946963Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2022-01-27T22:38:26.948630Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2022-01-27T22:38:26.948712Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2022-01-27T22:38:26.949587Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Permission denied 2022-01-27T22:38:26.949630Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ? 2022-01-27T22:38:26.949908Z 0 [ERROR] [MY-010119] [Server] Aborting 2022-01-27T22:38:27.949853Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27-0ubuntu0.20.04.1) (Ubuntu). Here is the result of mount | grep proc proc on /proc type proc (rw,nosuid,nodev,noexec,noatime) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) – |
How to change the tmux working directory with a shell command Posted: 18 Jun 2022 06:47 PM PDT I want to create a shell command that, when run, sets the working directory of the current tmux session to the current working directory. There are numerous answered questions on how to set the session working directory; the answer seems to be to run attach-session -t . -c /path/to/directory in the tmux command prompt. Under my (default) configuration, that'd be C-b : attach-session -t . -c /path/to/directory . I don't want to manually interact with the tmux command prompt; I want a simple command, mostly because I don't want to deal with typing out or copy-pasting the target directory. I know it's possible to send commands to tmux from a shell prompt; for instance, I can run tmux display-message MESSAGE at the shell instead of C-b : display-message HELLO to show a message in the status bar. However, running tmux attach-session -t (tmux display-message -p '#S') -c (pwd) throws an error: "sessions should be nested with care, unset $TMUX to force". Of course, I don't have any desire to nest a tmux session, I only want to change the directory of the current session. I've also tried using tmux send-keys and tmux-send-prefix , but these seem to forward the key sequences to the underlying tty (where the shell responds to them) rather than directly to tmux. I'm using the fish shell, but I'm assuming the solution would fit in a shell script, so I'm happy with a solution in any language. |
Get cursor back after killing xkill Posted: 18 Jun 2022 02:41 PM PDT Assume that you accidentally typed xkill on a terminal and you killed by Ctrl+Z or Ctrl+X . Now the cursor is an X and it doesn't really function. How can I get the cursor back without rebooting the PC? |
SH/BASH: Store Command Parameter with Whitespace in Variable [duplicate] Posted: 18 Jun 2022 06:22 PM PDT I'm trying to store a command string in a variable for later execution. The problem is that the command includes a parameter argument with whitespace. When the command is executed, instead of seeing the argument as a single string, the shell interprets it as two, including the double-quote characters: Example: $ CMD_CMAKE="cmake -G \"MSYS Makefiles\" ../../source/poppler-0.79/" $ ${CMD_CMAKE} CMake Error: Could not create named generator "MSYS I need to pass -G "MSYS Makefiles" to the cmake command. Instead, -G \"MSYS and Makefiles\" are being passed. I have tried all of the following with no success: $ CMD_CMAKE='cmake -G "MSYS Makefiles" ../../source/poppler-0.79/' $ CMD_CMAKE="cmake -G 'MSYS Makefiles' ../../source/poppler-0.79/" $ CMD_CMAKE="cmake -G MSYS\ Makefiles ../../source/poppler-0.79/" $ CMD_CMAKE="cmake -G MSYS\\ Makefiles ../../source/poppler-0.79/" $ GEN="MSYS Makefiles" && CMD_CMAKE="cmake -G ${GEN} ../../source/poppler-0.79/" $ GEN="MSYS Makefiles" && CMD_CMAKE="cmake -G \"${GEN}\" ../../source/poppler-0.79/" $ CMD_CMAKE=$(echo "cmake -G \"MSYS Makefiles\" ../../source/poppler-0.79/") $ CMD_CMAKE=$(echo 'cmake -G "MSYS Makefiles" ../../source/poppler-0.79/') I have done some searching around on Google, but I am not finding any answers. Perhaps because I am not using the correct terminology. Edit: I'm sorry, I think I should have posted this question on stackoverflow.com. Edit: 2022-06-18 This question has been closed as a duplicate, so answers cannot be added. But the solution was to store the command in an array: CMD_CMAKE=(cmake -G "MSYS Makefiles" ../../source/poppler-0.79/) Then execute it enclosed within quotes: "${CMD_CMAKE[@]}" Thanks to jesse_b & Kusalananda for the help. |
How to fix gnu screen term detection when started on detached mode? Posted: 18 Jun 2022 02:06 PM PDT I'm writing a script that spawns a screen process but depends on some pre-conditions I intend to perform before attaching to it. I noticed that when started in detached mode it does not recognize the $TERM , but I do not want to hardcode it on .screenrc , and I did not find anyone with the same problem. Here's my environment: $ screen --version Screen version 4.06.02 (GNU) 23-Oct-17 $ echo $TERM xterm-256color Here you can see it works as expected: $ screen -ADRS profile $ echo $TERM screen.xterm-256color But if done this way it goes all wrong: $ screen -dmS profile # I will perform some stuff here, then: $ screen -ADrS profile # here you can notice the colors have gone $ echo $TERM screen How can I spawn a detached screen but get the same $TERM behavior as it was in the first case, without hardcoding the term on .screenrc ? |
Create Palette Image with Multiple Rows Using ImageMagick Posted: 18 Jun 2022 06:49 PM PDT I have learned how to generate a palette image from a source image using ImageMagick: convert source.png -colors 256 -unique-colors -scale 1000% palette.png An image with a single row of colors, such as the following, is output: However, I would like set a value to limit the number of squares/columns, & start a new row when that number is reached. So the output should look more like this: Is it possible to do this with ImageMagick? Or is there another method to do so? |
Mount Samsung Galaxy S7 using simple-mtpfs Posted: 18 Jun 2022 06:07 PM PDT I would like to mount my Samsung Galaxy S7 to an folder using simple-mtpfs and I cannot do it as I used to (on previous Fedora and older Galaxy S4). If I simply plug S7 to my computer, I can browse it using Nautilius, but I cannot access it in terminal as ordinary folder, what is exactly what I want to achieve. Every time I plug S7 I check twice that it works in MTP mode, so that isn't the problem. In the past, I simply plugged S4 and typed: simple-mtpfs /home/adam/S4 Now, I can perform it and even my phone ask me to confirm MTP choice, but the catalogue S7 is still empty. I also tried to mount it as root or ordinary user and by device number, but with no result. # simple-mtpfs --list-devices 1: SamsungGalaxy models (MTP) $ simple-mtpfs --device 1 /home/adam/S7 # simple-mtpfs --device 1 /media/s7 $ simple-mtpfs /dev/libmtp-3-1 /home/adam/s7 # simple-mtpfs /dev/libmtp-3-1 /media/s7 I even tried to do it by udev rules: # dmesg | tail [16821.258485] usb 3-1: Product: SAMSUNG_Android [16821.258487] usb 3-1: Manufacturer: SAMSUNG [16821.258489] usb 3-1: SerialNumber: 98867????????????? [16827.556099] usb 3-1: USB disconnect, device number 29 [16830.383366] usb 3-1: new high-speed USB device number 30 using xhci_hcd [16830.548882] usb 3-1: New USB device found, idVendor=04e8, idProduct=6860 [16830.548887] usb 3-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4 [16830.548903] usb 3-1: Product: SAMSUNG_Android [16830.548905] usb 3-1: Manufacturer: SAMSUNG [16830.548907] usb 3-1: SerialNumber: 98867????????????? # touch /etc/udev/rules.d/10-phone.rules Content of /etc/udev/rules.d/10-phone.rules is set to: SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}="6860", SYMLINK="S7" After reloading rules I have /dev/S7 and I've tried to mount it: # udevadm control --reload-rules # ls -l /dev/S7 lrwxrwxrwx. 1 root root 15 10-20 15:03 /dev/S7 -> bus/usb/003/075 # ls -l /dev/libmtp-3-1 lrwxrwxrwx. 1 root root 15 10-20 15:03 /dev/libmtp-3-1 -> bus/usb/003/075 # simple-mtpfs /dev/S7 /media/s7 And still without any result. Mounting doesn't give and errors, but the directory where I about to mount is still empty. The details about my setup: # uname -r 4.7.7-200.fc24.x86_64 # rpm -qa | grep mtp simple-mtpfs-0.2-6.fc24.x86_64 libmtp-1.1.11-1.fc24.x86_64 gvfs-mtp-1.28.3-1.fc24.x86_64 # rpm -qa | grep fuse fuse-libs-2.9.7-1.fc24.x86_64 glusterfs-fuse-3.8.4-1.fc24.x86_64 fuse-2.9.7-1.fc24.x86_64 gvfs-fuse-1.28.3-1.fc24.x86_64 Extract from system log (Fedora's journalctl) after plugging the phone and typing simple-mtpfs /media/s7 : # journalctl -n 53 -- Logs begin at śro 2016-10-19 21:29:20 CEST, end at sob 2016-10-22 09:26:43 CEST. -- paź 22 09:24:31 PRZEDNICZEK01 kernel: usb 3-1: USB disconnect, device number 10 paź 22 09:24:31 PRZEDNICZEK01 PackageKit[1559]: get-updates transaction /384_eccedcee from uid 1000 finished with success after 45ms paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: new high-speed USB device number 11 using xhci_hcd paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: New USB device found, idVendor=04e8, idProduct=6860 paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4 paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: Product: SAMSUNG_Android paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: Manufacturer: SAMSUNG paź 22 09:24:32 PRZEDNICZEK01 kernel: usb 3-1: SerialNumber: 98867????????????? paź 22 09:24:32 PRZEDNICZEK01 gvfsd[1813]: PTP: reading event an error 0x02ff occurredDevice 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP). paź 22 09:24:32 PRZEDNICZEK01 gvfsd[1813]: LIBMTP ERROR: couldnt parse extension samsung.com/devicestatus:0 paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: Could not find parent node for URI:'mtp://[usb:003,011]/' paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: NOTE: URI theme may be outside scheme expected, for example, expecting 'file://' when given 'http://' prefix. paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: Could not find parent node for URI:'mtp://[usb:003,011]/' paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: NOTE: URI theme may be outside scheme expected, for example, expecting 'file://' when given 'http://' prefix. paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-CRITICAL **: Could not set mount point in database 'urn:nepomuk:datasource:5e7b19a6b9795726a5c47a99a89757bf', GDBus.Error:org.freedesktop.Tracker1.SparqlError.Internal: UNIQUE constraint paź 22 09:24:32 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-CRITICAL **: Could not set mount point in database 'urn:nepomuk:datasource:5c7e6bb78b9a6691c3ecea3925b2971d', GDBus.Error:org.freedesktop.Tracker1.SparqlError.Internal: UNIQUE constraint paź 22 09:24:34 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: (gnome-shell:1832): Gjs-WARNING **: JS ERROR: TypeError: is null paź 22 09:24:34 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: ContentTypeDiscoverer<._onContentTypeGuessed/<@resource:///org/gnome/shell/ui/components/autorunManager.js:133 paź 22 09:24:34 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: _proxyInvoker/asyncCallback@resource:///org/gnome/gjs/modules/overrides/Gio.js:86 paź 22 09:24:34 PRZEDNICZEK01 gvfsd[1813]: ** (process:3243): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/18 (g-dbus-error-quark, 19) paź 22 09:24:34 PRZEDNICZEK01 gvfsd[1813]: ** (process:3243): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/18 (g-dbus-error-quark, 19) paź 22 09:24:34 PRZEDNICZEK01 gvfsd[1813]: ** (process:3243): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/18 (g-dbus-error-quark, 19) paź 22 09:24:34 PRZEDNICZEK01 gvfsd[1813]: ** (process:3243): WARNING **: send_done_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/18 (g-dbus-error-quark, 19) paź 22 09:24:35 PRZEDNICZEK01 PackageKit[1559]: get-updates transaction /385_decdbbba from uid 1000 finished with success after 45ms paź 22 09:26:37 PRZEDNICZEK01 kernel: usb 3-1: usbfs: process 3385 (simple-mtpfs) did not claim interface 0 before use paź 22 09:26:37 PRZEDNICZEK01 kernel: usb 3-1: reset high-speed USB device number 11 using xhci_hcd paź 22 09:26:38 PRZEDNICZEK01 kernel: usb 3-1: usbfs: process 3385 (simple-mtpfs) did not claim interface 0 before use paź 22 09:26:38 PRZEDNICZEK01 kernel: usb 3-1: usbfs: process 3250 (events) did not claim interface 0 before use paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: USB disconnect, device number 11 paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: new high-speed USB device number 12 using xhci_hcd paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: New USB device found, idVendor=04e8, idProduct=6860 paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4 paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: Product: SAMSUNG_Android paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: Manufacturer: SAMSUNG paź 22 09:26:40 PRZEDNICZEK01 kernel: usb 3-1: SerialNumber: 98867????????????? paź 22 09:26:41 PRZEDNICZEK01 gvfsd[1813]: PTP: reading event an error 0x02ff occurredDevice 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP). paź 22 09:26:41 PRZEDNICZEK01 gvfsd[1813]: LIBMTP ERROR: couldnt parse extension samsung.com/devicestatus:0 paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: Could not find parent node for URI:'mtp://[usb:003,012]/' paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: NOTE: URI theme may be outside scheme expected, for example, expecting 'file://' when given 'http://' prefix. paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: Could not find parent node for URI:'mtp://[usb:003,012]/' paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-WARNING **: NOTE: URI theme may be outside scheme expected, for example, expecting 'file://' when given 'http://' prefix. paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-CRITICAL **: Could not set mount point in database 'urn:nepomuk:datasource:0e6a8582e05ac627e4014d1ca1e6ec87', GDBus.Error:org.freedesktop.Tracker1.SparqlError.Internal: UNIQUE constraint paź 22 09:26:41 PRZEDNICZEK01 tracker-miner-fs.desktop[2001]: (tracker-miner-fs:2001): Tracker-CRITICAL **: Could not set mount point in database 'urn:nepomuk:datasource:5c7e6bb78b9a6691c3ecea3925b2971d', GDBus.Error:org.freedesktop.Tracker1.SparqlError.Internal: UNIQUE constraint paź 22 09:26:41 PRZEDNICZEK01 dbus-daemon[1760]: [session uid=1000 pid=1760] Activating service name='org.gnome.Shell.HotplugSniffer' requested by ':1.16' (uid=1000 pid=1832 comm="/usr/bin/gnome-shell " label="unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023") paź 22 09:26:41 PRZEDNICZEK01 dbus-daemon[1760]: [session uid=1000 pid=1760] Successfully activated service 'org.gnome.Shell.HotplugSniffer' paź 22 09:26:42 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: (gnome-shell:1832): Gjs-WARNING **: JS ERROR: TypeError: is null paź 22 09:26:42 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: ContentTypeDiscoverer<._onContentTypeGuessed/<@resource:///org/gnome/shell/ui/components/autorunManager.js:133 paź 22 09:26:42 PRZEDNICZEK01 org.gnome.Shell.desktop[1832]: _proxyInvoker/asyncCallback@resource:///org/gnome/gjs/modules/overrides/Gio.js:86 paź 22 09:26:43 PRZEDNICZEK01 gvfsd[1813]: ** (process:3399): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/17 (g-dbus-error-quark, 19) paź 22 09:26:43 PRZEDNICZEK01 gvfsd[1813]: ** (process:3399): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/17 (g-dbus-error-quark, 19) paź 22 09:26:43 PRZEDNICZEK01 gvfsd[1813]: ** (process:3399): WARNING **: send_infos_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/17 (g-dbus-error-quark, 19) paź 22 09:26:43 PRZEDNICZEK01 gvfsd[1813]: ** (process:3399): WARNING **: send_done_cb: No such interface 'org.gtk.vfs.Enumerator' on object at path /org/gtk/vfs/client/enumerator/17 (g-dbus-error-quark, 19) paź 22 09:26:43 PRZEDNICZEK01 PackageKit[1559]: get-updates transaction /386_acdeddea from uid 1000 finished with success after 48ms |
Prevent MATE from launching Caja Desktop when running i3 Posted: 18 Jun 2022 04:03 PM PDT A while back I installed i3 on my MATE box, and I'm quite happy with it, however despite disabling Caja Desktop (x-caja-desktop ) when setting i3 as the default window manager through dconf editor, every time I install a .deb package via the gui installer, the desktop "window" opens and overlays my entire screen. This is incredibly annoying, and hitting super-shift-q to close the window doesn't work, which forces me to just move it to an unused workspace. Is there anything I can do to stop this from happening without installing a different file manager? |
how to run a script on ubuntu shutdown when it needs network on Posted: 18 Jun 2022 07:07 PM PDT I have an upstart script that needs to run on reboot or shutdown, but it needs to access the network to post an http requests and wait for the replies, I tried start on starting rc and start on starting (rc and net-device-up IFACE=eth0) but no luck. |
GStreamer and sample rate conversion Posted: 18 Jun 2022 05:05 PM PDT I have a soundcard that is only partially supported in Alsa, i.e. playback is only working in 48 kHz. Most of my audio files are in 44.1 kHz, and I would like to use Exaile as my audio player, as it has all the functionality that I need. The problem is, that gstreamer - the backend for exaile - does not convert the sample rate with my current settings, so playing back the audio files will result in a speed up, while playing the files with mplayer works just fine, mplayer does sample rate conversion on playback. Is there a way to get gstreamer to convert the sample rate? EDIT: The sound card in question is an E-MU 0404 PCI express, see http://alsa-project.org/main/index.php/Matrix:Vendor-Creative_Labs and http://alsa-project.org/main/index.php/Matrix:Module-emu10k1-fpga |
How to detect from script when the user's desktop is loaded? Posted: 18 Jun 2022 03:23 PM PDT I have a daemon, implemented in bash and running by means of cron and the @reboot option, that shows the desktop in inactivity. The script is as following (timings are short for testing purposes): #!/bin/bash P_STATE=0 while : do sleep 5 if [ $P_STATE == 0 ]; then [ `xprintidle` -ge 25000 ] && P_STATE=1 && wmctrl -k on else [ `xprintidle` -le 25000 ] && P_STATE=0 done Problem: If a user is still, for example, in the login screen, xprintidle and wmctrl fails since the desktop isn't yet loaded. In order to avoid this, I've put the next lines at the very beginning of the script: while: do sleep 10s [ -n `who | grep "$USER"` ] && break done So, the script waits the user (the USER variable is set to my user-name in the crontab file) is logged. But, it a user begins, for example, a terminal session (and not a graphical session like KDE or GNOME), the script also continue. How can I determine if a user is already in a "graphical" session capable of "showing desktop mode" or not? And moreover, how can I ensure that a "graphical" session is completely loaded and not in process of loading or something like that? My solution: My (informal) solution is adding in the main loop the grep line: WAIT_TIME=180 while: do sleep $WAIT_TIME [ ! -n "`ps -ef | grep "$WM_CMD" | grep -v "grep"`" ] && continue ## My actions here done Being "$WM_CMD" the target windows manager command. I assume that, if the windows manager command is running in the system, it means the desktop is completely loaded and any "graphic" command is sure. Where is WM_CMD variable defined? In the crontab line: @reboot DISPLAY=:0 WM_CMD=/usr/bin/gnome-shell exec script_path/myscript.sh &> /dev/null But also I think that it would be possible to detect the "windows manager command" by means of other system requests. However, for me defining WM_CMD in the crontab file is enough. |
How to execute a shellscript when I plug-in a USB-device Posted: 18 Jun 2022 04:04 PM PDT I want to execute a script when I plug in a device in my Linux machine. For example, run xinput on mouse or a backupscript on a certain drive. I have seen a lot of articles on this, most recently here and here. But I just can't get it to work. Here's some simple examples trying to get at least some kind of response. /etc/udev/rules.d/test.rules #KERNEL=="sd*", ATTRS{vendor}=="*", ATTRS{model}=="*", ATTRS{serial}=="*", RUN+="/usr/local/bin/test.sh" #KERNEL=="sd*", ACTION=="add", "SUBSYSTEM=="usb", ATTRS{model}=="My Book 1140 ", ATTRS{serial}=="0841752394756103457194857249", RUN+="/usr/local/bin/test.sh" #ACTION=="add", "SUBSYSTEM=="usb", RUN+="/usr/local/bin/test.sh" #KERNEL=="sd*", ACTION=={add}, RUN+="/usr/local/bin/test.sh" KERNEL=="sd*", RUN+="/usr/local/bin/test.sh" KERNEL=="*", RUN+="/usr/local/bin/test.sh" /usr/local/bin/test.sh #!/usr/bin/env bash echo touched >> /var/log/test.log if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ] then echo ${DEVICE} >> /var/log/test.log fi The rules folder is watched by inotify and should be active immediately. I keep replugging my keyboard, mouse, tablet, memorystick and usb-drive, but nothing. No log file touched. Now, what would be the most simple way to at least know something is working? It's easier to work from something that's working than from something that's not. |
Screen turns on automatically (xset dpms force off) Posted: 18 Jun 2022 05:06 PM PDT I am using xset dpms force off to manually turn my screen off to save power. However, it turns back on after some time (20 - 40 seconds). Distro: Ubuntu-Lucid Graphics: Intel 4500 MHD Trying steps in this solution (Turning off screensaver or wireless) did not work. Can it be due to any other reasons like network (magic packet) or usb devices? Result of xset -q : Keyboard Control: auto repeat: on key click percent: 0 LED mask: 00000000 XKB indicators: 00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off 03: Compose: off 04: Kana: off 05: Sleep: off 06: Suspend: off 07: Mute: off 08: Misc: off 09: Mail: off 10: Charging: off 11: Shift Lock: off 12: Group 2: off 13: Mouse Keys: off auto repeat delay: 500 repeat rate: 30 auto repeating keys: 00ffffffdffffbbf fadfffefffedffff 9fffffffffffffff fff7ffffffffffff bell percent: 50 bell pitch: 400 bell duration: 100 Pointer Control: acceleration: 2/1 threshold: 4 Screen Saver: prefer blanking: yes allow exposures: yes timeout: 0 cycle: 0 Colors: default colormap: 0x20 BlackPixel: 0 WhitePixel: 16777215 Font Path: /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType,built-ins DPMS (Energy Star): Standby: 0 Suspend: 0 Off: 0 DPMS is Enabled Monitor is On |
No comments:
Post a Comment