title: Setup ssh tunnelling to browse using the IP of a computer inside a private network

text: I think my question is much easier to understand looking at the draw below. The idea is that for some reasons (such like accessing the intranet of my company, or getting access to some web pages that only my company has access to) I want to browse the Internet using the IP of my company, but from home. The problem is that to get access to my PC "inside" I have to go through a gate. One solution could be of course to login into gate, and from there to my PC, with `ssh -X`. Once inside I can open a Firefox window that will pop up in my PC at home. The problem of this approach is that it is very slow because I have to send the whole GUI through the network, instead of just the Internet packages. A better idea to overcome this problem would be to use `ssh -D8080 ip.remote.company` to create a tunnel, and then setup Firefox in my PC at home to use the remote computer as proxy, sending the internet packages (but not the GUI) through this secure channel, such as explained in many web pages. The problem, of course, is that I have to go through the gate, which adds a level of complexity, so I have to setup (I think) two tunnels instead of just one, those drawn in red in the figure. How can I setup a port forwarding (or something similar) to tunnel my connection to Internet through the network of my company, as illustrated in the figure, from outside? Of course I have access and accounts in the three computers. ![setup](http://i.stack.imgur.com/MQpoP.png)


title: mysql access denied

text: Trying to find a way in by going through checklist of possible reasons I am locked out of mysql and one, I read, is to determine if I have grant tables.               -bash-4.1# cd /var     -bash-4.1# ls     cache  empty  lib    lock  mail  opt       run    tmp  yp     db     games  local  log   nis   preserve  spool  www     -bash-4.1# ls db     sudo      Apparently I am supposed to see a file named user.MYD in the db directory. I don't even remember if I created a db after reinstall but I see 'db' there so that must be it(?) Is there a way I can drop the database and recreate one without access in?


title: Alternative to su/sudo on barebone system

text: I'd like to run some unit tests in a barebone `chroot` jail on Solaris. **There's no`su` or `sudo`**, and a copy of `su` (with `libpam.so.1`) just returns exit code 1 without any output, with or without parameters. Is there some easy way to **run Bash scripts as a non-root user** on such a system? Maybe setuid or a wrapper script?


title: Encrypted Booting

text: I want to boot the Linux from the /boot partition, and also want to encrypt this /boot partition. [ AFAIK, Grub is unable to find the kernel and initrd from an truecrypted partition or cryptsetup encrypted boot partition. ] Is there any way to do so ?


title: Are there any Linux distros aimed specifically at being Linux tutorials?

text: Are there any Linux distributions that come pre-loaded with hands-on, guided tutorials or other learning software aimed at teaching a new user how to work with Linux? I'm aware that some distros are naturally easier for new users to pick up than others, but I'm particularly hoping there's one out there that directly _teaches_ the user. I've tried going the independent "learn by using" route with an Ubuntu VM, but would find it much more helpful and fitting to my personal learning and motivational mechanisms to have something that could guide me through the process. To be a bit more specific, I'm not just looking for a general "Linux for Beginners" tutorial (although that also would be a good start). I'm hoping to eventually be as familiar and comfortable in Linux as I am in Windows (System Administrator).


title: What does this lvcreate call do?

text: Could someone explain this line:               lvcreate -l 128 vg_appli -n lv_cmp      I think 128 is the size, but what is it doing as a whole?


title: why does emacs stop superuser from editing files without permissions?

text: If I have a file I want to edit, as root, I should have the ability to modify it regarless of the permissions. But this does not seem to be the case with all text editors, emacs in particular. If there is a text file with any of the following permissions, with the permissions `-rw-r--r--`, `-r--rw-r--`, or `-r--r--rw-` then as root, I can edit the file, no problem. However, if there are no write permissions at all (`-r--r--r--`), then `emacs` will not allow root to even make changes to the buffer. Vim behaves in a slightly quirky way as well. For the first three cases, it will allow root to save changes with the `:w` command, but in the last case, root must use the override `:w!` command to save. Both `nano` and `gedit` behave properly, giving the super user write access all the time. Does anyone know what the source of this obnoxious behavior is on the part of `emacs` and `vim`? I'm inclined to think it's more of a side-effect of something, rather than an intentional design, based on vim's behavior, but I can't think of what would cause this.


title: Allow IP packet forwarding from LAN to modem via router

text: In short: I'd like to be able to telnet to my modem from my PC via my router. There is a simple home router on `192.168.33.1`. It is running OpenWrt. It has the following interfaces defined:               br-lan    Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan1      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan2      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan3      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lan4      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0     lo        Link encap:Local Loopback     pppoe-wan Link encap:Point-to-Point Protocol     wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0      I think only one or two have relevance here:               root@TIBERIUS: ~ > ifconfig wan     wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:2295 errors:0 dropped:1 overruns:0 frame:0               TX packets:2740 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0               RX bytes:270389 (264.0 KiB)  TX bytes:245297 (239.5 KiB)          root@TIBERIUS: ~ > ifconfig eth0     eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:6252 errors:0 dropped:0 overruns:83 frame:0               TX packets:4725 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000               RX bytes:863045 (842.8 KiB)  TX bytes:667374 (651.7 KiB)               Interrupt:4      None has an IP address assigned to it. But `pppoe-wan` does. And that's the way Internet access works on this box, via PPPoE. The DSL modem is connected to the router on the WAN port. The one labeled such on the casing. (I do not understand why there are both `eth0` and `wan`.) It has a built-in IP address of `192.168.1.1`. It can be audited via telnet. The first step to do so is to set up an interface on the router box to reach the modem through.               root@TIBERIUS: ~ > ifconfig eth0 192.168.1.220     root@TIBERIUS: ~ > ping 192.168.1.1 -I eth0     PING 192.168.1.1 (192.168.1.1): 56 data bytes     ^C      This adds a route, but doesn't work, not even adding the `-I` switch. Must be the wrong interface. (I don't know what `eth0` corresponds to on this box. Maybe the LAN part, not the WAN part?) Anyway, I then reset the network settings (`/etc/init.d/network restart`) and repeat the procedure for `wan`, and that does work:               root@TIBERIUS: ~ > ifconfig wan 192.168.1.222     root@TIBERIUS: ~ > ping 192.168.1.1 -I wan     PING 192.168.1.1 (192.168.1.1): 56 data bytes     64 bytes from 192.168.1.1: seq=0 ttl=64 time=1.205 ms     64 bytes from 192.168.1.1: seq=1 ttl=64 time=0.496 ms      Audit via `telnet` also works. Now I'd like to also work from my PC on the LAN. My PC is on `192.168.33.152`. Trying to `telnet` the modem from the PC results in "connection refused". And I can't ping the modem either ("Antwort von 192.168.33.1: Zielport nicht erreichbar." = "destination port not reachable"). From what I understand about `iptables` from various docs and graphical schemas floating about the net, packets from the LAN to the modem will enter `PREROUTING` chain on the router (no destination NAT needed), then after routing (hopefully) the `FORWARDING` chain, and then (hopefully) the `POSTROUTING` chain (source NAT required). However, I don't have a clue how to fit this in with the various chains predefined by OpenWrt. There's a couple of them in `nat`:               root@TIBERIUS: ~ > iptables -S -t nat     -P PREROUTING ACCEPT     -P INPUT ACCEPT     -P OUTPUT ACCEPT     -P POSTROUTING ACCEPT     -N nat_reflection_in     -N nat_reflection_out     -N postrouting_rule     -N prerouting_lan     -N prerouting_rule     -N prerouting_wan     -N zone_lan_nat     -N zone_lan_prerouting     -N zone_wan_nat     -N zone_wan_prerouting     -A PREROUTING -j prerouting_rule     -A PREROUTING -i br-lan -j zone_lan_prerouting     -A PREROUTING -i pppoe-wan -j zone_wan_prerouting     -A POSTROUTING -j postrouting_rule     -A POSTROUTING -o br-lan -j zone_lan_nat     -A POSTROUTING -o pppoe-wan -j zone_wan_nat     -A postrouting_rule -j nat_reflection_out     -A prerouting_rule -j nat_reflection_in     -A zone_lan_prerouting -j prerouting_lan     -A zone_wan_nat ! -d 192.168.1.0/24 -j MASQUERADE     -A zone_wan_prerouting -j prerouting_wan      And many more in `filter`:               root@TIBERIUS: ~ > iptables -S -t filter     -P INPUT ACCEPT     -P FORWARD DROP     -P OUTPUT ACCEPT     -N forward     -N forwarding_lan     -N forwarding_rule     -N forwarding_wan     -N input     -N input_lan     -N input_rule     -N input_wan     -N nat_reflection_fwd     -N output     -N output_rule     -N reject     -N syn_flood     -N zone_lan     -N zone_lan_ACCEPT     -N zone_lan_DROP     -N zone_lan_REJECT     -N zone_lan_forward     -N zone_wan     -N zone_wan_ACCEPT     -N zone_wan_DROP     -N zone_wan_REJECT     -N zone_wan_forward     -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A INPUT -i lo -j ACCEPT     -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn_flood     -A INPUT -j input_rule     -A INPUT -j input     -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A FORWARD -j forwarding_rule     -A FORWARD -j forward     -A FORWARD -j reject     -A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT     -A OUTPUT -o lo -j ACCEPT     -A OUTPUT -j output_rule     -A OUTPUT -j output     -A forward -i br-lan -j zone_lan_forward     -A forward -i pppoe-wan -j zone_wan_forward     -A forwarding_rule -j nat_reflection_fwd     -A input -i br-lan -j zone_lan     -A input -i pppoe-wan -j zone_wan     -A output -j zone_wan_ACCEPT     -A output -j zone_lan_ACCEPT     -A reject -p tcp -j REJECT --reject-with tcp-reset     -A reject -j REJECT --reject-with icmp-port-unreachable     -A syn_flood -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m limit --limit 25/sec --limit-burst 50 -j RETURN     -A syn_flood -j DROP     -A zone_lan -j input_lan     -A zone_lan -j zone_lan_ACCEPT     -A zone_lan_ACCEPT -o br-lan -j ACCEPT     -A zone_lan_ACCEPT -i br-lan -j ACCEPT     -A zone_lan_DROP -o br-lan -j DROP     -A zone_lan_DROP -i br-lan -j DROP     -A zone_lan_REJECT -o br-lan -j reject     -A zone_lan_REJECT -i br-lan -j reject     -A zone_lan_forward -j zone_wan_ACCEPT     -A zone_lan_forward -j forwarding_lan     -A zone_lan_forward -j zone_lan_REJECT     -A zone_wan -p udp -m udp --dport 68 -j ACCEPT     -A zone_wan -p icmp -m icmp --icmp-type 8 -j ACCEPT     -A zone_wan -j input_wan     -A zone_wan -j zone_wan_REJECT     -A zone_wan_ACCEPT -o pppoe-wan -j ACCEPT     -A zone_wan_ACCEPT -i pppoe-wan -j ACCEPT     -A zone_wan_DROP -o pppoe-wan -j DROP     -A zone_wan_DROP -i pppoe-wan -j DROP     -A zone_wan_REJECT -o pppoe-wan -j reject     -A zone_wan_REJECT -i pppoe-wan -j reject     -A zone_wan_forward -j forwarding_wan     -A zone_wan_forward -j zone_wan_REJECT      How can I file my rules in this set of chains? (Feeling encouraged to ask this here because another user was similarly bewildered by the set of default chains in OpenWrt.)


