Posts

Showing posts with the label linux

C - print args without stdlibs

C - print args without stdlibs I just wrote a C program that prints its command line argument without using the standard library or a main() function. My motivation is simply curiosity and to understand how to play with inline assembly. I am using Ubuntu 17.10 x86_64 with the 4.13.0-39-generic kernel and GCC 7.2.0. main() Below is my code which I have tried to comment as much as I understood. The functions print , print_1 , my_exit , and _start() are required by the system to run the executable. Actually, without _start() the linker will emit a warning and the program will segfault. print print_1 my_exit _start() _start() Functions print and print_1 are different. The first one prints out a string to the console, measuring the length of the string internally. The second function needs the string length passed as an argument. The my_exit() function just exits the program, returning the required value, which in my case is the string length or the number of command line arguments. ...

how to remove spaces and double quotes and number ending dot using sed command [closed]

how to remove spaces and double quotes and number ending dot using sed command [closed] I need to remove space before and after the | symbol and number ending | before dot and string have double quotes. example : shyam|abhi"|ee d|453223.|shuyb should become : shyam|abhi|eed|453223|shuyb please suggest me how to do using sed linux command. Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. what did you try? what worked and what didn't work? – sathyz Jul 2 at 5:27 space remove is working using this command sed 's/[[:space:]]*|[[:space:]]*/|/g...

Expo/GenyMotion throws “ADB server didn't ACK” when running project

