Alias doesn't work inside watch command [duplicate] Posted: 29 Jun 2021 10:59 AM PDT I have such an alias for ls command: alias l='ls -CF' And I'm trying to watch the directory with watch command, but futile. When I do watch -d -n1 'l /dev/tty*' it shows: Every 1.0s: l /dev/tty* sh: 1: l: not found And when I do watch -d -n1 l /dev/tty* the result is: Every 1.0s: l /dev/tty /dev/tty0 /dev/tty1 /dev/tty10 /dev/tty11 /dev/tty12 /dev/tty13 /dev/tty14 /dev/tty15 /dev/tty16 /dev/tty17 /dev/tty18 /dev/tty19 /dev/tty2 /dev/tty... sh: 1: l: not found It looks a bit strange. What is the reason for such behavior? |
How to make a command global/static? Posted: 29 Jun 2021 10:32 AM PDT When using commands such as cat, they don't require for a path to be executed. How can this be done in Linux? |
Synchronising directories, but with a transformation Posted: 29 Jun 2021 10:05 AM PDT I often run into a situation where I have two directories, A, and B, and for every file in A, there should be a corresponding file in B that was generated by performing some sort of transformation on the file in A. Also, if there's a file in B that doesn't have a corresponding source file in A (perhaps it was deleted), it should warn me. Here are some examples where I want to do this: - running pandoc on markdown files to create HTML files
- maintaining a set of encrypted versions of files
In the past I've done this using gnu make . (Generate the list of transformed files as a variable, define rules to build any missing/outdated files, and run a script to warn about target files that don't have a source. Or I write a makefile that writes a makefile and then runs that.) Before I hack another makefile, I have to ask: Is there a Linux utility that "synchronises" two directories, but instead of just copying files, it executes some command on them? Perhaps there's an alternative to make that is better suited to this task? |
How to gracefully kill (like normal close) Google Chrome (over SSH)? Posted: 29 Jun 2021 09:28 AM PDT I am running a "TV laptop" - just a low-powered laptop connected to a TV with one single purpose, to run a live TV stream from Google Chrome on Ubuntu MATE 20.04.2 LTS. The first thing I noticed when rebooting this machine with just reboot over ssh , was that: "Chrome didn't shut down correctly." which is an exact transcript of the bubble message. Is there a way to avoid it? |
Combine physical drives and lose minimal files in case of failure Posted: 29 Jun 2021 09:12 AM PDT I need to store large files on a lot HDDs. I don't care losing data but I want to lose as few files as possible if/when a drive fails. As far as I understand, it's not possible to setup drives in raid 0 without stripping, or logical drives in LVM while chosing never to split files. What would be the easiest way to setup that group of HDD in order to maximize utilization of space while minimizing the amount of large files lost if a drive fails? |
the whole root file system went read-only Posted: 29 Jun 2021 10:50 AM PDT This problem first appeared when I was downloading a huge data archive(about 500GB) but I didn't keep the output and logs at the time. I rebooted the system and it entered emergency mode automatically. I used fsck and solved this but a few hours later it happened again. This time I found that the whole root fs is read-only even /tmp(someone asked me to try this). This is the last output of dmesg: [35761.273361] ata4.00: exception Emask 0x0 SAct 0x1800 SErr 0x0 action 0x0 [35761.273373] ata4.00: irq_stat 0x40000008 [35761.273379] ata4.00: failed command: READ FPDMA QUEUED [35761.273386] ata4.00: cmd 60/00:58:c0:31:a1/02:00:38:00:00/40 tag 11 ncq dma 262144 in res 41/40:00:f3:31:a1/00:00:38:00:00/40 Emask 0x409 (media error) <F> [35761.273394] ata4.00: status: { DRDY ERR } [35761.273398] ata4.00: error: { UNC } [35761.276060] ata4.00: configured for UDMA/133 [35761.276077] sd 3:0:0:0: [sdb] tag#11 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [35761.276083] sd 3:0:0:0: [sdb] tag#11 Sense Key : Medium Error [current] [35761.276089] sd 3:0:0:0: [sdb] tag#11 Add. Sense: Unrecovered read error - auto reallocate failed [35761.276095] sd 3:0:0:0: [sdb] tag#11 CDB: Read(16) 88 00 00 00 00 00 38 a1 31 c0 00 00 02 00 00 00 [35761.276101] print_req_error: I/O error, dev sdb, sector 950088179 [35761.276117] ata4: EH complete [38523.236782] ata4.00: exception Emask 0x0 SAct 0x18080 SErr 0x0 action 0x0 [38523.236793] ata4.00: irq_stat 0x40000001 [38523.236797] ata4.00: failed command: READ FPDMA QUEUED [38523.236802] ata4.00: cmd 60/08:38:f0:31:a1/00:00:38:00:00/40 tag 7 ncq dma 4096 in res 41/40:00:f3:31:a1/00:00:38:00:00/40 Emask 0x409 (media error) <F> [38523.236807] ata4.00: status: { DRDY ERR } [38523.236810] ata4.00: error: { UNC } [38523.236813] ata4.00: failed command: WRITE FPDMA QUEUED [38523.236821] ata4.00: cmd 61/40:78:80:b9:81/09:00:30:00:00/40 tag 15 ncq dma 1212416 ou res 41/40:00:00:00:00/00:00:00:00:00/00 Emask 0x9 (media error) [38523.236825] ata4.00: status: { DRDY ERR } [38523.236828] ata4.00: error: { UNC } [38523.236830] ata4.00: failed command: WRITE FPDMA QUEUED [38523.236834] ata4.00: cmd 61/70:80:e8:4d:9f/00:00:ea:00:00/40 tag 16 ncq dma 57344 out res 41/40:00:00:00:00/00:00:00:00:00/00 Emask 0x9 (media error) [38523.236838] ata4.00: status: { DRDY ERR } [38523.236840] ata4.00: error: { UNC } [38523.238584] ata4.00: configured for UDMA/133 [38523.238607] sd 3:0:0:0: [sdb] tag#7 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [38523.238615] sd 3:0:0:0: [sdb] tag#7 Sense Key : Medium Error [current] [38523.238622] sd 3:0:0:0: [sdb] tag#7 Add. Sense: Unrecovered read error - auto reallocate failed [38523.238628] sd 3:0:0:0: [sdb] tag#7 CDB: Read(16) 88 00 00 00 00 00 38 a1 31 f0 00 00 00 08 00 00 [38523.238634] print_req_error: I/O error, dev sdb, sector 950088179 [38523.238659] sd 3:0:0:0: [sdb] tag#15 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [38523.238664] sd 3:0:0:0: [sdb] tag#15 Sense Key : Medium Error [current] [38523.238668] sd 3:0:0:0: [sdb] tag#15 Add. Sense: Unrecovered read error - auto reallocate failed [38523.238674] sd 3:0:0:0: [sdb] tag#15 CDB: Write(16) 8a 00 00 00 00 00 30 81 b9 80 00 00 09 40 00 00 [38523.238679] print_req_error: I/O error, dev sdb, sector 813808000 [38523.238687] EXT4-fs warning (device sdb3): ext4_end_bio:323: I/O error 10 writing to inode 56511830 (offset 26411008 size 1212416 starting block 101726296) [38523.238694] Buffer I/O error on device sdb3, logical block 93788464 [38523.238704] Buffer I/O error on device sdb3, logical block 93788465 [38523.238708] Buffer I/O error on device sdb3, logical block 93788466 [38523.238713] Buffer I/O error on device sdb3, logical block 93788467 [38523.238717] Buffer I/O error on device sdb3, logical block 93788468 [38523.238722] Buffer I/O error on device sdb3, logical block 93788469 [38523.238728] Buffer I/O error on device sdb3, logical block 93788470 [38523.238733] Buffer I/O error on device sdb3, logical block 93788471 [38523.238738] Buffer I/O error on device sdb3, logical block 93788472 [38523.238747] Buffer I/O error on device sdb3, logical block 93788473 [38523.238982] JBD2: Detected IO errors while flushing file data on sdb3-8 [38523.238984] sd 3:0:0:0: [sdb] tag#16 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [38523.238995] sd 3:0:0:0: [sdb] tag#16 Sense Key : Medium Error [current] [38523.238999] sd 3:0:0:0: [sdb] tag#16 Add. Sense: Unrecovered read error - auto reallocate failed [38523.239005] sd 3:0:0:0: [sdb] tag#16 CDB: Write(16) 8a 00 00 00 00 00 ea 9f 4d e8 00 00 00 70 00 00 [38523.239010] print_req_error: I/O error, dev sdb, sector 3936308712 [38523.239026] ata4: EH complete [38523.239032] Aborting journal on device sdb3-8. [38523.239045] EXT4-fs (sdb3): Delayed block allocation failed for inode 56511830 at logical offset 6748 with max blocks 120 with error 30 [38523.239055] EXT4-fs (sdb3): This should not happen!! Data will be lost [38523.239643] EXT4-fs error (device sdb3) in ext4_writepages:2906: IO failure [38523.296445] EXT4-fs (sdb3): Remounting filesystem read-only [38523.296477] EXT4-fs error (device sdb3): ext4_journal_check_start:61: Detected aborted journal [38525.832744] ata4.00: exception Emask 0x0 SAct 0x30 SErr 0x0 action 0x0 [38525.833100] ata4.00: irq_stat 0x40000008 [38525.833365] ata4.00: failed command: READ FPDMA QUEUED [38525.833629] ata4.00: cmd 60/80:20:c0:3b:a1/00:00:38:00:00/40 tag 4 ncq dma 65536 in res 41/40:00:e7:3b:a1/00:00:38:00:00/40 Emask 0x409 (media error) <F> [38525.834152] ata4.00: status: { DRDY ERR } [38525.834415] ata4.00: error: { UNC } [38525.836456] ata4.00: configured for UDMA/133 [38525.836737] sd 3:0:0:0: [sdb] tag#4 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [38525.837001] sd 3:0:0:0: [sdb] tag#4 Sense Key : Medium Error [current] [38525.837267] sd 3:0:0:0: [sdb] tag#4 Add. Sense: Unrecovered read error - auto reallocate failed [38525.837531] sd 3:0:0:0: [sdb] tag#4 CDB: Read(16) 88 00 00 00 00 00 38 a1 3b c0 00 00 00 80 00 00 [38525.837796] print_req_error: I/O error, dev sdb, sector 950090727 [38525.838072] ata4: EH complete [38528.260746] ata4.00: exception Emask 0x0 SAct 0x400 SErr 0x0 action 0x0 [38528.261092] ata4.00: irq_stat 0x40000008 [38528.261357] ata4.00: failed command: READ FPDMA QUEUED [38528.261623] ata4.00: cmd 60/08:50:e0:3b:a1/00:00:38:00:00/40 tag 10 ncq dma 4096 in res 41/40:00:e7:3b:a1/00:00:38:00:00/40 Emask 0x409 (media error) <F> [38528.262144] ata4.00: status: { DRDY ERR } [38528.262405] ata4.00: error: { UNC } [38528.264870] ata4.00: configured for UDMA/133 [38528.265149] sd 3:0:0:0: [sdb] tag#10 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [38528.265410] sd 3:0:0:0: [sdb] tag#10 Sense Key : Medium Error [current] [38528.265668] sd 3:0:0:0: [sdb] tag#10 Add. Sense: Unrecovered read error - auto reallocate failed [38528.265923] sd 3:0:0:0: [sdb] tag#10 CDB: Read(16) 88 00 00 00 00 00 38 a1 3b e0 00 00 00 08 00 00 [38528.266182] print_req_error: I/O error, dev sdb, sector 950090727 [38528.266459] ata4: EH complete [54010.452717] EXT4-fs error (device sdb3): ext4_remount:5338: Abort forced by user [56341.190097] EXT4-fs error (device sdb3): ext4_remount:5338: Abort forced by user [56572.048951] EXT4-fs error (device sdb3): ext4_remount:5338: Abort forced by user [56633.963486] EXT4-fs error (device sdb3): ext4_remount:5338: Abort forced by user After that no more messages has been logged because the entire rootfs has become read-only. Then I tried: # mount / -o remount,rw mount: /: cannot remount /dev/sdb3 read-write, is write-protected. It failed but fortunately there's no problem with partitions on other HDDs so I can upload a locally built smartctl to server and see the smart info: # /other/smartmontools-7.2/smartctl -a /dev/sdb smartctl 7.2 2020-12-30 r5155 [x86_64-linux-4.19.0-14-amd64] (local build) Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Western Digital Gold Device Model: WDC WD4002FYYZ-01B7CB0 Serial Number: WD-N8G6724Y LU WWN Device Id: 5 0014ee 25f546502 Firmware Version: 01.01K03 User Capacity: 4,000,787,030,016 bytes [4.00 TB] Sector Size: 512 bytes logical/physical Rotation Rate: 7200 rpm Device is: In smartctl database [for details use: -P show] ATA Version is: ATA8-ACS (minor revision not indicated) SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Tue Jun 29 23:11:25 2021 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x82) Offline data collection activity was completed without error. Auto Offline Data Collection: Enabled. Self-test execution status: ( 121) The previous self-test completed having the read element of the test failed. Total time to complete Offline data collection: (49440) seconds. Offline data collection capabilities: (0x7b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. Conveyance Self-test supported. Selective Self-test supported. SMART capabilities: (0x0003) Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01) Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 533) minutes. Conveyance self-test routine recommended polling time: ( 5) minutes. SCT capabilities: (0x70bd) SCT Status supported. SCT Error Recovery Control supported. SCT Feature Control supported. SCT Data Table supported. SMART Attributes Data Structure revision number: 16 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x002f 198 197 051 Pre-fail Always - 14 3 Spin_Up_Time 0x0027 175 149 021 Pre-fail Always - 10208 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 29 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0 9 Power_On_Hours 0x0032 079 079 000 Old_age Always - 15352 10 Spin_Retry_Count 0x0032 100 253 000 Old_age Always - 0 11 Calibration_Retry_Count 0x0032 100 253 000 Old_age Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 29 183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0 192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 9 193 Load_Cycle_Count 0x0032 200 200 000 Old_age Always - 19 194 Temperature_Celsius 0x0022 109 098 000 Old_age Always - 43 196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 10 198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 6 199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0 200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 8 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed: read failure 90% 15351 788280736 # 2 Short offline Completed: read failure 90% 15327 788280736 # 3 Short offline Completed without error 00% 97 - # 4 Extended offline Aborted by host 90% 34 - SMART Selective self-test log data structure revision number 1 SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 1 0 0 Not_testing 2 0 0 Not_testing 3 0 0 Not_testing 4 0 0 Not_testing 5 0 0 Not_testing Selective self-test flags (0x0): After scanning selected spans, do NOT read-scan remainder of disk. If Selective self-test is pending on power-up, resume after 0 minute delay. I'm not completely sure that this is the problem with HDD because I can't understand these informations well - my native language isn't English and please forgive me for the bad wording :/ |
Touchpad cursor jumps/skips on Lenovo Ideapad Gaming laptop Posted: 29 Jun 2021 09:00 AM PDT I have recently bought a new Lenovo Ideapad Gaming laptop. On my old Lenovo laptop, when I move my finger against the touchpad, the cursor will move smoothly, a few pixels each time. But on the new laptop, the cursor will skip hundreds of pixels each time. It's like if it updated with 5 FPS. The touchpad also don't feel responsive at all. It's very hard and painful to position cursor when it jumps that way. The direction of movement seems correct, as well as distance. OS is Ubuntu 20.4. I have tried mtrack and synaptics drivers in addition to normal libinput, they make matters worse: mtrack is more jumpy and synaptics will not even respond to some touches (I understand it's no longer supported). I have fiddled with some of mtrack settings with no apparent effect. The device is reported as MSFT0001:00 06CB:CE2D Touchpad . Googling reveals a lot of posts about Legion 5 touchpad not working, which is not relevant since it sort of works in my case. Update: When I boot into UEFI, the touchpad works flawlessly there. |
Is the /opt directory empty by default in macOS Big Sur 11.4? Posted: 29 Jun 2021 07:52 AM PDT I am currently on macOS Big Sur 11.4, and I have noticed that my /opt directory is empty. I opened the Terminal application and typed cd /opt . I then typed ls , but it did not show any files or directories. This left me wonder whether the /opt directory is supposed to have certain directories and/or files or is supposed to be empty. |
remove all files and folders not listed in file Posted: 29 Jun 2021 08:44 AM PDT I am looking into a way of deleting all files and folders recursively in the current working directory that are not listed in files2keep.txt . I am using Linux. The text file can be quite large, up to several GB in size with multi-million rows. Files in the text file are relative to the current working directory, for example: Dummy_Path_001/00110-003/VET_Visit2/VET/PTCT-PET_AC_FOOT-604/1/2021-06-22T18-45-00.766Z Dummy_Path_001/00110-003/VET_Visit2/VET/PTCT-PET_AC_FOOT-607/1/2021-06-22T18-44-55.904Z Dummy_Path_001/00110-003/VET_Visit2/VET/PTCT-PET_AC_FOOT-610/1/2021-06-22T18-44-57.682Z Using rsync is one of the options, but would lead to some initial data duplication and probably disk space issues. There will be no whitespace in the file names or paths. All ideas are welcome |
Trying out Maas on a Raspberry Pi? Posted: 29 Jun 2021 11:05 AM PDT I would like to kick the tires with Maas - https://maas.io/ - and tried out https://snapcraft.io/install/maas/raspbian with a 3B I had lying around with a recent version of Raspbian. (I don't have a spare PC I can dedicate to this at the moment). Unfortunately it appears that there is no armhf snap of Maas so the instructions fail. It appears that this might be a leftover from before the conversion to snaps, so it might still be possible to try out an older version of Maas on my Raspberry. I am fine with only being able to test out 16.04 or 18.04 on my test client, as the thing I want to see is if we can use this with a 32-bit 386 embedded system too until we can replace them. How should I approach this? (I've asked the question at AskUbuntu but they considered it off-topic and sent me here) |
Is that OK or Better to use oflag=direct and conv=fsync together in dd? Posted: 29 Jun 2021 10:48 AM PDT Is that OK or Better to use oflag=direct and conv=fsync together in dd? What I understand (might not be 100% correct): conv=fsync will be executed only once at the end of dd call. But I don't want the sync happen in the end. I want the data is written to the storage directly as soon as possible. There are another two options oflag=direct and oflag=sync . I don't like oflag=sync , because (1) it's extremely slow when I test with bs=4096 . (2) it still uses memory cache but I think that is no need. So I will use oflag=direct instead. oflag=direct bypass the kernel's page cache (memory cache), writing directly to the storage. But the storage may itself store the data in a write-back (hdd) cache, so conv=fsync will still be required in order to write hdd cache to the actual storage. Thus, it's better to use the two arguments together. something like: dd if=/dev/zero of=/dev/sdX bs=4096 status=progress oflag=direct conv=fsync |
Setting variable in awk Posted: 29 Jun 2021 09:15 AM PDT I want to set a variable in awk that in composed of appending three strings containing the filename. The command is supposed to print lines between numbers a and b . find "$dir" \( -name \*.org -o -name \*.texi \) \ -exec awk -v a="$na" -v b="$nb" \ -v red="$(tput setaf 1)" \ -v nrm="$(tput sgr0)" \ -v rd="\033[1;31m" \ -v nr="\033[0m" \ 's = "==>" FILENAME "<==" FNR == 1 {f = 0} FNR == a {print red, s, nrm; f = 1} f {print; if (FNR == b) nextfile}' {} + |
Kill all sleeping processes in linux Posted: 29 Jun 2021 08:11 AM PDT How to kill all processes in sleeping state in linux? Will the command below work? killall sleep How to find list of all processes linux? ps -aux . Is this correct? |
How to fix Archlinux not recognizing headset michrophone via headphone jack? Posted: 29 Jun 2021 09:42 AM PDT My audio card: HDA Intel PCH My chipset: Realtek ALC887-VD What I've tried: Installing Alsa and Pulseaudio audio drivers. Experimenting with the audio drivers. Looking at several forums (nothing has worked so far). I've used two different headsets, one Beats and another one I don't know the name of. Regardless, none worked. \ |
How to changes colors for files that their group owner is `root`? Posted: 29 Jun 2021 09:29 AM PDT I have tried How to change the color of different files in ls's solution to apply color changes in ls . I have observed that they do not apply in folders that has a root group owner? For example a .json file differs in color in a root folder and a user's home folder. ~/folder/ > ls -l -rw-rw-r-- 1 alper alper alper 0 2021-06-16 06:35 hello.json ~/mnt/ > ls -l -rwxrwxrwx 1 alper root alper 0 2021-06-16 06:38 alper.json Related question: https://superuser.com/q/1598934/723632, which has a solution only for folders. |
Script function call: function vs $(function) Posted: 29 Jun 2021 08:39 AM PDT Taking how reference the following code for simplicity #!/bin/bash number=7 function doSomething() { number=8 } doSomething echo "$number" It prints 8 . But with: #!/bin/bash number=7 function doSomething() { number=8 } $(doSomething) echo "$number" It prints 7 . I have the following questions: - What are the technical names for each one?, I mean
functioncall and $(functioncall) - How does work each approach? It seems the former considers (affects) the variables outside of the function itself, the latter not
- When is mandatory use one approach over the other (it mostly about performance issues - of course - if there is any), if there are other reasons, they are welcome.
|
Bluetooth HSP/HFP and A2DP Problem: Switching between profiles not working Posted: 29 Jun 2021 09:37 AM PDT I recently bought new Bluetooth headphones (Jabra 75t) and have connectivity problems with my Lenovo x240 (Linux Mint 20). When I first connected the headphones, they connect in HSP/HFP mode, now when I manually switch to A2DP they immediately lose Bluetooth connection. When reconnecting everything, they reconnect in HSP/HFP and the audio quality is obviously quite bad. Now I stumbled around and found when editing /etc/pulse/default.pa .ifexists module-bluetooth-policy.so load-module module-bluetooth-policy .endif .ifexists module-bluetooth-discover.so load-module module-bluetooth-discover .endif to .ifexists module-bluetooth-policy.so load-module module-bluetooth-policy ag=true .endif .ifexists module-bluetooth-discover.so load-module module-bluetooth-discover headset=ofono autodetect_mtu=yes .endif I do now have A2DP, but cannot use my Microphone any more, as the HSP/HFP profile is unavailable in PulseAudio. The Audio quality is quite great but I can only use the internal laptop microphone for voice calls. Now ideally, I would like to have both good audio quality (A2DP) and use my microphone (HSP/HFP) but it seems like I have to edit /etc/pulse/default.pa to be able to switch between those two profiles. Does anyone know any workaround or solutions? I'd be grateful for any advice or hint! If you need any further information, let me know! |
Set up Debian networking bridge with DHCP Posted: 29 Jun 2021 08:03 AM PDT After a recent bout of package upgrades (but still within the stretch release) my bridge networking to support libvirt VMs seems to have died - the DHCP server does not send an IP to the host nor does the host have any network connectivity. Previously my /etc/network/interfaces file worked great (as has been recommended in the the Debian wiki): iface eth0 inet manual auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0 Alas, when I try to bring it up using ifup br0 or systemctl restart networking I get very unhelpful log messages like ifup: failed to bring up eth0 . Most strangely, if I set a static IP on the br0 interface everything works great, but I'd like to configure my static IPs in the router rather than the host OS. This is the workaround static IP configuration, closely modeled after the libvirt networking guide. iface eth0 inet manual auto br0 iface br0 inet static bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0 hwaddress ether e0:3f:49:eb:7f:35 address 192.168.1.140 gateway 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0 Also, if I remove the bridge entirely and just configure eth0 to directly use dhcp the host will receive an address from the router. Any thoughts on what I can do to further troubleshoot or fix the issue? Thanks! |
Ubuntu, No Wifi Adapter Posted: 29 Jun 2021 09:08 AM PDT I have installed Ubuntu 18.04.3 as a persistent storage, live USB version on an old Seagate external drive. I'm getting a "No Wifi Adapter Found" error in the Wifi settings once I boot into this Ubuntu Drive. My network adapter readout from 'lspci' is 00:14.3 Network controller: Intel Corporation Wireless-AC 9560 [Jefferson Peak] (rev 10) I dowloaded the corresponding linux supported drivers and copied it to /lib/firmware folder. After restarting my computer I still get the same error message. I double checked the /lib/firmware folder for the .ucode file and it was still there. Any help is greatly appreciated. |
jq: globbing possible? [duplicate] Posted: 29 Jun 2021 10:13 AM PDT I have the following json output: { x0: { scores: { small, human readable }, payload: { huge data } } { x1: ... } { x2: ... } ... { xn: ... } What I would like to do is, when I finish generating this report, tee it into a file and jq like so, in pseudo code: {json content} | tee out.json | jq '.*.scores' How does one glob like this with jq? |
How to format HDD which is using raid? Posted: 29 Jun 2021 10:24 AM PDT I have a laptop that has RAID installed on it, and I have two devices sda and sdb for my storage unit and it's a RAID, I want to completely format both the discs. I have come up with the following command to format both discs. dd if=/dev/zero of=/dev/sda bs=1M dd if=/dev/zero of=/dev/sdb bs=1M Are these commands sufficient enough to format both discs or not? |
Running a different configuration.nix file into a virtual machine from a non-nixos operating system Posted: 29 Jun 2021 09:32 AM PDT In the amazing nixos, it is possible to launch a lightweight container that will run a system whose configuration.nix file is different from the host configuration by first compiling using: $ nixos-rebuild build-vm -I nixos-config=./configuration.nix and running via: $ ./result/bin/run-*-vm However, the first command cannot work on operating systems where nixos is not installed, like debian + nixpkgs, because nixos-rebuild does not exists. How can I still use build-vm in non-nixos systems? |
dd command oflag direct and sync flags Posted: 29 Jun 2021 11:06 AM PDT I have the below shell script and I wonder whether oflag's direct does the syncing automatically or if it is explicitly required: dd bs=10M oflag=direct,sync of=ofile.bin Also what is the difference in saying oflag=sync and conv=sync and conv=fsync? What impact does it have if I change the code to the line below? dd bs=10M conv=fsync oflag=direct of=ofile.bin |
How can I change directories and set bash options when logging onto to a remote server via ssh Posted: 29 Jun 2021 07:53 AM PDT I regularly have to log onto remote hosts via SSH and I like to use the bash option set -o vi and I normally have to cd to a specific directory. Since these hosts are ephemeral (they are created and destroyed regularly) I can't log onto them and save these in a .bash_profile /.bashrc . So I was looking into how I can do this when I connect via SSH so I don't have to type the same commands each time I connect to a remote server. I've tried several ways to achieve this but none of them seem to work. Can someone help me get this command right? In a nutshell this is what I want to do. cd to a specific directory - set the bash option
set -o vi Here's how I've tried to do it: ssh root@remotehost.com -t "cd /data; exec bash --login -c \"set -o vi\"" I feel that this actually works but that the SSH session terminates because once the command set -o vi is executed the session disconnects with a message like: Shared connection to remotehost.com closed. Is there a way to keep the session open after executing these commands or is there another way to achieve what I want? |
OverlayFS over read only rootfs fail Posted: 29 Jun 2021 08:37 AM PDT I need to keep one system as much intact as possible. Only soldering of HW stuff is allowed :-). I need to install a test software package and this package must not stay there in the future. I have a following situation: - mmcblck partition mounted as /, ext4, read only, kernel v4.6.0
- usb stick (only one partition), mounted to /tmp/usbstick, ext4
- Created directories on usbstick /tmp/usbstick/upperdir, /tmp/usbstick/workdir
- Using the following line: mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/usbstick/upperdir,workdir=/tmp/usbstick/workdir /
After that the / is still read only. The only partial success I had was when I created /tmp/usbstick/merged and gave it as a "merged" directory, instead of / to the module. Then I saw all my rootfs in that directory and it was rw mounted, but I can't use it there. What should I do? |
How to set a systemd unit to start after loading the desktop? Posted: 29 Jun 2021 08:20 AM PDT I created systemd unit for x0vncserver like this [Unit] Description=Remote desktop service (VNC) After=graphical.target [Service] Type=forking User=user ExecStart=/usr/bin/sh -c '/usr/bin/x0vncserver -display :0 -rfbport 5900 -passwordfile /home/user/.vnc/passwd &' [Install] WantedBy=multi-user.target and enabled it to run but it fails. Then I realized as I am trying to load the original desktop using x0vncserver, I can only do that after loading the desktop itself completely. So I have to set the system unit to run after loading the desktop but how? Or any timed way to set it up? Though it may be possible by using desktop session tools but any systemd way solution? and my default.target is # systemctl get-default graphical.target |
snmptt running as non-root, writting to file as root Posted: 29 Jun 2021 11:05 AM PDT I'm running snmptt as a SNMP trap handler for snmptrapd , with the aim being to write to a trap file that can be read and processed by Zabbix. I have set up snmptt to run as the zabbix user by changing the init script. # grep daemon /etc/init.d/snmptt # description: SNMP Trap Translator daemon # Short-Description: SNMP Trap Translator daemon OPTIONS="--daemon" daemon --user=zabbix /usr/sbin/snmptt $OPTIONS snmpttt is running as expected as the zabbix user, the same user which is running the Zabbix server. # ps -ef | grep snmp root 3796 1 0 Jun19 ? 00:13:04 /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid zabbix 4444 1 0 15:00 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon zabbix 4445 4444 0 15:00 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon root 9300 29899 0 15:25 pts/2 00:00:00 grep snmp zabbix 16576 16511 0 Aug16 ? 00:00:11 /path/to/sbin/zabbix_server: snmp trapper [processed data in 0.000007 sec, idle 1 sec] root 16600 1 0 Aug16 ? 00:00:07 /usr/sbin/snmptrapd -A -Lf /var/log/snmptrapd.log -D -p /var/run/snmptrapd.pid The log file to send traps caught is /var/tmp/zabbixtest/zabbix_traps.tmp # egrep "^(log_file|pid)" /etc/snmp/snmptt.ini pid_file = /var/run/snmptt/snmptt.pid log_file=/var/tmp/zabbixtest/zabbix_traps.tmp However, the trap log file is being written to, and owned by the root user, not as the zabbix user as expected. Moreover, the permissions on the file are 0640 , meaning that the zabbix user running the server is not able to read the file. # service snmptt stop Stopping snmptt: [ OK ] # rm /var/tmp/zabbixtest/zabbix_traps.tmp rm: remove regular file `/var/tmp/zabbixtest/zabbix_traps.tmp'? y # ls -lia /var/tmp/zabbixtest/zabbix_traps.tmp ls: cannot access /var/tmp/zabbixtest/zabbix_traps.tmp: No such file or directory # ls -lia /var/tmp/zabbixtest/ total 24 263224 drwxrwxr-x 2 root zabbix 4096 Aug 17 15:32 . 262145 drwxrwxrwt 7 root root 4096 Aug 17 14:53 .. # service snmptt start Starting snmptt: PID file: /var/run/snmptt/snmptt.pid [ OK ] # ps -ef | grep snmptt zabbix 9944 1 0 15:32 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon zabbix 9945 9944 0 15:32 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon root 9981 29899 0 15:32 pts/2 00:00:00 grep snmptt # ps -ef | grep snmp root 3796 1 0 Jun19 ? 00:13:04 /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid zabbix 9944 1 0 15:32 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon zabbix 9945 9944 0 15:32 ? 00:00:00 /usr/bin/perl /usr/sbin/snmptt --daemon root 9986 29899 0 15:32 pts/2 00:00:00 grep snmp zabbix 16576 16511 0 Aug16 ? 00:00:11 /path/to/sbin/zabbix_server: snmp trapper [processed data in 0.000079 sec, idle 1 sec] root 16600 1 0 Aug16 ? 00:00:07 /usr/sbin/snmptrapd -A -Lf /var/log/snmptrapd.log -D -p /var/run/snmptrapd.pid # ls -lia /var/tmp/zabbixtest/zabbix_traps.tmp 262265 -rw-r----- 1 root root 122 Aug 17 15:32 /var/tmp/zabbixtest/zabbix_traps.tmp Note the file permissions and ownership of /var/tmp/zabbixtest/zabbix_traps.tmp . Accordingly, the zabbix user is unable to read the file and is hence unable to process it. I can fix by manually modifying the mode of the trap file /var/tmp/zabbixtest/zabbix_traps.tmp to 0644 , for example, but I am hoping there is a better way, e.g. via a configuration file, since the file location will most likely change. (There are some blog sites recommending to change the mode to 0777, obviously that is not the correct solution). I guess it is due to the snmptrapd configuration, running as root, but not sure the best way to fix this. My questions: Why is the trap log file being written to as the root user with 0640 permissions, instead of as zabbix user running snmptt ? How can/should I configure snmptt and/or snmptrapd to have the trap file be owned and readable by the zabbix user instead of root user. Other relevant info: snmptrapd config file: # grep -v '^#' /etc/snmp/snmptrapd.conf disableAuthorization yes traphandle default /usr/sbin/snmptthandler Running RHEL 6.6 |
getting output from netcat, decoding it and returning an output Posted: 29 Jun 2021 08:36 AM PDT I have to get an output from netcat, decode it and return it. after typing: nc cs2107.spro.ink 9000 the output i get is this: Welcome to the Proof of work challenge! Rules: i will provide hex encoded byte strings to you. Your task is to decode it and calculate the md5 hash in hex encoded format and return it back to me. You will need to do this 500 times! Ready? Go! cdde140fffda1da2bc3f MD5: So I have to get take in that hex encoded string, decode it and output it again and that's suppose to happen 500 times. I think I know what I have to do but I have no idea how to code it in unix. I think an .sh file is needed? But i'm not very sure. start with nc cs2107.spro.ink 9000 search for the hex string from the nc output decode it and calculate the md5 hash finally, send it back edit: i know i'm able to save the output of nc by doing so nc cs2107.spro.ink 9000 > somefile.txt how do i then search specifically for the hex string? how do i decode the hex string? and finally how to i return the result back into the terminal? edit2: so i'm allowed to use python to do this assignment. some hints were to either use the subprocess module or the sockets module. tried doing it with subprocess as i read that subprocess.Popen keeps the command running in the background i'm currently stuck with this import subprocess p = subprocess.Popen('nc cs2107.spro.ink 9000', shell = True, stdin = subprocess.PIPE, stdout = subprocess.PIPE) a = subprocess.Popen('grep ^[0-9a-f] | xxd -r | md5sum | awk "{print $1}" ', stdin = p.stdout, stdout = subprocess.PIPE) now i'm stuck trying to pipe a back into p |
What does a red-colored filename mean? Posted: 29 Jun 2021 10:36 AM PDT I have been exploring files in bash, and in /etc/ssl/certs, most of the filenames are light blue. There is a red filename though, and I can't figure out why it is red. Most of the files in this directory are .pem files. The red one is also a .pem file. It happens to be something like China_Internet_Network_Information_Center...pem According to this stack exchange question , light blue filenames mean linked files, while red file names mean "archived" files. What does that mean? Looking at the directory with ls -all , I still can't tell what makes the filename red. Can anyone explain why it is red? |
No comments:
Post a Comment