title: The right way to wrap block of lines in custom text in vim

text: I would like to be able to select several lines using `vim` when editing an HTML file, then enter some hotkey and get these lines wrapped in a django comment block. For example, I have:               one line     another line      I want to get:               {% comment %}     one line     another line     {% endcomment %}


title: Extract data from two files

text: I have two files as given below Output1.csv               201319107648361,12:27:04,12:27:14,0:0:10 secs     201319109089878,12:27:04,12:27:15,0:0:11 secs     201319108968961,12:27:15,12:27:54,0:0:9 secs     201319108686853,12:27:34,12:27:43,0:0:9 secs     .     .     .     n      Output2.csv               201319107648361,200     201319109089878,129     201319108968961,719     201319108686853,412     .     .     .     n      I need to merge these two files in to a single file with one condition i.e if the first field of both the file are same. For Instance, If the first value or field of Output1.csv - **201319107648361** is equal to the first field of Output2.csv then need to print the remaining field of the files in to another file. Desired output file should contain:               201319107648361,12:27:04,12:27:14,0:0:10 secs,200     201319109089878,12:27:04,12:27:15,0:0:11 secs,129     201319108968961,12:27:15,12:27:54,0:0:9 secs,719     201319108686853,12:27:34,12:27:43,0:0:9 secs,412     .     .     .     n


title: How to create ico file with more then one image

text: I can use imagemagic to convert png to ico but (I think, not sure) it will create one image ico file for the size I specify.               convert favicon.png --resize 32 favicon.ico      And ico file can contain 2 or 3 images for 16x16 32x32 and 64x64 pixels. Is it posible to create such icon maybe with image magic of other tool?


title: Use awk to insert a line after N output

text: I have a text file filled with a bunch of data. I need to pull out lines that contain specific strings. I accomplished this with awk using the following:               awk '/pattern1|pattern2|pattern3/ {print;}' infile      I then need to put a new line (\n) after ever 3rd line. So it would need to look like this               pattern1     pattern2     pattern3     <new line>     pattern1...      I was able to accomplish this by piping the first command into another awk statement               awk -F '\n' '/pattern1|pattern2|pattern3/ { print; }' infile | awk '{ if ((NR % 3) == 1) printf("\n"); print; }'      I figure that there must be a more efficient way of doing this so I started looking to see how I could combine the two commands together. I tried the following:               awk '/pattern1|pattern2|pattern3/ { if ((NR % 3) ==1 ) printf("\n"); print; }'      I figured this would work but the output is completely unpredictable, sometimes there are 5 lines grouped together, groups of 2 lines, but no lines of 3. I was thinking that perhaps there was a delimiter issue so I tried playing with the -F option and setting the IFS but neither changed the output. I figure I am doing something stupid in the way I have tried to combine the pattern match with the if statement but I haven't been able to figure out the combination. Is what I am trying to do possible in a single awk command? And if so, where am I going wrong?


title: How do I add newly created mount point to fstab?

text: I just mounted sda2 to /mnt. How can I force a refresh of fstab so it can pickup the changes and insert a new line for sda2-/mnt?


title: Monitoring progress/liveness of background jobs

text: I have started a background job. Is there a way to know how it is progressing, and whether it has stopped? My command line is like:               java weka.classifiers.trees.J48  -t data.arff  J48-data.model >&  log


title: Expanding text format in VI