Image
Expo/GenyMotion throws “ADB server didn't ACK” when running project I'm trying to set up a React Native project using GenyMotion and Expo on Ubuntu. However, when I click the 'Device' button in Expo to package the app onto the emulator, I get the following error in the Expo console: I initially tried to use React Native through Android Studio, with the inbuilt Android emulator, so I thought the issue might that my computer hasmultiple ADB versions (when I ran $ adb --start-server from the terminal, it'd run the Android Studio binary, not the GenyMotion one). So I: $ adb --start-server Android/Sdk/ $ adb --start-server $ sudo apt-get remove adb android-tools-adb Set the filepath for the Android SDK in GenyMotion to my GenyMotion Android SDK. But I'm guessing is the same as the default setting, so I don't know if I needed to do this? Removed all path variables related to Android Studio from my .bashrc file, including $ANDROID_HOME . (should I instead set $AN...

A minimum of a 3 Node Galera Cluster is Recommended, but is it better to have 5 nodes?

A minimum of a 3 Node Galera Cluster is Recommended, but is it better to have 5 nodes? Right now I have a 400GB database, with a 5 node Galera Cluster. They are all RAID 10 SSDs. I've read the following: If the node goes missing due to a network problem or otherwise leaves without telling the rest of the cluster, then problems can arise. For the cluster to function, it needs a quorum, a majority of nodes active in the cluster. The two other nodes will continue to function normally since their partition has more than half of the known nodes but the node that left will stop accepting queries when it realizes that it is no longer in contact with the active partition. In this case, assuming an application can access the two active nodes, the failure can go mostly unnoticed. I am trying to reduce my cost and make things more optimal. My cluster is handling a few thousand queries per minute. Is it safe to have a 3 node cluster? What happens if 1 or 2 of the nodes go down,...

Pixelbook CromeOS Secured Shell App sftp mount fails

Pixelbook CromeOS Secured Shell App sftp mount fails My new Pixelbook i7 arrived and I was trying to install Android Studio. I followed the steps on this page: https://developer.android.com/topic/arc/studio I got to step 6 under "Mount Linux file". On step 5 I replaced the hostname with the IP address, clicked SFTP Mount and got the following. (I replaced part of the IP address with **). Welcome to Secure Shell App version 0.8.43. Answers to Frequently Asked Questions: ... (ctrl+click on links to open) [Pro Tip] Use 'Open as Window' or 'Fullscreen' to prevent Ctrl-W from closing your terminal! [Pro Tip] See .... for more information. ChangeLog/release notes: ... Random Pro Tip #6: Color your output/prompt using basic 16 colors & 256 colors & full 24-bit colors: http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Connecting to cfan@100.***.**.198... Loading NaCl plugin... done. ssh: connect to host 100.***.**.198 port 22: Connection refused failed! :( Wh...

Execute several command in linux shell file [closed]

Execute several command in linux shell file [closed] I only can get the desire output when I run the command one by one. How can I combine all the command in a shell script and get the desired output? //insert timestamp column $ vmstat -n 5 | (while read; do echo "$(date +%Y-%m-%d.%H:%M:%S) $REPLY"; done)> vm.txt //remove 1st & 2nd row $ sed '1,2d' vm.txt > vm2.txt //convert text file to csv $ sed 's/^ *//;s/ */,/g' vm2.txt > vm2.csv //insert column name $ echo $'datetime, r, b, swpd, free, buff, cache, si, so, bi, bo, in, cs, us, sy, id, wa, st' | cat - vm2.csv> chart.csv $ psql -p 5432 -U postgres -c "copy vmstat FROM '/root/report/chart.csv' delimiter '|' csv header" Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. ...

“Unable to find remote helper for 'https'” during git clone

“Unable to find remote helper for 'https'” during git clone I am unable to clone HTTPS repositories. I can clone SSH repos fine, but not HTTPS repos. I cannot test the GIT protocol since I am behind a corporate firewall. This is what I am trying to do: $ git clone https://github.com/nvie/gitflow.git Cloning into gitflow... fatal: Unable to find remote helper for 'https' I have so far tried the following (based on Google searches) apt-get build-deps apt-get ./configure --prefix=/usr --with-curl --with-expat ./configure --prefix=/usr --with-curl=/usr/bin/curl I have tried everything I can find on the internet with no luck. Can anyone help me? Git version = 1.7.6.4 OS = Ubuntu 11.04 Sorry to be obvious, it sounds like curl isn't installed. do curl --help and see if it is. – mike jones Nov 30 '11 at 19:09 ...

Debian Linux: Nouveau blocking cpu core [closed]

Debian Linux: Nouveau blocking cpu core [closed] I had simillar problems months ago, related to graphic driver nvidia. I just blacklisted nvidia driver, generate new Xorg configuration, install required packages, reboot, and it worked okay with nouveau. However, now I have some problem which I can't solve for few days. -When nouveau module is enabled, I am getting following errors Pcieport: pcie bus error Nouveau bus MIO read fault Rcu_sched self detected stall on Cpu Watchdog bug soft lockup cpu -When intel module is enabled (even if I have installed firmware-misc-nonfree) Firmware: Failed to load i915/skl_dmc_ver1_27 UPDATE Accidentially, I removed some gnome-related packages, so I installed them and I solve blue-screen problem. However, I still have those errors related to graphics. I can't use nouveau driver, it keeps on blocking my pc and using 100% of one cpu thread, and does not show login screen. When I blacklist it, I am able to use the pc, it only shows Firmware: Fail...

How to run nmap on python 3.6.4 on Kali Linux? [closed]

How to run nmap on python 3.6.4 on Kali Linux? [closed] I am currently attempting to use nmap on Python 3 and have used pip install through the Kali Linux terminal from PyPi packages and also have used apt-get install nmap and when I attempt to import nmap into the Python script or from the terminal, it tells me there is no module found. I know that it works for Python 2, but I'm wondering how to access it using Python 3? This question appears to be off-topic. The users who voted to close gave this specific reason: Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. Also see Why is Kali Linux so hard to set up? Why won't people help me? on Unix & Linux Stack Exchange and Should I Use Kali Linux? in the Kali docs. – jww Jul 2 at 3:13 ...

jq array of hashes to csv

jq array of hashes to csv So I have a data source like this: { "things": [ { "thing_name": "Bestco", "thing_id": 1 }, { "thing_name": "GreatCo", "thing_id": 2 }, { "thing_name": "DressCo", "thing_id": 3 } ] } I want to get output like this: $ echo '{"things":[{"thing_name":"Bestco","thing_id":1},{"thing_name":"GreatCo","thing_id":2},{"thing_name":"DressCo","thing_id":3}]}' | jq -r '.things | map(.thing_name, .thing_id, "n") | @csv' | sed -e 's/,"$//g' -e 's/^",//g' -e 's/^"$//g' "Bestco",1 "GreatCo",2 "DressCo",3 $ Using a fake parameter seems like a hack and then needs to be clean up by sed to work. How do I do this with just jq...

Wildfly admin console cannot be open on Linux

Wildfly admin console cannot be open on Linux I installed wildfly 13 Final, edited standalone.xml , added users but I still can't open the admin console on Ubuntu 16. I try to get an access to the console remotely. I can connect from the local machine, though sudo curl -i http://localhost:9990/console/index.html HTTP/1.1 200 OK Connection: keep-alive Last-Modified: Thu, 31 May 2018 02:30:23 GMT X-Frame-Options: SAMEORIGIN Content-Length: 1241 Content-Type: text/html Accept-Ranges: bytes Date: Sun, 01 Jul 2018 20:51:16 GMT config - /etc/default/wildfly ################################################# # General configuration for the init.d scripts, # # not necessarily for WildFly itself. # # default location: /etc/default/wildfly # ################################################# ## Location of JDK JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre" ## Location of WildFly JBOSS_HOME="/opt/wildfly" ## The username who should own the process. JB...

OpenGL Application makes Xorg leaks

OpenGL Application makes Xorg leaks I am working on a rather big Qt5/OpenGL application. Each time the application run and exit on a linux with nvidia driver, with a compositor active , nvidia-smi shows an increase of 4Mb of VRAM usage for Xorg process. My suposition would be that even if my application leaks, everything should be released when it is destroyed, but it does not seems to be the case. On this thread OpenGL GPU Memory cleanup, required?, Someone mentionned that it would not be the case if "Display list" are shared. I do not know much about OpenGL, and could not find coherent informations about this issue on the web. My objective is to understand how this could happen, where it may come from in my code and how to fix it. Note : The leaks are present in Xorg after my Aplication is stopped and no other process then Xorg and Desktop Environnement related are shown in nvidia-smi The DE I use does not matter (tested : KDE, Lxde, OpenBox, Gnome, Unity). The Linux Distri...

How can I find all syscalls that have to be whitelisted for seccomp?

How can I find all syscalls that have to be whitelisted for seccomp? I have an existing program that I would like to sandbox using seccomp (v2). How can I find what seccomp rules I need to allow for the program? I've tried adding seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(…), 0) for all syscalls printed by strace -xfc a.out , but apparently that wasn't enough, since I'm still getting "SIGSYS, Bad system call" when I run the program with seccomp. seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(…), 0) strace -xfc a.out 1 Answer 1 Probably the most reliable way is to switch your seccomp filter to return SECCOMP_RET_TRAP ("send catchable SIGSYS on error") rather than SECCOMP_RET_KILL ("kill the process with an uncatchable SIGSYS "), then print the siginfo_t from the signal handler, then commit suicide. SECCOMP_RET_TRAP SIGSYS SECCOMP_RET_KILL SIGSYS sigi...

Serial port hangs on close()

Serial port hangs on close() I developed this simple kernel module, which emulates a serial port by using a FIFO queue and a timer (read from hardware : out from the queue, write to hardware : insert in the queue). Source code is shown next. #include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/tty.h> #include <linux/tty_flip.h> #include <linux/serial.h> #include <linux/serial_core.h> #include <linux/module.h> #define TINY_SERIAL_DEBUG #define pr_fmt(fmt) "tiny_serial: " fmt #if defined(TINY_SERIAL_DEBUG) #define DBG(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) #else #define DBG(fmt, ...) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif #define DRIVER_AUTHOR "Me Me <me@me.com>" #define DRIVER_DESC "Tiny serial driver" /* Module information */ MODULE_AUTHOR( DRIVER_AUTHOR ); ...