text: The following code is taken from the superfish module for websites: > (function($){$.fn.hoverIntent=function(f,g){var > cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var > cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var > compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX- > cX)+Math.abs(pY-cY)) And once upon a time when editing this kind of file, I once accidentally hit a shortcut key that restructured the code:               (function($){$.fn.hoverIntent=function(f,g){      var cfg={sensitivity:7,interval:100,timeout:0};      cfg=$.extend(cfg,g?{over:f,out:g}:f);      var cX,cY,pX,pY;      var track=function(ev){cX=ev.pageX;cY=ev.pageY;};      var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);      if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity       {$(ob).unbind("mousemove",track)       etc..........      I want to know what that shortcut is o.0 It's like the formatting already exists but VI didn't render it?


title: Java process, swap (/proc Solaris10) memory highly utilized

text: How can I analyze high swap memory utilization of Solaris 10 for Java processes?


title: Recommended fstab settings

text: I made a new partition for my home drive by following this guide I have no idea what the fstab setting it suggests mean: > UUID=???????? /home ext3 nodev,nosuid 0 2 I used an install CD and used "try it without install", so that I could run with my drive unmounted. I used GParted to resize the partition, and make a new one in the unused space. I then looked up the UUID as the guide said (and used ext4 instead), and everything worked fine. However I'd like to understand what the "nodev,nosuid 0 2" settings are. Are these the recommended settings? Is this the only valid setting? Does it matter in any way?


title: Why does my shell script give the error: "declare: not found"?

text: Here is a simple example showing that using `declare` in a script the script will not run, while sourcing the script will:               $ cat /tmp/new     #! /bin/sh     declare -i  hello     $ chmod a+rwx /tmp/new     $ /tmp/new     /tmp/new: 3: declare: not found     $ source /tmp/new     $       I wonder why directly running the script doesn't work, while sourcing it does? How can I make the first one work? Thanks!


title: How can you change the format command used by man?

text: I'd like to define a new command that prints man pages to PostScript, but using a page size different than the default. For example, on Mac OS X you can run               man -t ls | open -f -a Skim      to open the man page for `ls` as a PDF, which is almost exactly what I'd like. In fact, the only change I want to make is to print to a different page size. Since I'm never actually going to print these out on real paper, it would be nice to have the PDF sized to fit more neatly on my monitor. But I haven't been able to figure out how to do this in a simple way. The man page for `man` says that the `-t` switch will > Use `/usr/bin/groff -Tps -mandoc -c` to format the manual page, passing the > output to `stdout`. To get a different page size it would appear that you need to change the arguments to `groff` to something like `groff -Tps -P-pa4`, so it looks like the straightforward way to do this is to give `man` a different command to use for formatting the man page. But there doesn't seem to be a command line switch or an environment variable that allows you to do this. Is there a way to invoke `man` so that it uses a command that I specify to format the man page? (I would prefer to avoid doing something like               groff -Tps -P-pa4 -mandoc -c `man -w ls`      because sometimes the man pages are compressed as `.gz` files and sometimes they aren't, and presumably `man` could be making some other decisions about how to preprocess man pages.)


title: Routing packets between networks with iptables

text: I'm trying to create a proxy of sorts using just iptables. The linux computer (my proxy) has two ports:   * p2p1 is connected to the Internet.   * em1 is connected to a local network. There are two devices on the local network (not including the linux machine). To connect to these, we should type (from any computer on the Internet):   * xx.xx.xx.xx:10001   * xx.xx.xx.xx:10002 where xx.xx.xx.xx is the public IP (and is dynamic). These devices can be accessed from the linux machine on the em1 port by accessing the following IPs:   * 192.168.3.100:80   * 192.168.3.101:80 So, all traffic that gets routed into xx.xx.xx.xx:10001 on p2p1 should be redestined for 192.168.3.100 on em1. I also need to retain the source IP, or something to that effect, so the packets can find their way back. Here's what I'm using in my IP tables script.               iptables -t nat -F  # Clear out any old rules.          MyIP=10.27.155.200     MyPort=10001     DestIP=192.168.3.100     DestPort=80          iptables -t nat -A PREROUTING --dst $MyIP -p tcp --dport $MyPort -j DNAT --to-destination $DestIP:$DestPort     iptables -t nat -A POSTROUTING -p tcp --dst $DestIP --dport $DestPort -j SNAT --to-source $MyIP     iptables -t nat -A OUTPUT --dst $MyIP -p tcp--dport $MyPort -j DNAT --to-destination $DestIP:$DestPort      Obviously there are some problems because my IP is dynamic, yet I'm hard coding it in every time. Furthermore, the packets, once they return to the computer, don't know how to get to their original source. I don't know where to go from here.


title: Linux: Difference between /dev/console , /dev/tty and /dev/tty0

text: On a Linux system, what is the difference between /dev/console , /dev/tty and /dev/tty0 ? What is their respective use? How do they compare?


title: How does SELinux / SEAndroid prevent or allow pseudo terminal allocation?

text: I'm trying to resolve an SSH connection issue on an Android phone running `SELinux` in "Enforcing" mode. The problem is that any SSH connection that tries to allocate a pseudo-terminal (`/dev/pts` etc) is denied permission, leaving my connection without a controlling tty. Practically this means that I loose the ability to use normal terminal control for editing, command history, CTRL characters etc. Presumably this means that SELinux is preventing the SSH daemon from opening `/dev/ptmx`. I have no idea how to remedy this highly annoying situation, from within SSH server device (phone). I'm running SSHelper on a non-priviledged port 2222 on a _Samsung S4_ using an _SELinux Enforcing AOS 4.2.2_ version. The weirdest thing is that I have root access using _su_ under "Enforcing", but when I disable "Enforcing" and go to "Permissive", everything works in terminal, but I can no longer use su to gain root! (Simply no reaction and no error message.) **So there must be a way to control this under SELinux, but where and how?** Or is this a triviality and that I have only missed something? * * * For SSH connection in _Enforcing_ mode, I use:               $ ssh -2 dummy@192.168.1.10 -p 2222     SSHelper Version 6.3 Copyright 2014, P. Lutus     dummy@192.168.1.10's password:     PTY allocation request failed on channel 0     Linux 3.4.0-2340422 armv7l      This gets me a non tty shell with no prompt, severely limiting any editing possibilities. PS. I have already tried with `ssh -t ...`, no go.


title: Using CtrlP isn't giving very good results - am I using it wrong?

text: I was hoping that I could just type "job.php" and be directed to the `job.php` in my `/lib/model/` folder, but I've mostly just get many other files returned:               [No name]          > batch/dataFixes/jobProspectsSubscriptionId.php     > batch/dataFixes/jobProspectsRankDistance.php     > batch/dataFixes/hiredJobDistanceRankFeedback.php     > batch/sendWeeklyJobOwnersUpdateEmail.php     > batch/dataFixes/backdateJobClosureDailyStats.php     > batch/dataFixes/jobExpectedRevenue.php     > batch/dataFixes/updateJobStats.php     > batch/updateEndedJobState.php     > batch/findUnresponsiveJobPosters.php     > batch/_job_criteria.php           prt  file  <mru>={ files }=<buf> <->      /Users/shane/Documents/sites/zinc      >d> job.php_      Switching to 'find in path' mode, and typing `lib/model/job.php` brings up tonnes of other classes in that folder which have 'job' in the filename, but not `job.php`. Job is a pretty common word in our project, but I was hoping that an exact match for the filename would get ranked pretty highly in the results. Am I using CtrlP wrong, or is the project not really suited to it?


title: What are possible issues with installing a package from the developer instead of the distro-repositories

text: It might sound like a trivial question to some but even though I have been using Linux for quite a few years I haven't really figured out this question. Little background info; I recently upgraded my system from Mint12 to Mint14 and as I started my eclipse installation I realized that I need to install SVN again. It turns out the latest version is 1.7.8 (as of now) while the version I get from the repos is 1.7.5. Now one might argue whether or not it's a big deal, but I personally like to stay in-sync with the current version to avoid downstream issues. I was wondering what kind of problems might arise from skipping the repos and installing from the developers homepage (subversion.apache in this case).


title: Shell programming, avoiding tempfiles

text: I often write KSH shell scripts that follow the same pattern:   * (1) retrieve output from one or more command   * (2) format it using grep|cut|awk|sed and print it to the screen or to a file In order to do that, I often store the output of (1) in a tempfile, and then do the formatting in (2) on that file. Take that code for instance:               TMPFILE=file.tmp          # If tmpfile exists rm it.     [ -f $TMPFILE ] && rm -f $TMPFILE          for SERVICE in $(myfunc); do         getInfo $SERVICE > $TMPFILE # Store raw output in the TMPFILE              # I retrieve the relevant data from the TMPFILE         SERV_NAME=$(head -1 $TMPFILE | sed -e 's/ $//')         SERV_HOSTNAME=$(grep HOSTNAME $TMPFILE | cut -d "=" -f2)         SERV_ARGS=$(grep Arguments $TMPFILE | cut -d ":" -f2)              print $SERV_NAME $SEP $SERV_HOSTNAME $SEP $SERV_ARGS         rm -f $TMPFILE #rm the TMPFILE in vue of next iteration     done      Is there a way, using pipes, redirections and whatnots, to avoid writing a file to disk each time? If it helps, I'm using ksh Version M-11/16/88i


title: Fedora17 record screencast doesn't work

text: I can't start **embedded GNOME screencast recorder** in **F17**. I tried to start it using `Shift`+`Ctrl`+`Alt`+`R` but nothing happened (I can't see any red icon and there isn't any file in my video folder). Could you help me how can I fix it?


title: Does `Segmentation fault` message come under STDERR?

text: I ran an executable in `bash`               ./code > log      It shows occasional error messages on terminal whereas all printf statements go into log file. I re-run it like below               ./code >& log      Now, the occasional error messages also go into log. But if there is a segmentation fault, it is still shown on terminal. Why? How to make the message `Segmentation fault (core dumped)` go into the log file? * * * user$ bash --version GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)


title: Unable to create logical partition with Parted

text: I was fiddling around with `parted` command on a loopback disk and tried to create some partitions using gpt part table but I keep getting `Error: Unable to satisfy all constraints on the partition.` when trying to create a logical partition               $ sudo parted /dev/loop0     (parted) mktable gpt     (parted) mkpart primary 1MiB 201MiB     (parted) mkpart extended 201MiB -0MiB     (parted) unit MiB print     Model: Loopback device (loop)     Disk /dev/loop0: 102400MiB     Sector size (logical/physical): 512B/512B     Partition Table: gpt          Number  Start    End        Size       File system  Name      Flags      1      1.00MiB  201MiB     200MiB                  primary      2      201MiB   102400MiB  102199MiB               extended          (parted) mkpart logical 202MiB 1024MiB     Error: Unable to satisfy all constraints on the partition.      Recreating the same partitions using msdos part table doesn't give such error, though. So any idea what's wrong?               % sudo parted /dev/loop0     GNU Parted 2.3     Using /dev/loop0     Welcome to GNU Parted! Type 'help' to view a list of commands.     (parted) mktable msdos                                                         (parted) mkpart primary 1MiB 201MiB     (parted) mkpart extended 201MiB -0MiB                                        (parted) mkpart logical 202MiB 1024MiB                                      (parted) unit MiB print                                                        Model: Loopback device (loop)     Disk /dev/loop0: 102400MiB     Sector size (logical/physical): 512B/512B     Partition Table: msdos          Number  Start    End        Size       Type      File system  Flags      1      1.00MiB  201MiB     200MiB     primary      2      201MiB   102400MiB  102199MiB  extended               lba      5      202MiB   1024MiB    822MiB     logical


title: CUPS error log contains "No such interface `org.freedesktop.ColorManager'"

text: On my Ubuntu 13.04 laptop, CUPS writes this message into `/var/log/cups/error_log` for each printer on restart:               W [25/Jun/2013:10:00:26 +0100] AddProfile failed: org.freedesktop.DBus.Error.UnknownMethod:No such interface `org.freedesktop.ColorManager' on object at path /org/freedesktop/ColorManager/devices/cups_Brother_HL_2150N_series      I'm not having any problems printing, but I'd like to know why the message appears and what I can do about it. Ideally I'd like to fix the problem without blindly installing drivers and packages; I want to understand precisely why the message appears.


title: Connecting a wireless webcam and wireless dongle

text: I must create a wireless connection between a USB wireless dongle (DLink wireless-N USB Mini Adapter DWA-140) and a wireless webcam (DLink DCS-932L). I.e. point to point connection without Internet. I have to use Linux without a GUI (only commands). What do I need to do, to get this to work?


title: How to copy rows of different files and paste column-wise?

text: I want to create a new file by copying rows of each file and pasting columnwise according to their file name orders. Here is the sample input and required output files below. file1.txt               1234     5678     9201140      file2.txt               abcged     ghigk     lmn      required output file out.tx               1234     abcged     5678     ghigk     9201140     lmn


title: Measure hard-disk read(), write() speed without caching in QNX 6.5

text: I am working on QNX 6.5 Operating system. QNX 6.5 supports POSIX APIs. I am trying to build an application which is used to evaluate performance of hard- disks. My application will read/write/read after write a user defined data buffer of size in kB or MB continuously to the hard-disk from start sector to end sector. The operation performed (read, write, read after write) depends on the user choice. Each time, an operation is performed, application will keep track of the time using `ClockCycles()` and also calculate the speed of each sector read/write operation. I am using `open()` call to open the device file like `/dev/hd0`. I am using `read()`, `write()` APIs to perform read/write operations. My problem is: I am not getting the correct speed of actual disk read/write. Actually the application is returning the speed of data read/write to cache often. The issue is more clear when I am trying to perform an immediate read after write operation. The speed of read operation just after a write operation is very high of the order of 1000-1200 MB/S; whereas a normal read is taking 50-60 MB/S. I am using open flags like `O_SYNC` and `O_RDWR`. I have also tried to change the flags to `O_DSYNC` and `O_RSYNC`. But I found the flags have no effect in the output of the application. There is no flag equivalent of `O_DIRECT` like in Linux. I have also tried to disable cache in hard-disk driver during bootup. Then I got read/write speed accuracy for data sizes of the order of MBs. But even then, when lower data sizes are read after an immediate write, the read speed is again very high. I have also seen some macros like `CACHE_FLUSH`, `CACHE_INVALIDATE` for use in drivers which needs DMA transfer. But I don't know how to use these macros in an application. Can anyone please help me how to bypass caching and get the speed of read/write operation to hard-disk? My hard-disk can be either formatted or unformatted. I have tested with both cases.


title: iCloud stuff stops working while connected to OpenVPN

text: I have a fairly simple OpenVPN setup on an OpenVZ VPS with Ubuntu 11.10. Client is the Viscosity client on Mac OS X 10.8.2, and after some testing, we can rule out the client as being part of the problem. Everything has been working fine except for Apple's iCloud stuff. Web surfing, email, FTP, NNTP, and Skype are all working as expected. It's ONLY the iCloud services that cease to function. If I connect to the VPN, iCloud stuff stops working. I no longer get anything in Messages, Calendar items don't get updated, and Notifications stop working. If I disconnect, the iCloud stuff all starts working. Connect again, iCloud stops working. Here's the server.conf:               status openvpn-status.log     log /var/log/openvpn.log     verb 4     port 1194     proto udp      dev tun     ca /etc/openvpn/ca.crt     cert /etc/openvpn/server.crt     key /etc/openvpn/server.key     dh /etc/openvpn/dh1024.pem     server 10.9.8.0 255.255.255.0     ifconfig-pool-persist ipp.txt     push "redirect-gateway def1"     push “dhcp-option DNS 10.9.8.1″     keepalive 10 120     duplicate-cn     cipher BF-CBC     comp-lzo     user nobody     group nogroup     persist-key     persist-tun     tun-mtu  1500     mssfix 1400      I'm using iptables in a script, and it's also fairly simplistic.               iptables -F     iptables -t nat -F     iptables -t mangle -F     iptables -A FORWARD -i tun0 -o venet0 -j ACCEPT     iptables -A FORWARD -i venet0 -o tun0 -j ACCEPT     iptables -A INPUT -p tcp --dport 22 -j ACCEPT     iptables -A INPUT -p tcp --dport 1194 -j ACCEPT     iptables -A INPUT -p udp --dport 1194 -j ACCEPT     iptables -t nat -A POSTROUTING -s 10.9.8.0/24 -j SNAT --to-source <server's public ip>     echo 1 > /proc/sys/net/ipv4/ip_forward      I tried forwarding ports as well, with no success.               iptables -A FORWARD -p tcp -d 10.9.8.0/24 --dport 5222:5230 -j ACCEPT     iptables -t nat -A PREROUTING -p tcp --dport 5222:5230 -j DNAT --to-destination 10.9.8.6      I am also sometimes behind a double-NAT situation that I have no control over.               Client -> work VPN -> my OpenVPN box -> Internet.          Client -> Airport Express -> ISP (which is doing NAT) -> my OpenVPN box -> Internet.      Those two situations are just the fact of life where I am, and I cannot change them. I do have full control over my client and the OpenVPN server. I am completely out of ideas. I have posted a similar query at the OpenVPN forums, but it hasn't posted yet and seems to be in their moderation queue still. Tried on freenode irc channels, but nobody is awake, so here I am. I have Googled _extensively_ for this, and can find nothing that is related. Help me get iCloud stuff working again! (Note: Sort of cross posted. I posted it here because of the Linux crowd that might be able to help with the particulars of iptables) EDIT: I hate to admit it, but it might possibly be the client after all. The issue does _NOT_ occur with Tunnelblick. I'm opening a dialogue with the developer on this. They've been very helpful so far, so maybe we'll find out what's going on.


title: Which "Processor family" to choose under "Processor type and features"?

text: I have recently compiled a minimal kernel for my **Intel(R) Pentium(R) Dual CPU T3400 @ 2.16GHz** , and chose **CONFIG_MCORE2 (Core 2/newer Xeon)** under "Processor type and features > Processor family" I don't know if this is related, but my laptop has **2GB** of RAM, and the resulting kernel, when compiled, limited my RAM to only **800MB**. Searching google for my CPU doesn't bring anything useful!               processor   : 0     vendor_id   : GenuineIntel     cpu family  : 6     model       : 15     model name  : Intel(R) Pentium(R) Dual  CPU  T3400  @ 2.16GHz     stepping    : 13     microcode   : 0xa3     cpu MHz     : 2166.000     cache size  : 1024 KB     physical id : 0     siblings    : 2     core id     : 0     cpu cores   : 2     apicid      : 0     initial apicid  : 0     fdiv_bug    : no     hlt_bug     : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 10     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm     bogomips    : 4322.39     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:          processor   : 1     vendor_id   : GenuineIntel     cpu family  : 6     model       : 15     model name  : Intel(R) Pentium(R) Dual  CPU  T3400  @ 2.16GHz     stepping    : 13     microcode   : 0xa3     cpu MHz     : 2166.000     cache size  : 1024 KB     physical id : 0     siblings    : 2     core id     : 1     cpu cores   : 2     apicid      : 1     initial apicid  : 1     fdiv_bug    : no     hlt_bug     : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 10     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm     bogomips    : 4322.39     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:


title: Space Problems?

text: I just got a new SD card for my pi. Trying to install node.js, I ran out of space (I've also recently installed a LAMP server system). But, when I plug it into my main (Windows-Ubuntu dual-boot) computer, windows says it's only half full. What's going on here?


title: Version of OpenVPN for Linux kernel 2.4.21 & having iOS client

text: I have the following requirements:   1. Have OpenVPN version that works with iOS client   2. The OpenVPN version should also be able to be compiled with and work on Linux kernel 2.4.21 (due to business reasons I am not allowed to upgrade). I have looked through the help and documentation but can't find any input on this. Will older OpenVPN versions that work on Linux kernel 2.4.21 (CentOS 3) be compatible with the iOS client?


title: How to disable all animations?

text: I'm using LXDE with Openbox.I hate that animations slow down work. How to disable all animations completely?


title: How to link different (incompatible) libraries at runtime depending on program?

text: I have a number of legacy codes that need to be compiled with specific (and often conflicting) libraries. To be specific I have a program which can only be compiled with `g77` and another program which can only be compiled with `gfortran`. Let's call the first program makee and the second program UVES_popler. When compiling (and running) they both need to be linked to the version of pgplot that is compiled with the respective compiler. So, compiling makee with g77 needs to run with pgplot that has been compiled by `g77` as well. And the same, respectively for UVES_popler and `gfortran`. Let's assume that I can compile pgplot with both g77 and gfortran -- what is the best practice for organizing my bashrc? Should I create a bash function for each program and have the proper links and `LD_LIBRARY_PATH`s? Something like:               runmakee() {       export LD_LIBRARY_PATH=/path/to/g77-pgplot/       makee     }      And (probably relatedly) is there a way of setting flags in Makefiles so that the proper libraries are called when compiling these programs respectively?


title: Why cannot a user change group ownership of his own files?

text: Why cannot a user change the group permissions of files which he owns. Let's suppose I have user `martin`:               $ ls -lAd /home/martin/     drwx------ 8 martin martin 4096 Apr 20 01:06 /home/martin/      For some reason, I want user `paul` to be able to access my home.               $ chgrp paul /home/martin/     chgrp: changing group of `/home/martin/': Operation not permitted      Is there a security reason why a user cannot change the group ownership of his own files? I am using Debian 7 (wheezy).


title: Another package being selected instead of what I am trying

text: I am trying to install dhcp3-server,but it is instead selecting isc-dhcp- server and its not working as per my expectations. Please help.                Reading package lists... Done      Building dependency tree             Reading state information... Done      Note, selecting 'isc-dhcp-server' instead of 'dhcp3-server'      I am following How To Set Up A DHCP Server For Your LAN on the HowtoForge site. There is nothing like dhcp3 in /etc/init.d


title: Bluetooth (A2DP) Audio input device

text: I use my Ubuntu (13.10) laptop as an A2DP (Bluetooth audio) sink for my Android phones. The music I play on my phones is sent to the laptop and is heard through laptop speakers. Now I'm trying to setup my laptop as a streaming server. I installed Icecast2 and Darkice. In the Darkice conf file, I configured audio input device as: default, pulse, hw:0,0, plughw:0,0 etc. In all cases, Darkice streams laptop microphone audio only and it does not stream Bluetooth PCM audio. When I muted the microphone in the Unity sound applet, Darkice streams only silence. To stream Bluetooth audio what device I should put in the Darkice conf file?


title: SimpleScreenRecorder, Two Inputs

text: I need to be able to allow SimpleScreenRecorder to record two sections of my screen/external sources without much post-production editing. Is that possible?


title: In the usage string of my custom shell script, shall I also display --help and --version?

text: I'm currently developing a shell script, called `up`, which shows a usage string on the commandline when called with `\--help`. The output looks like this:               $ up --help     usage: up [-n levels][--help][--versions][basename]...      This looks okay but I'm wondering if I actually need to show the `\--help` and `\--version` options because they are a widely accepted standard and only seem to add noise to the usage string.


title: KVM guest as default gateway for bridged network

text: I currently have two vm's both on kvm (virt-manager), both running on separate virtual interfaces (`virbr0` and `virbr1`). The IP of `virbr0` is 192.168.122.0; the IP of `virbr1` is 192.168.123.0. Both VMs can talk to each other. I am trying to make all traffic go through the VM on `virbr0` (122.0) before going to `virbr1` (123.0) from the host machine. Deleting the routing table for 123.0 and adding a new entry with the 122.0 VM as a gateway does not work, and the VMs lose connection after the route is deleted. Any ideas how the traffic can be forwarded to 122.0 before hitting 123.0?


title: Extract bookmarks from a pdf and add them to another in gs?

text: I have two pdf files, one with bookmarks, and the other without. I would like the second pdf file to have the same bookmarks as the first. I wonder how to do that using `gs`? Ideally, it will be nice to first extract the bookmarks from the first pdf file into a text file (which is editable if I can learn its format), and then add the text file as bookmarks to the second pdf file. Thanks! p.s.: I know how to add bookmarks in `pdfmarks` format to a pdf file by `gs`, from http://blog.tremily.us/posts/PDF_bookmarks_with_Ghostscript/               gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=out.pdf in-*.pdf pdfmarks      But I don't know how to extract bookmarks from a pdf directly into `pdfmarks` format. p.s.: In case you may wonder what bookmarks are, they are table of contents which can be shown in a side panel of a pdf reader (such as Evince (note: in Evince bookmarks are called index)), and when you click one bookmark, it will take you to the page.


title: impossible to make fsck

text: I'm trying to make a fsck to a pendrive and it says me:               e2fsck 1.42.8 (20-Jun-2013)     Pass 1: Checking inodes, blocks, and sizes     Error reading block 40402759450689 (Invalid argument).  Ignore error? yes          Force rewrite? yes          Error writing block 40402759450689 (Invalid argument) while getting next inode from scan.  Ignore error? yes          Error storing directory block information (inode=16489, block=0, num=62814697): Memory allocation failed     e2fsck: aborted      Could you help me please to fix the pendrive. Is very important for me. Thanks


title: how to setarch for each bash session

text: I am using bash as my default shell. I don't have root access. But I would like to customize my bash by setarch. So the question is how to do this automatically? Currently, I have to manually run "setarch ... /bin/bash" when I want to use thecustomized bash. Is there a way that this setarch is always automatically done for all my bash sessions?


title: How do I Nohup an interactive shell-script?

text: My Script is having 2 command-line arguments and then just couple of questions, after these questions the script will run for itself, I'm able to pass the command-line argument by just doing,               -bash-3.2$ nohup ./Script.sh 21 7     nohup: appending output to `nohup.out'          -bash-3.2$      Anyway to add the answers of these to-be-asked-questions with nohup?


title: where does lspci gather its information from?

text: In kernel.org's documentation on `proc` I found "[ _The latest version of this documentis available online_". There I says: "… `lspci` _is a synonym for_ `cat /proc/pci`". Which isn't the case here, on a Crunchbang 10 system (Debian based). No such directory. I do get the basic idea and, as far as I know, the content of `proc` is (mainly) created during runtime. (Wrong?). This made me curious: **Question** : Where does `lspci` gather it's information from? And where is this documented? (Where did I miss something?)    Another difference I found: In kernel.org's documentation, under " _Table 1-5: Kernel info in_ `/proc`" > `pci`     Deprecated info of PCI bus (new way -> `/proc/bus/pci/`, decoupled > by `lspci)


title: Linux recommendation for old laptop

text: I want to install Linux on my old laptop from 2006 February. Primarily I want to use it for lightweight coding and browsing the internet. Software needed: **python**   **some web design tools** (i have some in mind)   **dropbox** It's specs are: **Notebook:** Acer Aspire 5003WLMi   **RAM:** 1GB   **Processor:** AMD Turion 64 ML-32   **Graphics Adapter:** SIS Mirage 2 M760 128 MB   **Display:** 15.4 inch, 16:10, 1280x800 pixels I just took the Linux Distribution Chooser quiz and its recommendations are OpenSuse and Fedora. Linux Mint was in the additional recommendation. I was hoping that Lubuntu / ArchLinux would show up as I read that these are minimal distributions; please correct me if I am wrong about this. One thing I definitely want is to install whatever software as and when I need and not get a lot of software preinstalled. Please suggest your recommendations.


title: BackTrack5 R2 video driver works, but presents disturbing error message

text: I've installed backtrack 5 R2 on my computer and everything works fine but the video driver. The solution described here does work, but whenever I start the graphics mode, a message saying that the graphics card doesn't support the configuration that is loaded. I don't know why this is happening. It doesn't change the performance of my computer, but I'd like to know why the message is arising, and what I can do to stop it. Alternatively, where can I find the configuration file that would help me understand what's going on?


title: Linux in a mostly Windows dev environment

text: A little background: our shop has traditionally run a Microsoft software stack but now we're planning to use embedded Linux and I find myself in the role of Columbus: conquer the new world. I mention this because it means I lack the context to interpret what you may think is a simple answer. If you can explain things with comparison to how Windows works this will greatly aid comprehension. If I've understood the idea of X-Windows correctly, an application is an X client and the windowing APIs send/receive UI messages to an X-server via a TCP socket (sends window drawing commands to the X-server and receives mouse and keyboard activity messages from it). As I understand it, use of sockets means that the app code can run on one Unix box while the UI runs on an X-server executing on (eg) any of   * the same computer   * another Unix box running X-server on the same network   * a Windows box 'W' running X-server on the same network   * any box running an X-server anywhere on the internet provided firewalls and routing are appropriately configured to allow the required sockets. On my desk I have a Linux Mint13 host using the Cinnamon desktop and named _ForwardUntoDawn_. It is connected to my 192.168.174 network as 35, and my Win7 is on the same network as 11. They can ping each other, and SAMBA allows file sharing between them. I have installed telnetd and sshd on ForwardUntoDawn and I can establish from Win7 telnet and ssh sessions, and authenticate to obtain a command line. On my Win7 system I have Xming installed with Xming and Xlaunch desktop icons. Running Xlaunch I answer the prompts thus:   * Multiple Windows / display 0   * Start program: gimp Using SSH (C:\Cygwin\bin\SSH.exe)   * Clipboard yes, no font server or params This momentarily results in a black command window but it vanishes before I can read the message. Can anyone guide me on next steps, or more appropriate responses to the needs of Xming? (I chose gimp only because I know it's installed and working.) Note that to use the answer below also read the comments and NOTE you must start your the cygwin xserver using cygwin\bin\startxwin.exe in order to get it to work, I imagine this initialises a few environment variables. * * * I didn't end up using Xming. After I got the ssh settings set right on the Linux box and succeeded in using the Cygwin tools, I had another go using Xming. Applications launched using Xlaunch would start but then abruptly disappear. The problem did not occur using strictly Cygwin tools.


title: How do I reinstall the bioperl modules on Ubuntu?

text: I am trying to learn bioinformatics the hard way. I have no background in Linux, Ubuntu, bash, Perl, Python, etc. I'm trying to use several programs, mostly the bioperl modules, that have been installed and used on this machine before. It seems that older versions function but the newer ones don't. Specifically, it's the NCBI standalone blast group of programs. I can use `blastall`, but not `blastn`, `fastacmd`, or `blastdbcmd` even though those modules are present and show up as executable. The error I get is `no such file or dir`. How do I uninstall this group of modules and then reinstall them? Or is there some other reason why they would not be found? I did try to run them from within the directory where they are located.


title: Why setsebool for httpd not working with -P parameter?

text: I'm trying to disable SELinux for httpd, but when I use the the `setsebool` command with -P parameter, it doesn't work:               setsebool -P http_can_network_connect 1      **Nothing happens** _when I do that ie, the command is apparently running, but returns nothing, and bash is freeze. I'll wait for 10~30 minutes, and nothing happens._ Why?


title: Where can I find hplip debug documentation?

text: I need to monitor HP printer state (ink, paper, etc). Hplip has hp-info tool with debug-mode and very verbose output. But I can't find any documentation with explanation of its data. For example:               hp-info[31896]: debug: printer_status=1     hp-info[31896]: debug: device_status=2     hp-info[31896]: debug: cover_status=4     hp-info[31896]: debug: detected_error_state=64 (0x40)     hp-info[31896]: debug: Printer status=1000


title: Why does the "which" command give duplicate results?

text: `which -a ruby` gives me               /usr/ruby     /usr/ruby     /usr/ruby      It gives the same path three times. Why does this happen?


title: Linux via Buildroot doesn't include alsa-utils

text: After following these instructions from here and from here, my booted Linux does not include ALSA-Utils like "aplay". But I have set all ALSA options. Any idea what's wrong? I also found this but I can't imagine that code refactoring will suddenly include these ALSA-Utils.


title: Batch Convert .mp4 to .avi with ffmpeg

text: Running Ubuntu 13.10 with a fully compiled `ffmpeg`. I know the code for the actual conversion is `ffmpeg -i video.mp4 -codec copy video.avi` I just need a plain and simple Bash script to do that for, say, forty or fifty of the `.mp4` files.


title: How to insert a 'string+ file name' in the file text in commnad line bash shell?

text: I am working on a problem, As part of that I have got some 30,000 files with some content in it. What I want is that I want `name:filename` inside the file text, but since I have got so many files, it is not practical for me to go through each file and do it manually. Is there any way I can do it using shell?               $ cat file1     text1,text2      What I want is this:               $ cat file1     text1,text2     name:file1      I have written this code,               for i in `ls`; do echo $i >> $i; done;      What this is doing is that it is adding the file name as a string at the end, Is there any way I can add `name:filename`, instead of just `filename`.


title: How to start a GUI program with PHP from website

text: My firm has some Ubuntu 12.04 running where there is no display attached and that are behind different firewalls. The visitor on local websites on that servers should be able to start a GUI program like `Teamviewer` there to give graphical access to me (or other support admins). I guess I have to give the PHP user www-data somehow sudo access to start the Teamviewer GUI in a virtual X-Session via `gksu`. How would I have to configure `sudoers` to achieve this? And how could I call that from within a PHP-script, that is running on that server? Sure, I for myself could easily login via ssh or pipe the X-session to my machine, but I need such a Teamviewer-login because this is the easiest way to get past that differing firewalls on all servers.


title: What's the correct value to base the maximum number of CPU's to sched_setaffinity to?

text: I have some confusion as to what's the correct value to use for the number of CPU's I can use to make a `CPU_SET` for a `sched_setaffinity` call on my system. My `/proc/cpuinfo` file:               processor   : 0     vendor_id   : GenuineIntel     cpu family  : 6     model       : 37     model name  : Intel(R) Core(TM) i5 CPU       M 460  @ 2.53GHz     stepping    : 5     microcode   : 0x2     cpu MHz     : 1199.000     cache size  : 3072 KB     physical id : 0     siblings    : 4     core id     : 0     cpu cores   : 2     apicid      : 0     initial apicid  : 0     fdiv_bug    : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 11     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority ept vpid     bogomips    : 5056.34     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:          processor   : 1     vendor_id   : GenuineIntel     cpu family  : 6     model       : 37     model name  : Intel(R) Core(TM) i5 CPU       M 460  @ 2.53GHz     stepping    : 5     microcode   : 0x2     cpu MHz     : 1199.000     cache size  : 3072 KB     physical id : 0     siblings    : 4     core id     : 0     cpu cores   : 2     apicid      : 1     initial apicid  : 1     fdiv_bug    : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 11     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority ept vpid     bogomips    : 5056.34     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:          processor   : 2     vendor_id   : GenuineIntel     cpu family  : 6     model       : 37     model name  : Intel(R) Core(TM) i5 CPU       M 460  @ 2.53GHz     stepping    : 5     microcode   : 0x2     cpu MHz     : 1199.000     cache size  : 3072 KB     physical id : 0     siblings    : 4     core id     : 2     cpu cores   : 2     apicid      : 4     initial apicid  : 4     fdiv_bug    : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 11     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority ept vpid     bogomips    : 5056.34     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:          processor   : 3     vendor_id   : GenuineIntel     cpu family  : 6     model       : 37     model name  : Intel(R) Core(TM) i5 CPU       M 460  @ 2.53GHz     stepping    : 5     microcode   : 0x2     cpu MHz     : 1199.000     cache size  : 3072 KB     physical id : 0     siblings    : 4     core id     : 2     cpu cores   : 2     apicid      : 5     initial apicid  : 5     fdiv_bug    : no     f00f_bug    : no     coma_bug    : no     fpu     : yes     fpu_exception   : yes     cpuid level : 11     wp      : yes     flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority ept vpid     bogomips    : 5056.34     clflush size    : 64     cache_alignment : 64     address sizes   : 36 bits physical, 48 bits virtual     power management:      In this file there are `processor` lines numbered 0-3, for "physical" processors (4 processors total). I can get this value from `sysconf(_SC_NPROCESSORS_ONLN)` but, there is also a line for `cpu cores` and each processor has 2. I believe this represents the "logical" processors or hyperthreading that is accounted for. Should I be using only the "physical" value or can I use the "logical" count? I'm not clear on this because if I go to `/proc/PID/status` theres the line `Cpus_allowed_list` and that can range from 0-7 (8 processors total) but, I also wrote a script to call `taskset -c -p PID` for every "PID" running and this shows every process of having an affinity list of 0-3 max.


title: EOF blocks my script?

text: I have this script (it is actually a snippet from a bigger script).               #!/bin/sh           if [ $actualsize -ge $MAXSIZE ]; then       read dummy FILEPOINT <<EOF       `dd if=myfile skip=8001 count=1 bs=1|od -x`       EOF      fi      When I run it, I get               ./bugged.sh: 9: Syntax error: end of file unexpected (expecting "fi")      Apparently, the problem is the "EOF". Why does this happen and how can I achieve the same result (reading from myfile)?


title: Systemd: keep forked process alive when service is stopped

text: I have a systemd service which forks some child processes. In one scenario I start a shell script which is supposed to stop the service which actually started the script. When I call `systemd stop xxx.service`, systemd will kill all processes in the service's cgroup, which also includes the shell script. Is there any way to stop systemd from doing so? I need the script to survive systemd's stopping attempts.


title: Do spellcheckers exist that are aware of Markdown?

text: I would like to run a spellchecker over my articles before I publish them. I think `aspell` is ok, but it should not try to check code blocks:               asdfasdfa adsfa sdfa text to check adsfasd f          ```     a wild code block appeared!     thisHas quiteOften() some strings.that should NOT get changed     ```          and also `inlined code` should not get checked      **Do command line based spellcheckers exist for Linux that are aware of Markdown and hence ignore code blocks?** I need to be able to run this in batch mode for multiple files. (Bonus points if you know one that really understands LaTeX - no, `aspell -t` does not completely work)


title: fg a bg process because you forgot to redirect output to /dev/null

text: I did `Ctrl`+`Z` `bg` with the intention of disowning next, but I forgot to redirect, now I cant get to my terminal because the scrolling of the output (tarballed a huge directory with verbose set). How do I get a prompt when `STDOUT` from `tar` is filling the screen and I already sent it to the background? I am using Bash 4.


title: How can I print only certain commands from a bash script as they are run?

text: I have a bash script with various if statements based on command line arguments I pass in when calling it. Having some kind of output as to what commands are being run is helpful to confirm the flow through all those if statements, but my current solution is giving me _too much_ information. Using `set -v` in the script was somewhat helpful to see commands printed to the screen as they were run in the script, however I get _too_ many commands. It's almost like an entire copy of the script. I want output that shows what commands are being run, but I don't want to see comments, new lines, expressions in if statements, etc. Is there a way I can pass all possible output generated by the -v option through a regex first before being printed? Or some other solution to get bash to only output commands of a certain "type" (e.g. that are using executables and not just bash specific statements, comments etc.?) [1] http://stackoverflow.com/questions/257616/sudo-changes-path-why was quite helpful on this and is where I got the suggestion for the `set -v` usage. **Edit** : A similar (but not identical) script to the one I'm running:               #!/bin/bash          #get verbose command output     set -v          env=$1          if [ "$env" == "dev" ]; then         python ascript.py     fi          if [ "$env" == "prod" ]; then              #launching in prod will most likely fail if not run as root. Warn user if not running as root.         if [ $EUID -ne 0 ]; then             echo "It doesn't look like you're running me as root. This probably won't work. Press any key to continue." > /dev/stderr             read input         fi              #"stop" any existing nginx processes         pkill -f nginx              nginx -c `pwd`/conf/artfndr_nginx.conf          fi      I want only 2 possible sets of output lines from this script. The first:               python ascript.py      The second:               pkill -f nginx     nginx -c /some/current/directory/conf/artfndr_nginx.conf


title: How to get the Job ID?

text: As we know, the shell enables the user to run background processes using `&` at the command line's end. Each background process is identified by a job ID and, of course, by it's PID. When I'm executing a new job, the output is something like `[1] 1234` (the second number is the process ID). Trying to invoke commands like `stop 1` and `stop %1` causes a failure message: `stop: Unknown job: 1` Understanding that the `stop` command causes a job to be suspended, I was wondering **how to get the job ID** and do it right. If the only way to kill a job is by it's process ID, **what is the purpose of the job ID**?


title: CentOS VPS - Pointing my Domain name to the VPS static IP

text: I am a Linux Newbie. I have a VPS with CentOS installed at my ISP and I am managing it remotely. Up to this point, I have had **shared webhosting** on a Linux machine at my ISP where I had CPANEL installed to manage my mail, ftp, mysql etc.. Now I want to move everything to my VPS: So how do I do the following:   * Install CPANEL on my VPS and access it remotely from my Web Browser?   * **Point my Domain name to my VPN static IP address?**   * Mail server to point to my static IP? Do I need to setup a new Mail server on the VPS or is that managed by CPANEL?   * **Do I need to install a DNS server on my VPS or how does it work? (relates to point nr 2)**


title: How to change extension of all files in a directory?

text: There are some extensionless files in current directory (there are not dot in their names). I want to rename like so:               filename -> filename.md      I tried doing `mv * *.md` but that didn't help. I am interested in a function that takes an argument for the extension and renames accordingly, and the another one for the files to perform operation on.


title: Multiple source directories in duply

text: Is it possible to specify multiple source directories in a `duply` configuration file? If not is there any simple workaround?


title: I am having trouble with a problem my buddy game me

text: SCRIPTING PROBLEM: Command Output Parser Write a script/program to parse the output of the command 'cat test_file.txt' (see linked file) The program should: Create a new file for every server. The file should be named with the server id which is the second field in the "INSTANCE" line. The first line of the file should be the state of the server, identified as the 6th field of the "INSTANCE" line. E.G., running/stopped/etc The remaining lines of the file should be the block device ids, identified by an id of the form qqa-, and the device name. An example line looks like: "qqa-3748959 /dev/sda" The device lines should be sorted in order of the device name (/dev/sda, etc) Bonus: Place the resulting files in directories named for the server type. The type is identified by the last field of the "TAG" line of "Type". In all cases: fields should be selected by column number rather than the id. For example, rather than searching for patterns that match "pj-" you should select the 2nd field of the line that starts with "INSTANCE" Example result based on the first 9 lines of the test file: File name: random_type/pj-10005128 Contents: running qqa-10014158 /dev/sda1 qqa-10002120 /dev/sdj1 qqa-10017806 /dev/sdj2 I honestly have no idea where to start.... any help would be greatly appreciated Here is the contents of the test file RESERVATION lk-10010440 440052211244 security_group,web_security_group INSTANCE pj-10005128 ike-10018425 29-148-165-208.cloud.com 80-224-178-164.cloud.com running random_value 0 random_string 2012-01-01T20:19:08+0000 random_string wie10031896 random_string 109.216.210.228 108.41.193.144 random_string paravirtual xen wq-10021186, wq-10027543, wq-10008697 security_group BLOCKDEVICE /dev/sda1 qqa-10014158 2012-01-01T20:19:43.000Z   BLOCKDEVICE /dev/sdj2 qqa-10017806 2012-01-01T20:19:43.000Z   BLOCKDEVICE /dev/sdj1 qqa-10002120 2012-02-11T18:35:15.000Z   TAG instance pj-10005128 Hostname random_string TAG instance pj-10005128 Name random_name_1 TAG instance pj-10005128 Group random_group TAG instance pj-10005128 Type random_type RESERVATION lk-10006589 440052211244 security_group,db_security_group INSTANCE pj-10007400 ike-10011775 202-248-49-29.cloud.com 201-12-133-81.cloud.com stopped 0 random_string 2013-01-25T05:59:43+0000 random_string wie10031896 random_string 231.253.4.61 231.253.4.61 random_string paravirtual xen wq-10009238, wq-10030026 security_group BLOCKDEVICE /dev/sda1 qqa-10020213 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj1 qqa-10011314 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj4 qqa-10020951 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj5 qqa-10004943 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj2 qqa-10018777 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj6 qqa-10000981 2013-01-25T05:59:53.000Z   BLOCKDEVICE /dev/sdj3 qqa-10028084 2013-01-25T05:59:53.000Z   TAG instance pj-10007400 Type database TAG instance pj-10007400 Name random_name_2 TAG instance pj-10007400 Group random_group RESERVATION lk-10014417 440052211244 security_group,db_security_group INSTANCE pj-10003176 ike-10011775 8-1-1-240.cloud.com 18-34-199-53.cloud.com running 0 random_string 2013-01-25T06:00:02+0000 random_string wie10031896 random_string 140.17.3.221 32.70.176.162 random_string paravirtual xen wq-10009238, wq-10030026 security_group BLOCKDEVICE /dev/sda1 qqa-10001321 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj1 qqa-10025849 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj4 qqa-10017095 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj2 qqa-10009948 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj6 qqa-10024491 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj3 qqa-10000218 2013-01-25T06:00:10.000Z   BLOCKDEVICE /dev/sdj5 qqa-10020627 2013-01-25T06:00:10.000Z   TAG instance pj-10003176 Name random_name_3 TAG instance pj-10003176 Type database TAG instance pj-10003176 Group random_group RESERVATION lk-10032059 440052211244 security_group,db_security_group INSTANCE pj-10020884 ike-10011775 141-49-20-42.cloud.com 110-204-10-172.cloud.com running 0 random_string 2013-01-25T06:00:20+0000 random_string wie10031896 random_string 149.114.49.142 85.142.179.141 random_string paravirtual xen wq-10009238, wq-10030026 security_group BLOCKDEVICE /dev/sda1 qqa-10002751 2013-01-25T06:00:29.000Z   BLOCKDEVICE /dev/sdj6 qqa-10009034 2013-01-25T06:00:29.000Z   BLOCKDEVICE /dev/sdj4 qqa-10030713 2013-01-25T06:00:29.000Z   BLOCKDEVICE /dev/sdj2 qqa-10018148 2013-01-25T06:00:29.000Z   BLOCKDEVICE /dev/sdj1 qqa-10003453 2013-01-25T06:00:29.000Z   TAG instance pj-10020884 Group random_group TAG instance pj-10020884 Name random_name_4 TAG instance pj-10020884 Type database RESERVATION lk-10020585 440052211244 security_group,web_security_group INSTANCE pj-10021471 ike-10005313 8-252-63-249.cloud.com 147-48-132-111.cloud.com pending 0 random_string 2013-02-16T04:56:40+0000 random_string wie10031896 random_string 230.91.172.39 238.209.51.80 random_string paravirtual xen 2572f0d9-fb51-4dcf-9576-482c928a8088_random_string_1 wq-10009238, wq-10028180 security_group BLOCKDEVICE /dev/sda1 qqa-10023749 2013-02-16T04:56:44.000Z   BLOCKDEVICE /dev/sdg qqa-10023749 2013-02-16T04:56:44.000Z   TAG instance pj-10021471 as autoscale TAG instance pj-10021471 Type app TAG instance pj-10021471 Group random_group TAG instance pj-10021471 Name random_name_A RESERVATION lk-10028120 440052211244 security_group,web_security_group INSTANCE pj-10013308 ike-10005313 142-69-27-121.cloud.com 216-130-112-163.cloud.com running 0 random_string 2013-02-16T04:56:40+0000 random_string wie10031896 random_string 0.245.135.206 241.13.160.138 random_string paravirtual xen 2572f0d9-fb51-4dcf-9576-482c928a8088_random_string_1 wq-10009238, wq-10008340 security_group BLOCKDEVICE /dev/sda1 qqa-10013748 2013-02-16T04:56:44.000Z   BLOCKDEVICE /dev/sdg qqa-10015384 2013-02-16T04:56:44.000Z   TAG instance pj-10013308 Name random_name_A TAG instance pj-10013308 Type app TAG instance pj-10013308 as autoscale TAG instance pj-10013308 Group random_group RESERVATION lk-10032084 440052211244 security_group,web_security_group INSTANCE pj-10011525 ike-10005313 49-63-205-3.cloud.com 214-182-99-155.cloud.com running 0 random_string 2013-02-16T04:56:41+0000 random_string wie10031896 random_string 108.204.74.51 108.204.74.51 random_string paravirtual xen 2572f0d9-fb51-4dcf-9576-482c928a8088_random_string_1 wq-10009238, wq-10008340 security_group BLOCKDEVICE /dev/sda1 qqa-10027627 2013-02-16T04:56:45.000Z   BLOCKDEVICE /dev/sdg qqa-10027627 2013-02-16T04:56:45.000Z   TAG instance pj-10011525 Group random_group TAG instance pj-10011525 as autoscale TAG instance pj-10011525 Type app TAG instance pj-10011525 Name random_name_A RESERVATION lk-10028680 440052211244 security_group,web_security_group INSTANCE pj-10026620 ike-10005313 39-55-202-95.cloud.com 14-132-191-42.cloud.com running 0 random_string 2013-02-16T05:25:50+0000 random_string wie10031896 random_string 64.121.47.214 9.102.77.198 random_string paravirtual xen cc24eea7-68fc-4aa8-b20e-2d15aed83291_random_string_1 wq-10009238, wq-10008340 security_group BLOCKDEVICE /dev/sda1 qqa-10009950 2013-02-16T05:25:57.000Z   BLOCKDEVICE /dev/sdg qqa-10009950 2013-02-16T05:25:57.000Z   TAG instance pj-10026620 as autoscale TAG instance pj-10026620 Name random_name_A TAG instance pj-10026620 Group random_group TAG instance pj-10026620 Type app


title: How to open multiple LUKS volumes with key entered in initramfs?

text: I have a Debian 7.4 (stable) based server configured to use an encrypted (RAID1 + LVM) root partition (/boot is un-encrypted regular partition) to which I installed dropbear SSH server so I can remotely enter the LUKS encryption passphrase. In addition to the root partition/volume I have other RAID1+cryptsetup+LVM volumes that I would like to be able to open with the same passphrase. I googled and found out I can use the script /lib/cryptsetup/scripts/decrypt_keyctl to cache passphrases and open multiple volumes with the same passphrase. But how do I use this script with the passphrase entered in initramfs stage?


title: Behavior of rsyslog writing to a pipe

text: I configure `rsyslog` with an additional entry, like this:               *.* |/var/log/logpipes/pipe1      and have my own evaluation program for the messages received. This works so far, but I am unsure, how `rsyslog` behaves if my pipe reader crashes. Would this block all other logging activities as well? I have logfiles too and plan to use `rsyslog-pgsql` and I cannot see, if `rsyslog` works with multiple threads, so, if one of them hangs [pipe reader hangs], if these other logging threads will continue.


title: Kernel module parameters vs /sys/class/... explanation

text: I was making (my first) kernel module to play with the gpio pins of my pandaboard and interrupts. Already "built-in", I noticed you can do (briefly)               cd /sys/class/gpio     echo 138 > export  # a file gpio138 appears         echo out > gpio138/direction     echo 1 > gpio138/value      to turn some voltage high or low on connector pins. Similarly on a kernel module you have module parameters and you can do `echo 3 > /sys/module/my_module/parameters/delay_seconds` for instance My questions :   1. What handles /sys/class/gpio ? A kernel module ? a driver ?   2. Whatever 1. is, is it possible to have more complicated module parameters in a kernel module, with some directory structure ? Like a 'delays' directory containing the params for delays, ... `/sys/module/my_module/parameters/delays/delay_led1_seconds`   3. Can you have the parameters somewhere else than in the path /sys/module/my_module/parameters/... ? (/sys/class/a_name/... for instance)   4. How does the gpio thing creates new/deletes files in /sys/class/gpio when you write to `[un]export` ?


title: Solaris/OpenIndiana: Password for roles?

text: I've been gently experimenting with `roles` in Solaris, and wonder a bit about setting a `password` for it. I want the role I've created to be used by several users, so setting password to the same as one user (as is done for the root-role) is not an option. Having several users "sharing" (knowing) a single password, I've heard is a bad idea - that is after all the rational behind `sudo`. So for now, I've set a blank password (just "Enter"). I did this not by leaving the field in `/etc/shadow` blank nor by setting it to "NP"... I did it by using `passwd` to set it to nothing (pressed "Enter" twice) - and the resulting encrypted entry was surprisingly long and garbeled. **So my first question; is it safe to leave a`role` with blank ("Enter") as password?** After all, only logged-in users with that role can assume it... **A few more questions:** Is there some way in the role-specification to specify that a user should authenticate with his own password - rather than the role's - to switch to the role (without changing the role's password to that of the user, as I assume is done with the root-role)? If not, are there other ways (eg. by using `sudo` - maybe in combination with `su`? If so, how?) to accomplish this? How is the `root`-role bound to the password of the "first user"? Is it some field in the role-specification that makes it happen automatically? What happens behind the scenes to make it happen?


title: ipset not executing from crontab

text: I have this txt files that contains IPs, one per line of file, that I want to block using ipset. I have this bash script that essentially reads from the plain txt file and constructs an array. Then it iterates the array elements and add each one to the ipset I have created for that purpose. The problem is this: if I execute the script manually from the terminal, it works perfectly, but when I add the script to run periodically using crontab, the script runs but the IPs are not added to the ipset. This is the relevant part of the script.               index=0     while true; do       ipset -quiet -A myIpset $[arrayOfIPS[$index]}       index=$[$index + 1]       if [ "$index" -gt "$lastIndexOfArray" ];       then break       fi      done      This works perfectly from terminal but not running from a crontab task. why?


title: Terminate every background process

text: I have a few `Stopped` background processes. `kill $(jobs -p)` and `kill `jobs -p`` have no effect `kill %1`, `kill %2`, etc. successfully terminate individual processes How can I kill every background process with one command? Also, why do the first two commands not work for me? I'm running Linux Mint 15, 64 bit


title: Using if statement with or to validate arguments for shell script

text: I'm working on a bash script to restart multiple apache instances in different environments. It's working fine except I'd like to add some logic to ensure only correct arguments are entered. I've tried the below statement in multiple ways, but I'm not having any luck. Any suggestions?               if [[ $ENVT != qa || $ENVT != qa2 || $ENVT != stageqa || $ENVT != stage ]];       then         usage     fi      It's when I use the stage environment it's evaluating the first option and invoking the function instead of iterating through as seen with set -x turned on. Full script can be seen at pastebin.               + ENVT=stage     + ACTION=stop     + USER=www     + '[' 2 -ne 2 ']'     + [[ stage != qa ]]     + usage


title: How can I use global variable arrays in aliases or functions

text: I am attempting to simplify repetitive work procedures. In doing so, I am trying to write a .bashrc script which will set global path variables that aliases can refer to. Disclaimer: I'm new to linux and scripting in general so I don't know if the approach I've taken to this point is correct. Here is what I've written so far.               SET_DIR=/var/www/          #Set the current site's root directory     function sroot (){         SET_DIR=/var/www/$1         setaliases         echo $SET_DIR     }          #Reinitialize aliases with new sroot     function setaliases(){         alias chk="echo $SET_DIR"         alias rt="cd $SET_DIR"         alias thm="cd $SET_DIR/sites/all/themes/"         alias mod="cd $SET_DIR/sites/all/modules"     }          setaliases      What I would like to do is expand this Idea to define sites in an array or a file. Then use a function that will check the value passed to the sroot function. This will in turn set variables in other functions.               #myfile or array     site=example1.com     theme=alpha     shortcut=x1           site=example2.com     theme=beta     shortcut=x2      So for example "sroot x1" would affect               SET_DIR=/var/www/$site     # and     alias thm="cd $SET_DIR/sites/all/themes/$theme"      How do I configure the function to check for a value in an array then use it's variables?


title: Deciding on a font, and determining the proper notation

text: I have an X11 program that allows you to set a font. It apparently accepts the 'standard' X Logical Font Description. This notation is fairly obscure, and while the document I linked to mentions it, it doesn't actually describe the syntax. Is there some kind of font picking tool that will provide a list of valid fonts, and allow me to picket a font from the list, and specify the sizes and such, then print out this notation? > X Logical Font Description X11 core font instances are usually specified > using a notation known as the X Logical Font Description (XLFD). An XLFD > starts with a dash `-', and consists of fourteen fields separated by dashes, > for example: > > -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1


title: Problem when connect to pptp vnc build on opensuse13.1

text: I have built a pptpd vnc server under opensuse13.1, everything looks fine when I running the pptp service. but there is problems when I connect from both android & winxp client:   1. by winxp at first i can connect to vpn but canot ping any site, it shows time out. I tried to google and uncheck 'use default gateway on remote network' which in vpn network tcp/ip properties advanced page. now the vpn network works fine.   2. by android well, android can connect but canot browser any url. and unfortunatwly i canot find similar settings as winxp. i am pretty sure that vpn server not works fine. can anyone help me here? thanks a lot.


title: Run script as root under Busybox?

text: I have written a shell script that has to be run as root under Busybox. My first thought was to add the script to /etc/busybox.conf like this:               /sbin/my_script.sh = ssx root.root      But this only works with the Busybox apps. How can I allow the script to be run with root permissions when executed by a normal user?


title: How does Ubuntu 14.04 achieve persistent eth* interfaces?

text: Trying to upgrade `udev` to 197+ on my LFS system, I've come across a problem that old persistent network interface names scheme is no longer supported. Before trying to go on with the new suggested scheme I wondered how it's done in Ubuntu, and launched its LiveCD in QEMU with two NICs. I've discovered that the interfaces are still `eth0` and `eth1`, not anything like `enp3s0` which would be under new scheme. Looking further, I noticed that there's still `/etc/udev/rules.d/70-persistent-net.rules` file which seems to be the same as for pre-197 `udev`. What does this mean? Does Ubuntu somehow work around the issue and still implement renaming inside eth-namespace? Or does it hack the `udev` to regain support for this? Or have I misunderstood something?


title: How to calculate average requests per seconds using awk or sed on Apache logs

text: I am trying to calculate the average requests per seconds for a specific period of time of my Apache logs. I have been able to narrow the results down to the period I am interested in, as well as calculating the requests per second, but I am not able to calculate the average. Here is what I have so far: `paste "/var/log/apache2/access.log" "/var/log/apache2/access.log.1" | awk ' $4>"[10/Feb/2013:16:48:00" && $4<"[10/Feb/2013:17:15:00" {gsub(/\\[/,"");print $4} ' | sort | uniq -c` Could anyone steer me in the right direction? I have mentioned sed or awk but I am happy to use something else. Cheers


title: Delete all 'nohup.out' within a directory recursively

text: How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.


title: TT-Connect CT2-4650 CI doesn't initialize (Timeout?)

text: I've tried to get a Techno Trend TT-connect CT2-4650 CI running under a Kali Linux, where I suppose the kernel is about the same as on a current Debian. The compilation ran just fine. The kernel module got loaded with no problems, but when I connect the device to my virtualbox I get the following messages in dmesg:               [  223.081774] usb 1-1: New USB device found, idVendor=0b48, idProduct=3012     [  223.081780] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3     [  223.081785] usb 1-1: Product: TechnoTrend USB2.0     [  223.081789] usb 1-1: Manufacturer: CityCom GmbH     [  223.081792] usb 1-1: SerialNumber: 20130422     [  223.335895] WARNING: You are using an experimental version of the media stack.     [  223.335895]  As the driver is backported to an older kernel, it doesn't offer     [  223.335895]  enough quality for its usage in production.     [  223.335895]  Use it with care.     [  223.335895] Latest git patches (needed if you report a bug to linux-media@vger.kernel.org):     [  223.335895]  a32f7d1ad3744914273c6907204c2ab3b5d496a0 Merge branch 'v4l_for_linus' into staging/for_v3.9     [  223.335895]  6b9e50c463efc5c361496ae6a895cc966ff8025b [media] stv090x: On STV0903 do not set registers of the second path     [  223.335895]  f67102c49a123b32a4469b28407feb52b37144f5 [media] mb86a20s: remove global BER/PER counters if per-layer counters vanish     [  223.354451] WARNING: You are using an experimental version of the media stack.     [  223.354451]  As the driver is backported to an older kernel, it doesn't offer     [  223.354451]  enough quality for its usage in production.     [  223.354451]  Use it with care.     [  223.354451] Latest git patches (needed if you report a bug to linux-media@vger.kernel.org):     [  223.354451]  a32f7d1ad3744914273c6907204c2ab3b5d496a0 Merge branch 'v4l_for_linus' into staging/for_v3.9     [  223.354451]  6b9e50c463efc5c361496ae6a895cc966ff8025b [media] stv090x: On STV0903 do not set registers of the second path     [  223.354451]  f67102c49a123b32a4469b28407feb52b37144f5 [media] mb86a20s: remove global BER/PER counters if per-layer counters vanish     [  223.395840] usbcore: registered new interface driver dvb_usb_ttv2     [  223.396104] usb 1-1: dvb_usb_v2: found a 'TT-connect CT2-4650 CI' in warm state     [  223.396137] usb 1-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer     [  223.396158] DVB: registering new adapter (TT-connect CT2-4650 CI)     [  223.428521] tt_usb MAC address=bc:ea:2b:65:02:d4     [  223.428529] usb 1-1: dvb_usb_v2: MAC address: bc:ea:2b:65:02:d4     [  223.430036] tt_usb: tt_4650_attach, build on Jan 14 2014 09:46:32()     [  223.653935] usb 1-1: DVB: registering adapter 0 frontend 0 (Sit2 DVB-T2/C)...     [  225.716341] usb 1-1: dvb_usb_v2: 2nd usb_bulk_msg() failed=-110     [  227.836363] usb 1-1: dvb_usb_v2: 2nd usb_bulk_msg() failed=-110     [  227.892198] tt_usb: tt_ci_init()     [  229.908294] usb 1-1: dvb_usb_v2: 2nd usb_bulk_msg() failed=-110     [  229.908318] tt_usb: tt_ci_write_i2c: error, Reg=[0x00], Status=-110     [  231.908252] usb 1-1: dvb_usb_v2: usb_bulk_msg() failed=-110     [  231.908260] tt_usb: tt_ci_write_i2c: error, Reg=[0x1f], Status=-110     [  233.908325] usb 1-1: dvb_usb_v2: usb_bulk_msg() failed=-110     [  233.908332] tt_usb: tt_ci_write_i2c: error, Reg=[0x18], Status=-110     [  233.908337] usb 1-1: dvb_usb_v2: 'TT-connect CT2-4650 CI' error while loading driver (-1)     [  233.909530] usb 1-1: dvb_usb_v2: 'TT-connect CT2-4650 CI' successfully deinitialized and disconnected      110 seems to be a Timeout issue, I can't quite see why though. Any ideas are greatly appreciated.


title: Can't start vsftpd on Fedora

text: I have installed vsftpd on my new Eee pc with Fedora 18:               sudo yum install vsftpd      How is it? :               systemctl is-active vsftpd.service      and got               failed      Then               systemctl status vsftpd.service      got               Failed to start Vsftpd demon     Unit vsftpd.service entered failed state      What is the best way to start repairing vsftpd?


title: Is Firefox for Linux generally unstable?

text: Started using Firefox in the early days and have used it as main browser for a long time. Under Windows, where I used it a lot until approximately 2011, I generally seldom had problems with it. Crashes was far and long apart. Perhaps once every 6-7 months. Now, – under Linux, where I have been more active the last years it has steadily been extremely unstable. It is by far the most unstable software, size (as in market etc.) and impact pulling up a lot, I have ever used. It has not been on only one computer, but 3 - 4. I have also done extensive memory and HDD tests over the years on all machines. * * * _**My question:_** Is this the normal for Linux? (I have mainly been on Debian and derivatives.) Is there a common cause for the problems causing crashes (thinking codebase and design) – or is it all over the place? Are the changes, over the years, in website design (a lot more scripts and content mashups) a factor? * * * As an example here are some of the times of crashes over the last months:               06/16/2013 09:50 PM     06/12/2013 04:31 AM     06/10/2013 09:28 AM     06/08/2013 06:02 AM     06/06/2013 02:28 AM     06/02/2013 11:51 AM          05/31/2013 04:42 PM     05/22/2013 08:16 PM     05/18/2013 12:39 PM     05/14/2013 03:40 AM     05/12/2013 03:14 AM     05/04/2013 03:50 PM     05/02/2013 09:14 PM     05/01/2013 04:17 PM          04/30/2013 03:44 AM     04/29/2013 08:56 AM     04/26/2013 07:23 PM     04/26/2013 07:56 AM     04/23/2013 07:34 PM     04/18/2013 11:12 PM     04/08/2013 10:06 PM     04/03/2013 11:23 PM      * * * Edit: This is native FF. (Not Iceweasel). I also keeps add-ons, plugins and tweaks to a minimum. Mainly dictionaries. Used to use Web Developer Toolbar and Firebug, but with the now built-in tools I have no need. I instead uses some custom profiles with plugins on demand like tampering with requests etc.


title: Creating partition from a start point till the end of the disk using parted

text: This is my partition table :               Model: ATA Hitachi HTS54757 (scsi)     Disk /dev/sda: 750GB     Sector size (logical/physical): 512B/4096B     Partition Table: gpt     Disk Flags:           Number  Start   End     Size    File system  Name                  Flags      1      17.4kB  134MB   134MB                Mi                    msftres      2      135MB   86.2GB  86.1GB  ntfs         Ba      3      86.2GB  86.5GB  315MB   ntfs         Ba                    hidden      4      86.5GB  86.6GB  105MB   fat16        EFI System Partition  boot      5      86.6GB  86.8GB  210MB   fat16      9      86.8GB  129GB   42.6GB                                     lvm      6      129GB   236GB   107GB   ntfs      7      236GB   343GB   107GB   ntfs      I want to create a last partition till the end of the disk to be like this :               8      343GB   750GB   407GB   ntfs      How to achieve this in case if i didn't know where to stop, i want to till parted that i want to make a partition from `343GB` till the end of the disk, how to do so ? I'm using parted 3.1


title: Apache throws 403 Forbidden after moving DocumentRoot (CentOS 6.4)

text: I installed Apache via yum on CentOS 6.4. I changed the `DocumentRoot` in `/etc/httpd/conf/httpd.conf` to point to `/home/djc/www`:               DocumentRoot "/home/djc/www"     <Directory "/home/djc/www">         Options Indexes FollowSymLinks         AllowOverride None         Order allow,deny         Allow from all     </Directory>      FS permissions:               djc@vm ~ $ ls -l     drwxrwxr-x.  3 djc djc   4096 Jan 14 11:17 www      No SELinux:               djc@vm ~ $ sestatus     SELinux status:                 disabled      What am I missing?


title: Is there a way to renice the network stack?

text: I have an ARM Linux board that is a router to 16 other boards. When all these download their updates via the router, the network routing effort starves the user space so that a software watchdog (and later on the hardware watchdog) triggers at the router. Is there a way to renice routing efforts without packet drops? I am aware that I could run the application with 'above normal' priority but that would have other unwanted side effects. I also have tried traffic shaping with both ingress and token bucket filters but I don't succeed even if I throttle bandwidth usage to 1-2 mbps. If I reduce the node count to five, I can serve up to 15mbps on average, 20 peak. The hardware is too slow to reach more than 30mbps on a fast ethernet link. _Topology:_   * `eth0`: common network at every board   * `eth1`: toward FTP-gateway, only at router   * no bridging, just IP-forwarding


title: Configure bash to execute command with last argument when no argument was provided

text: I would like to configure bash so that when I execute command (preferably from a list of commands, not any command) without an argument, it takes the argument of previous command. So, for example I type `emacs ~/.bashrc`, then when I enter `source`, bash executes `source ~/.bashrc`. I know it's possible but I don't know where to look for such options.


title: Capturing Screenshot of terminal application via shell script?

text: ## Problem Run `iftop` for 5 seconds, capture the screenshot and save it to a file. `iftop` is a beautiful program for visualizing network traffic, but it doesn't have a batch mode where I can run it for few seconds and capture the output to a file. ## So my idea is   * use commands like `screen` to create a virtual display and run `iftop` in it.   * look for any tools (`screendump`) to take a screen shot of the `screen`. Any idea on how do I go with this?


title: In Bash how does one determining the length of filename?

text: I'm doing a little script to rename some files. Actually a lot of files. The problem and the cool thing is, that I actually just need to change the files that have a filename length of 5 characters. I did a `$(filename:0:5)` and look if there is some leftover, but I guess that's dirty and I would appreciate to know the real or scholastic way of doing this. Something like that:               if [$(filename).length() == 5]; then       reaname_file     fi


title: Extract only the key(s) from GPG exported keypair

text: I have exported public and private keys to file with `gpg --export` and `\--export-secret-keys`. When I examine them with `gpg --list-packets`. I can see that the file contains:   * the actual key   * the user ID   * a signature packet How can I extract only the actual key from the file? I would like end up with a PKCS8 private key file and a _PublicKeyInfo_ (?) file that I can use programmatically.


title: How to log all udp packets from port N in readable format?

text: How to log into file all udp packets (in and out) from port `N` in readable format (capture packet type (time stamp, name of error if one happens or message type, data size, data))?


title: kernel 3.1x and optimus support

text: I have encountered a negative observation regarding bumblebee. Namely, using optirun the performance of the GPU seems to be an order of magnitude lower than it should be. To be more specific: I have a laptop with GTX660M, I have (or had, up until yesterday) a bumblebee installation with kernel 3.7.16 running (OS: openSUSE 12.3) where bumblebee was working fine. But after comparing the runtime of my code on the laptop (GTX660M) with an older card (GTX 560) in my desktop PC I have determined the runtime difference to be about 10x - very bad! After reading up, that the linux kernel 3.12+ comes with support for optimus Graphics I thought of changing to it and did just that. That wrecked pretty much everything. Threads like this do not really help. (especially b/c I'm having trouble applying Arch info to opensuse) So here's the core question: Does GPU switching work with kernel 3.12+ and which packets are required? Furthermore, does GPGPU work then and what is the performance?


title: What is the easiest way to clone an embedded linux SD Card?

text: I have a 8 GB SD Card (card 1) installed with embedded linux for Power PC, libraries and some applications. I want to prepare another 8GB SD Card (card 2) exactly like card 1. What is the easiest way to do this? I tried copying all the files from card 1 to a linux laptop and then from the laptop to card 2 but I am getting some permission denied errors in spite to doing this in root. Is my approach correct? Please suggest any other techniques.