title: Is the Linux implementation of the system configuration "variable" ARG_MAX different from other system variables and is it POSIX compliant?

text: In the shell, as explained in this this Q&A in the context of expansion, depending on the system, the maximum length of a command's argument is initially constrained by the kernel setup. The maximum value is revealed at runtime using the `getconf` command (see also IEEE Std 1003.1, 2013 Edition):               # getconf ARG_MAX     2097152     vs. value found in limits.h on my setup:     #define ARG_MAX       131072    /* # bytes of args + environ for exec() */      Indeed: > The sysconf() call supplies a value that corresponds to the conditions when > the program was either compiled or executed, depending on the > implementation; the system() call to getconf always supplies a value > corresponding to conditions when the program is executed. The manpages reference POSIX, from the prolog alluding the _POSIX Programmer's manual_ , to the _description_ itself: > The value of each configuration variable shall be determined as if it were > obtained by calling the function from which it is defined to be available by > this volume of POSIX.1-2008 or by the System Interfaces volume of > POSIX.1-2008 (see the OPERANDS section). The value shall reflect conditions > in the current operating environment. The basic variables which can be queried appear in the table for the `sysconf` function specification and there is more information about the values in the `limits.h` header documentation:               {ARG_MAX}         Maximum length of argument to the exec functions including environment data.         Minimum Acceptable Value: {_POSIX_ARG_MAX}     ...(nb you cannot be POSIX compliant under a certain value...)     {_POSIX_ARG_MAX}         Maximum length of argument to the exec functions including environment data.         Value: 4 096      The `xargs --show-limits` command confirms some of this:               Your environment variables take up 3134 bytes     POSIX upper limit on argument length (this system): 2091970     POSIX smallest allowable upper limit on argument length (all systems): 4096     Maximum length of command we could actually use: 2088836     Size of command buffer we are actually using: 131072      `sysconf` was initially designed to find the system value for the PATH variable, then it was extended to other variables. Now, the _Open Group_ documentation explores the rationale for having such a framework where applications can poll for system variables at runtime, and the related practical considerations about the baseline...: > (...) If limited to the most restrictive values in the headers, such > applications would have to be prepared to accept the most limited > environments offered by the smallest microcomputers. Although this is > entirely portable, there was a consensus that they should be able to take > advantage of the facilities offered by large systems, without the > restrictions associated with source and object distributions. > > During the discussions of this feature, it was pointed out that it is almost > always possible for an application to discern what a value might be at > runtime by suitably testing the various functions themselves. And, in any > event, it could always be written to adequately deal with error returns from > the various functions. In the end, it was felt that this imposed an > unreasonable level of complication and sophistication on the application > developer. ...as well as the shortcomings of such a setup as it relates to some file variables with `fpathconf`: > The pathconf() function was proposed immediately after the sysconf() > function when it was realized that some configurable values may differ > across file system, directory, or device boundaries. > > For example, {NAME_MAX} frequently changes between System V and BSD-based > file systems; System V uses a maximum of 14, BSD 255. On an implementation > that provides both types of file systems, an application would be forced to > limit all pathname components to 14 bytes, as this would be the value > specified in on such a system. So the intent was to relieve developers of some burden for the baseline while also acknowledging variety in the filesystems and generally enabling some customizing on different variants of the platform. The evolution of hardware, Unix and related standards (C and POSIX) plays a role here. **Questions:**   * The command `getconf` doesn't have a "list" option, and `set`, `printenv` or `export` don't show those variables. Is there a command which lists their value?   * Why facilities like `fpathconf` were seemingly built to introduce more flexibility, but only for PATH and file related system variables? Is it just because at that time getconf was only about PATH?   * What is the current Linux implementation, and is it POSIX compliant? In the linked Q there is reference in the answers to ARG_MAX varying with the stack size ("on Linux 3.11... a quarter of the limit set on the stack size, or 128kiB if that's less than 512kiB"):      * What is the rationale for this?      * Is this choice (1/4 of the stack size) a Linux specific implementation or just a feature on top of the basic implementation or did the historical UNIX implementation always yield basically that 1/4th of the stack size?     * Are many other variables besides ARG_MAX a function of the _stack_ size or similar resources or does the importance of this variable warrant a special treatment?     * Practically, does one deliver a POSIX compliant Linux system/solution and there's configuration of the stack size limit for example to allow some application to go beyond the basic maximum spec if it scales up with the hardware or is it a practice to customize directly `limits.h` and compile for specific needs?      * What is the difference for something like ARG_MAX between using `limits.h` vs. changing the variable at runtime with something like the `ulimit -s` command vs. having the kernel manage it directly? In particular is the (low)value of that variable in my `limits.h` obsolete on Linux because of kernel changes i.e. has it been superseded?   * The command line supposedly has shell specific length restrictions which are not related to expansion and ARG_MAX; what are they in `bash`?


title: VGA passthrough - Code 43 with KVM and libvirt on all AMD hardware

text: I've set up a system with an R9-270 and an ATI Rage (PCI graphics card, doesn't use radeon driver) on an FX-8320 and an ASRock 970 Extreme3 R2.0 motherboard with the intention of running Debian Wheezy as host and Windows 8.1 Pro as a guest with the R9 passed through to the guest system. I've followed the guide from the Debian Wiki to do this (https://wiki.debian.org/VGAPassthrough) and have reached the end, but when I boot the guest with the card and its audio device attached I get Code 43 in the guest and the card doesn't work. I've also tested passing it through to an Ubuntu guest which also didn't work. Apparently it's fairly common to get code 43 errors, but these are mainly with Nvidia GPUs and the only one I've seen for AMD only showed up when that user moved away from an AMD CPU. The guide does not feature any explanation for troubleshooting Code 43 presumably because the author did not get it. I'm running the VM on KVM and passing the card and its audio device through using virt-manager's Add Hardware dialogue. This software configuration is known to work, as this is the same setup used by the author of the above guide. It seems support for this issue is (understandably) scarce because it isn't commonly used. EDIT: should probably note that I have blacklisted the radeon driver on the host, and that since it's not in the guide and I can't find a good explanation for how exactly it works I am not using the PCI stub driver.


title: Why is NetworkManager attempting to control an interface script that doesn't exist?

text: I'm showing hundreds of frequently repeated entries in /var/log/messages that don't make sense. More below the example. Here's an example, which is repeated ad nauseam in the log file:               Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 1 of 5 (Device Prepare) scheduled...     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 1 of 5 (Device Prepare) started...     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 2 of 5 (Device Configure) scheduled...     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 1 of 5 (Device Prepare) complete.     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 2 of 5 (Device Configure) starting...     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> (em2): device state change: 4 -> 5 (reason 0)     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 2 of 5 (Device Configure) successful.     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 3 of 5 (IP Configure Start) scheduled.     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 2 of 5 (Device Configure) complete.     Oct 15 15:14:01 mybox NetworkManager[2570]: <info> Activation (em2) Stage 3 of 5 (IP Configure Start) started...     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 4 of 5 (IP4 Configure Timeout) scheduled...     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 4 of 5 (IP4 Configure Timeout) started...     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 5 of 5 (IP Configure Commit) scheduled...     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 4 of 5 (IP4 Configure Timeout) complete.     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 5 of 5 (IP Configure Commit) started...     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 5 of 5 (IP Configure Commit) failed (no IP configuration found)     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> (em2): device state change: 7 -> 9 (reason 5)     Oct 15 15:14:46 mybox NetworkManager[2570]: <warn> Activation (em2) failed.     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> Activation (em2) Stage 5 of 5 (IP Configure Commit) complete.     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> (em2): device state change: 9 -> 3 (reason 0)     Oct 15 15:14:46 mybox NetworkManager[2570]: <info> (em2): deactivating device (reason: 0).      I originally had two interfaces on this machine, but am now only using one (em1). The second interface (em2) no longer exists in `/etc/sysconfig/network- scripts/` The networking service has been restarted, and the machine itself. Still getting references to `em2`. I've looked in /etc for hidden config entries with               find /etc/ -exec grep -Hn em2 {} \;      But nothing comes up for "em2" (aside from garbage text in sha/md5 strings) Couple questions: 1) Where else would `NetworkManager` be pulling config data from? Or is NM seeing a physical card and trying to bring it up even though a network interface script doesn't exist? 2) Is `NetworkManager` absolutely required for managing network interfaces? This machine uses a min install of `CentOS 6`. I think NM was installed early on but I later used vim to hand configure the network scripts. The primary interface (em1) works fine.


title: understanding Linux software-RAID superblock

text: According to `mdadm` manual, `\--zero-superblock` option will overwrite the superblock with zeros. As I understand, superblock is a 256 byte block on HDD/SSD describing the RAID level used, name of the array, creation time of the array, modification time of the superblock itself etc. However, how does the `mdadm` know where is the superblock located on the disk? Hasn't this changed throughout the versions of superblocks? In addition, is there only a single superblock in use or are there multiple ones for redundancy reasons?


title: How to parse the file from end in awk

text: #!/bin/sh     if [ $# -ne 8 ]; then             echo "Usage: sh `basename $0` YYYYMMDD hour min masterid account destination filename forward|backward";             exit 1;     fi          day=${1}     hour=${2}     min=${3}     masterid=${4}     account=${5}     destination=${6}     file=${7}     if [ "${8}" == "backward" ]; then             backward="true";     fi          if [ "${backward}" != "true" ]; then             awk -v day=${day} -v hour=${hour} -v min=${min} -v masterid=${masterid} -v account=${account} -v destination=${destination} -f /var/tmp/selfCross.awk /koba/c/dumper/${file}     else             tac "/koba/c/dumper/${file}" | awk -v day=${day} -v hour=${hour} -v min=${min} -v masterid=${masterid} -v account=${account} -v destination=${destination} -f /var/tmp/selfCross.awk     fi      if backward != true, it is working fine. But, tac is somehow not working what should I do? It is returning immediately. What am I doing wrong in the above script?


title: Why the unix bin directory named in that way?

text: I thought the `bin` directory is the place for _binary_ files. If so, what about script files? Should they be placed somewhere else? What's the history of `bin` directory and where should I put script files if the `bin` means _binary_?


title: Get ssh server key fingerprint

text: Is there a way to _programmatically_ obtain a SSH server key fingerprint _without authenticating_ to it? I'm trying `ssh -v user@host false 2>&1 | grep "Server host key"`, but this hangs waiting for a password if key based auth is not setup.


title: Splitting file using prefix

text: I need to split a file into 5 parts but the tricky part to append the numeric number in the prefix of the filename and not at the end.               split -n 5 -d -a 2 "$file" "$file"      Name of the file:- file = text creates the text01 but I want 01text.


title: Different version of Python cannot find modules

text: In my Suse system I have these 2 versions of Python:               # which python2.6     # /usr/bin/python2.6          # which python2.4     # /usr/local/bin/python2.4      2.6 is the system one, and 2.4 was compiled by me. If I try to import a package using the 2.4 version:               # python2.4 -c "import bz2; print bz2.__doc__"      I get the following error:               # ImportError: No module named bz2      What is the correct way to proceed with this?


title: How do I restore grub on a uefi boot after a windows update wiped it?

text: Until yesterday I had a dual boot debian / win8 with grub that worked like a charm. Yesterday a stupid windows update totally wiped grub and I'm now unable to boot in linux.   I installed linux a year ago and I remember it was quite a pain to properly make grub work and I don't even remember all the steps involved. What is the correct procedure to restore it?


title: Auto Start MySQL and Apache

text: How does one get certain daemons to automatically startup on a restart of the server? I found this post on Server Fault but I am looking of a more in depth explanation of how getting a daemon to auto start works. I am using CentOS v5.8 and I am trying to get MySQL and Apache to start by default after a restart of the system. Does it involve changing a configuration file?


title: linux io stack analysis

text: I'm trying to understand the Linux IO stack by analyzing `blktrace` trace. Below is the trace i captured by executing simple fio sequential write with no Direct IO (5 x 8k request size).                 8,16   1        1     0.000000000 10006  U   N [fio] 0       8,16   1        2     0.000024099 10006  U   N [fio] 0       8,16   1        3     0.000034879 10006  U   N [fio] 0       8,16   1        4     0.000045234 10006  U   N [fio] 0       8,16   1        5     0.000055410 10006  U   N [fio] 0       8,16   1        6     5.110792867 22364  A  WS 903168 + 8 <- (8,17) 901120       8,16   1        7     5.110794692 22364  Q  WS 903168 + 8 [kjournald]       8,16   1        8     5.110798680 22364  G  WS 903168 + 8 [kjournald]       8,16   1        9     5.110800405 22364  P   N [kjournald]       8,16   1       10     5.110801662 22364  I  WS 903168 + 8 [kjournald]       8,16   1       11     5.110804742 22364  A  WS 903176 + 8 <- (8,17) 901128       8,16   1       12     5.110804951 22364  Q  WS 903176 + 8 [kjournald]       8,16   1       13     5.110806188 22364  M  WS 903176 + 8 [kjournald]       8,16   1       14     5.110807168 22364  A  WS 903184 + 8 <- (8,17) 901136       8,16   1       15     5.110807321 22364  Q  WS 903184 + 8 [kjournald]       8,16   1       16     5.110807592 22364  M  WS 903184 + 8 [kjournald]       8,16   1       17     5.110808138 22364  A  WS 903192 + 8 <- (8,17) 901144       8,16   1       18     5.110808292 22364  Q  WS 903192 + 8 [kjournald]       8,16   1       19     5.110808498 22364  M  WS 903192 + 8 [kjournald]       8,16   1       20     5.110808948 22364  A  WS 903200 + 8 <- (8,17) 901152       8,16   1       21     5.110809092 22364  Q  WS 903200 + 8 [kjournald]       8,16   1       22     5.110809284 22364  M  WS 903200 + 8 [kjournald]       8,16   1       23     5.110809726 22364  A  WS 903208 + 8 <- (8,17) 901160       8,16   1       24     5.110809872 22364  Q  WS 903208 + 8 [kjournald]       8,16   1       25     5.110810062 22364  M  WS 903208 + 8 [kjournald]       8,16   1       26     5.110814625 22364  A  WS 903216 + 8 <- (8,17) 901168       8,16   1       27     5.110814796 22364  Q  WS 903216 + 8 [kjournald]       8,16   1       28     5.110815070 22364  M  WS 903216 + 8 [kjournald]       8,16   1       29     5.110815547 22364  A  WS 903224 + 8 <- (8,17) 901176       8,16   1       30     5.110815692 22364  Q  WS 903224 + 8 [kjournald]       8,16   1       31     5.110815881 22364  M  WS 903224 + 8 [kjournald]       8,16   1       32     5.110816338 22364  A  WS 903232 + 8 <- (8,17) 901184       8,16   1       33     5.110816483 22364  Q  WS 903232 + 8 [kjournald]       8,16   1       34     5.110816675 22364  M  WS 903232 + 8 [kjournald]       8,16   1       35     5.110817040 22364  A  WS 903240 + 8 <- (8,17) 901192       8,16   1       36     5.110817185 22364  Q  WS 903240 + 8 [kjournald]       8,16   1       37     5.110817375 22364  M  WS 903240 + 8 [kjournald]       8,16   1       38     5.110819614 22364  U   N [kjournald] 1       8,16   1       39     5.110821326 22364  D  WS 903168 + 80 [kjournald]       8,16   1       40     5.111602870     0  C  WS 903168 + 80 [0]       8,16   1       41     5.111724953 22364  A  WS 51910880 + 8 <- (8,17) 51908832       8,16   1       42     5.111725778 22364  Q  WS 51910880 + 8 [kjournald]       8,16   1       43     5.111727434 22364  G  WS 51910880 + 8 [kjournald]       8,16   1       44     5.111728735 22364  P   N [kjournald]       8,16   1       45     5.111729356 22364  I  WS 51910880 + 8 [kjournald]       8,16   1       46     5.111730264 22364  A  WS 51910888 + 8 <- (8,17) 51908840       8,16   1       47     5.111730424 22364  Q  WS 51910888 + 8 [kjournald]       8,16   1       48     5.111731118 22364  M  WS 51910888 + 8 [kjournald]       8,16   1       49     5.111732441 22364  U   N [kjournald] 1       8,16   1       50     5.111733167 22364  D  WS 51910880 + 16 [kjournald]       8,16   1       51     5.112248377     0  C  WS 51910880 + 16 [0]       8,16   1       52     5.112288403 22364  A FWFS 51910896 + 8 <- (8,17) 51908848       8,16   1       53     5.112289215 22364  Q  WS 51910896 + 8 [kjournald]       8,16   1       54     5.112290348 22364  G  WS 51910896 + 8 [kjournald]       8,16   1       55     5.112291577 22364  P   N [kjournald]       8,16   1       56     5.112292055 22364  I  WS 51910896 + 8 [kjournald]       8,16   1       57     5.112293139 22364  D  WS 51910896 + 8 [kjournald]       8,16   1       58     5.112303160 22364  U   N [kjournald] 1       8,16   1       59     5.112767922     0  C  WS 51910896 + 8 [0]       8,16   1       60    39.159727927 10007  A   W 796696 + 8 <- (8,17) 794648       8,16   1       61    39.159729606 10007  Q   W 796696 + 8 [flush-8:16]       8,16   1       62    39.159733195 10007  G   W 796696 + 8 [flush-8:16]       8,16   1       63    39.159735006 10007  P   N [flush-8:16]       8,16   1       64    39.159736356 10007  I   W 796696 + 8 [flush-8:16]       8,16   1       65    39.162686094     0 UT   N [swapper] 1       8,16   1       66    39.162702603    23  U   N [kblockd/1] 1       8,16   1       67    39.162704841    23  D   W 796696 + 8 [kblockd/1]       8,16   1       68    39.163311755     0  C   W 796696 + 8 [0]      Notes:   * OS is CentOS with kernel version 2.6.32-358.18.1.el6.x86_64   * ext3 with Journal ordered mode used with default option (commit = 5 seconds)   * The disk offset of 903168 is the data file where fio write into it   * The disk offset of 51910880 should be where the journal located. (I did a test with external journal and can't find this range in that trace) Another hint is the operation is FWFS. After some study, i can confirm that this offset 51910880 is journal descriptor block, offset 51910888 is filesystem metadata block and offset 51910896 is journal commit block    * I assume disk offset 796696 is where the metadata resides So my questions are:   * Is kjournald suppose to flush file data? I always think that kjournald only flush dirty journal block? How about pdflush?   * Difference between kjournald and jbd2/vdb*-*? Is it one for ext3 and another for ext4?   * Why metadata is flushed only after ~34 seconds? Is this always the case when flush is initiated, kblockd is used to issue write request to device driver?


title: Can somebody explain The Debian Apache2 configuration files cocondrum?

text: I am a newbie to `Apache2.4`. I know I am running the said version because of :-               $ sudo apache2ctl -v     Server version: Apache/2.4.10 (Debian)     Server built:   Jul 23 2014 13:15:48      Apparently there are three different configuration files which are needed to be configured :-               /etc/apache2$ ls *.conf     apache2.conf  ports.conf      and               /etc/apache2/conf.d$ ls *.conf     httpd.conf      Apparently these three files work something like this :- `apache2.conf` :- It is known as the **Global** configuration file. `ports.conf` :- This is apparently to tell Apache which IP Addresses and port to listen and bind to (to do web-serving). `httpd.conf` :- This is something to do with user configs. I do not have much idea about it. Now I have two questions :- a. Is my understanding of the three files correct ? If somebody could better explain it would be nice. b. why is httpd.conf supposed to be in /etc/apache2/conf.d/httpd.conf while the other two are in /etc/apache2/ ?


title: How to split text file into records by first non-blank charecter using awk and print only records containing string

text: I have a text file with information separated in blocks. I would like to separate these blocks into records so that I can handle them separately. This is my text file (file.txt):               Alarm Stats:     com.android.calendar          38ms running, 0 wakeups          1 alarms: act=com.android.calendar.APPWIDGET_SCHEDULED_UPDATE dat=content://com.android.calendar typ=vnd.     com.android.providers.calendar          2ms running, 2 wakeups          2 alarms: act=com.android.providers.calendar.intent.CalendarProvider2 flg=0x14     android          35563ms running, 11 wakeups          1 alarms: act=android.intent.action.DATE_CHANGED flg=0x20000014          1210 alarms: act=android.intent.action.TIME_TICK flg=0x40000014          120 alarms: act=com.android.server.ThrottleManager.action.POLL flg=0x14          1 alarms: act=android.net.wifi.DHCP_RENEW flg=0x14          10 alarms: act=android.content.syncmanager.SYNC_ALARM flg=0x14     com.apollo.apollonetworkcheck          1026ms running, 88 wakeups          88 alarms: flg=0x14     com.android.phone          4ms running, 0 wakeups          2 alarms: act=com.android.phone.UPDATE_CALLER_INFO_CACHE flg=0x14      Using "apollo" as my search string, the output should be:               com.apollo.apollonetworkcheck          1026ms running, 88 wakeups          88 alarms: flg=0x14      So far I have this for my commandline, but I don't know where to put the search string "apollo". Also, I don't know how to specify "non-blank" for the recordcord separator.               $ awk 'BEGIN { RS = "^RTC" } { print $1 }' file.txt      * * * _Archemar, wurtel, steeldriver, terdon, your answers are great and adds lots of substances and resource resolution to the question. I up-voted each answer for the great value. The one with "gawk" of course was more precise to the question and objective to use the unix/linux command._


title: Unable to extract tarball

text: I have a gzip compressed tarball, `my.tar.gz` and I run the following commands to extract the contents:               tar -xvzf my.tar.gz     tar xvzf my.tar.gz      Both these commands run successfully but do not create any directory. I mean the directory containing the contents of `my.tar.gz`. Any suggestions?


title: Place the cut field in the desired position of ouput file

text: I am writing a script like in which, it will `cut` the fields from input file and append to output file.               cat $1|while read line     do     acc_no=`echo "$line" | cut -c29-43`     acc_type=`echo "$line"|cut -c124-125`     echo "$acc_no","$acc_type" >> out.csv     done      here it is separated by ','. Now I want in output file like `acc_no` from positions `20 to 33` in output file `acc_type` from positions `1 to 2` in output file I do not need any delimiters, I want to access these things by the positions. How can I do this?


title: Jack not recognizing MIDI device

text: Jack does not recognize my MIDI keyboard, whereas ALSA does. Here are the logs :               pi@raspberrypi / $ jack_lsp      system:playback_1      system:playback_2     LinuxSampler:midi_in_0      LinuxSampler:0      LinuxSampler:1      * * *               pi@raspberrypi / $ amidi -l      Dir Device    Name      IO  hw:1,0,0  nanoKEY2 MIDI 1      * * *               pi@raspberrypi / $ cat /proc/asound/cards      0 [ALSA           ]: bcm2835 - bcm2835 ALSA                           bcm2835 ALSA      1 [nanoKEY2       ]: USB-Audio - nanoKEY2                           KORG INC. nanoKEY2 at usb-bcm2708_usb-1.2, full speed      What could be the problem ? Many thanks !


title: Will switching from Gnome to LXDE improve battery life?

text: I currently have Fedora 14 and the battery life is not so good. I am planning to switch to Fedora 16. Will I get significantly more battery life if I go for the LXDE spin instead of GNOME?


title: Printing a new line using awk

text: I have a load of files in which I need to take out specific rows and then put the data I've taken out into a spreadsheet. An example would be my file shows:               Name: w          Age: x          Height: y          Weight: z      I only want the age, height and weight, so I first ran:               grep -E 'Age|Height|Weight' [input file] > output.txt      Because of the number of files, my output now looks like               Age 1          Height 1          Weight 1          Age 2          Height 2          Weight 2          etc...      What I now want is to run an awk script so it goes through my new output.txt file and first finds every row with the word 'Age' and the prints it. Once it has done all the 'Age' ones, it then does the heigh and then weight. I ran the script:               awk -F"\t" '/Age/ {print} /Height/ {print}' output.txt >output2.txt      But if just prints it like the original out put file. How do I change it so after it has done all the Age ones, it then finds the height ones? EDIT: My desired output is for the file to be > Age 1 > > Age 2 > > Height 1 > > Height 2 > > Weight 1 > > Weight 2 > > etc.. Just to clarify, the Age 1 is the row with 'age' in it from file 1, etc.


title: Why is this ALSA configuration file preventing aplay and arecord from listing PCM devices?

text: In my embedded system I have this configuration file in `/etc/asound.conf`:               pcm_slave.sl2 {             pcm "hw:0,0"             rate 48000             channels 2             format S16_LE     }          pcm.rate_convert {             type plug             slave sl2     }          pcm.!default rate_convert      I noticed that since this file was placed in the system, `aplay -L` and `arecord -L` cannot list the PCM devices anymore. `aplay -l` and `arecord -l` are instead working as expected. If this file is not placed in there, the list is correctly returned. What is this doing exactly? Why is this preventing `aplay` and `arecord` from listing PCM devices?


title: What is the difference between rc, rc.local and rc.sysinit?

text: I tried to display the list of startup scripts for the current runlevel at bootup. I wrote the following code.               rl=`runlevel | cut -d " " -f2`     ls /etc/rc.d/rc$rl.d/S* | cut -d "/" -f5     sleep 10      It's working if I put this code in `rc.local` file. But it's not working if I put it in `rc` file or in a separate script file `abc` in `/etc/init.d` and by creating softlinks in runlevel directories. But simple commands like follows are able to run in all the methods.               ls /etc/init.d      Do some commands like runlevel or piping won't work unless some of the scripts have started? Or is there something else? And if I put my code in `rc` file, my code runs before and after reboot.   * So what's the difference between `rc`, `rc.local` and `rc.sysinit` files?   * Where exactly I need to edit those files? Also I can find `S99local` -> softlink for `rc.local` in 2,3,4 and 5 runlevels. Does it mean that `rc.local` wont run on runlevel 1?


title: How to issue a warning to administrator (when the administrator issues a system restart) when user has process running

text: **Background**   I work on a development team and for each project we have a different server setup to emulate the environment of our customers. It can be hard to keep track of what I was doing on each server and where I need to start. In order to alleviate this problem I have started using a terminal multiplexer (tmux/screen). My problem is on one of the servers that I work on, the project lead is constantly making mistakes and resetting the system. When that happens I lose all of my screens as well as time getting back to where I was and what I was doing. **Question**   All developers are given root access to the servers and I want to know if there is anyway I can set up the server so that my project lead gets a warning of users logged on or screens running when they decide to reset the server? (If possible I'd like to include a message of what I'm running and why they should find a different solution to resetting the server. In my company this is the only project manager that resets the server on a daily basis.)


title: How to shutdown Linux at a specific datetime from terminal?

text: It seems I can shutdown using `sudo shutdown` by specifying a time or minutes. Is there a way to specify datetime for shutdown?


title: cuda - gzip: stdin: invalid compressed data--format violated

text: I downloaded cuda toolkit from here! I'm running on 32-bit Linux(Mint 17). I had to download `.run` file(the downloaded file name is `cuda_6.5.14_linux_32.run-{09606fc1-f7a7-4b33-a22d-12b51c090f83}.dtapart` After downloading, I made it executable(Properties -> Permissions -> Allow this ... ). When I ran it, it didn't work(nothing happen). I tried installing it from terminal. I did `chmod +x <name>` and then 'bash '. But now it showed me this message:               gzip: stdin: invalid compressed data--format violated     Extraction failed.     Ensure there is enough space in /tmp and that the installation package is not corrupt     Signal caught, cleaning up      I searched the error but I couldn't find a solution. My system info: `32bit LinuxMint 17` `lspci | grep -i nvidia` : 01:00.0 VGA compatible controller: NVIDIA Corporation G98M [GeForce G 105M] (rev a1) `uname -m && cat /etc/*release`:               i686     DISTRIB_ID=LinuxMint     DISTRIB_RELEASE=17     DISTRIB_CODENAME=qiana     DISTRIB_DESCRIPTION="Linux Mint 17 Qiana"     NAME="Ubuntu"     VERSION="14.04, Trusty Tahr"     ID=ubuntu     ID_LIKE=debian     PRETTY_NAME="Ubuntu 14.04 LTS"     VERSION_ID="14.04"     HOME_URL="http://www.ubuntu.com/"     SUPPORT_URL="http://help.ubuntu.com/"     BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"     cat: /etc/upstream-release: Is a directory


title: How do I address a possible version mismatch between headers and package on RHEL4's EPEL?

text: Trying to install `puppet` from EPEL on RHEL4:               # up2date -i puppet          Fetching Obsoletes list for channel: rhel-i386-as-4...     ########################################          Fetching Obsoletes list for channel: EPEL...          Fetching obsoletes list for http://infrastructure.fedoraproject.org/repo/pub/epel/4/i386...     #######################################     Fetching rpm headers...     ########################################          Name                                    Version              Rel               Arch     ----------------------------------------------------------------------------------------     puppet                                  0.25.6              1.el4               i386               Testing package set / solving RPM inter-dependencies...          Downloading headers to solve dependencies...     #######################################     Downloading headers to solve dependencies...     #######################################     Downloading headers to solve dependencies...     #######################################     Downloading headers to solve dependencies...     ########################################     There was a fatal error communicating with the server. The message was:          An HTTP error occurred:     URL: http://infrastructure.fedoraproject.org/repo/pub/epel/4/i386/augeas-libs-0.10.0-2.el4.i386.rpm     Status Code: 404     Error Message: Not Found      I tried changing the mirrors at `/etc/sysconfig/rhn/sources` and clearing out the headers from `/var/spool/up2date` but the same error appears. When I look deeper into the mirror, I see the following:   * Package: `augeas-libs-0.` **10.0-3**`.el4.i386.rpm`   * Header: `augeas-libs-0-0.` **10.0-2**`.el4.i386.hdr` Could this be the problem? If so, how do I go about addressing it?


title: Tmux status bar question

text: I'm fairly new to tmux and to truly master and learn it, I decided to make myself a fresh .tmux.conf I was wondering, though, if it's possible to hide a path in the status bar. For example, I have this in my tmux.conf:               setw -g window-status-format '#I #10W'     setw -g window-status-current-format '#[fg=red][#I:#10W]#F'      Now, let's use my window as an example. In one window, I have macvim running. The tmux status bar changes to "[1:mvim] _". That's exactly what I want. But I have another pane inside that window running ttytter. When I switch to it, tmux doesn't change the name to "1:[ttytter]_ " Also, in another window, I have opened a directory with a long path name. tmux changes the status bar to "[1:...long/path]*". I've seen people run their tmux and it only says "zsh" for them. How can I have that too? I don't want the full path name inside my status bar. I'm running tmux on OS X if that helps. Thanks in advance for any help!


title: What process is accessing a mounted filesystem sporadically?

text: I have a Solaris 10 server with autofs-mounted home dirs. On one server they are not unmounted after the 10 min timeout period. We've got `AUTOMOUNT_TIMEOUT=600` in `/etc/default/autofs`, I ran `automount -t 600`, disabled and re-enabled `svc:/system/filesystem/autofs:default` service and nothing seems to work. My suspicion is that _something_ on the system is periodically accessing all the mounted filesystems, maybe checking if they are accessible, and thus resetting the automounter timeout that in turn never expires. This is supported by a test I just did - if I set the timeout to 10 seconds the mountpoints are unmounted, looks like 10 sec is shorter than the period in which that _something_ is doing the checks and the timer has a chance to expire. The question is how can I find what process is doing that? The server is a heavily used production system and I can't do any dangerous experiments on it. Note that the filesystems are _not_ kept open and can be manually unmounted. That _something_ is probably going mountpoint by mountpoint, cd in, cd out, move on, often enough to prevent `automount` from unmounting it. But it doesn't keep it open and therefore is not visible with `lsof` or `fuser -c`. I want to catch it or record it as soon as it accesses the mountpoints to know what's doing it. FWIW it's a Solaris 10 zone on rather beefy Solaris 10 host (Sparc / M5000).


title: Tab autocomplete for files with spaces in it

text: How do I tab autocomplete for files with spaces in it? Thanks.


title: creation of user add

text: I'm having more then 59 servers I need to create a script for user add. purpose: if I'm creating a user in one server it will be reflected on all 59 servers. How can I accomplish this?


title: Grub MD5 Crypt algorithm

text: How does Grub's MD5 algorithm work? When you run grub-md5-crypt and enter the same password each time you get different results. Generally md5 is supposed to always return the same hash, so why does grub's version return something different each time? Also, considering that, how is it then determining you are entering the correct password? If you each encryption creation with the same password generates a different hash, then how is it that later on when you enter your password (and theoretically the same algorithm is used) that since the hash's will be different, how are they matched to show you provided the correct password? I'm assuming a salt is used somewhere and that the salt is randomly generated, but what is the salt, and how is it generated exactly, and then how is it replicated?


title: Windows 7/Ubuntu 11 dual boot plus VM?

text: I have installed Ubuntu on my Windows 7 machine, and can now happily dual- boot. What I'd like to do is retain this set-up but be able to use the same Ubuntu set-up as a virtual machine within Windows. I've seen solutions that allow this with a Windows VM within Ubuntu, but not the other way around. Can anyone help? Thanks in advance!


title: What does “trace trap” mean when reported by zsh?

text: I am trying to run a set UID root program in UNIX using the zsh shell. But I keep getting this message               $ ./progExe     zsh: trace trap ./progExe      Can anyone please tell what does “zsh: trace trap” mean?


title: Problem after ati driver installation

text: I've just installed the ati radeon drivers using the latest version on the ati site. Upon rebooting this has caused gnome 3 to fall back into a safe mode. My question boils down to how do I fix this mess? Is there a way to uninstall the ati drivers? Have I not completed the installation properly. Is there a better open source alternative? I'm using fedora 15 and the drivers were catalyst 11.9. The graphics card is a HD 4570 on my laptop. Thanks in advance.


title: Why is that when I download a binary from the web it doesn't have executable permissions set, but when I use gcc to build a binary it does?

text: For example, if I have the file hello.c which just contains:               int main() {        printf("Hello world");        return 0;     }      and I built it in gcc with `gcc hello.c -o hello` I can then run `./hello` and it runs. However, if I try to download a binary from the web with e.g. `curl`, I first have to set the permissions with chmod before I can run it. Is there a reason why? Do gcc and/or curl set some default permissions on the files?


title: Why does Bash history not record this command?

text: The command `printf "#!/bin/bash\n" > t` generates an error(`bash: !/bin/bash\n": event not found`), but hitting the up key does not recall the command so that I can modify it. Why is that? (What I was trying for here can be accomplished with `printf "%s\n" '#!/bin/bash' >t` I am trying to learn Bash and really want to understand why bash history doesn't capture the previous `printf` command.)


title: Understanding webcam 's Linux device drivers

text: As far as I know, device driver is a part of SW that is able to communicate with a particular type of device that is attached to a computer. In case of a USB webcam, the responsible driver is UVC that supports any UVC compliant device. This means that enables OS or other computer program to access hardware functions without needing to know precise details of the hardware being used. For this reason, I installed UVC Linux device driver by running:               opkg install kernel-module-uvcvideo      Webcam has been recognised by Linux kernel: `dev/video0`. However, I still wasn't able to perform video streaming with FFmpeg, as I was missing V4L2 API. I installed V4L2, by configuring kernel. **My queries are:**   * How UVC driver and V4L2 are linked together?   * What is the purpose of V4L2 API?   * If I haven't installed UVC first, it would be installed with V4L2? LinuxTV refers: _The uvcvideo driver implementation is adherent only to the V4L2 API_. This means that UVC is part of V4L2 API?


title: Connect my laptop through desktop to internet

text: I'm currently at work and our wifi is down. I usually connect my desktop to the internet through eth0 and my laptop connects through wifi. I have an extra port on the back of the desktop (eth1) and one on my laptop (eth0). I tried connecting a crossover cable between these two ports and bringing up a connection. I set up a route to the desktop through my laptop and I can ping between the two machines but neither one will connect to the internet through desktop's eth0. Any help is much appreciated =)


title: Printing PDF with not embedded TrueType Font (cups / lpr)

text: I have a PDF in which the TrueType font `OCRB` is used, however the font is not embedded. So I tried to install the font on my system (which is by the way a SLES11 SP2), I did the following things:   * Double Clicked the font on gnome Desktop and clicked install   * Copied it in the `/user/home/username/.fonts` folder   * Copied it in the `/usr/share/fonts`   * With root: `SuSEconfig --module fonts`   * `fc-cache` When I try to print the .pdf with the command:               lpr -PHL2400Ce -# 1 test.pdf      The .pdf prints just fine, but the `OCRB` font is gone and replaced with the standard one. However, when I open the .pdf with `evince` (gnome Document viewer) I see the `OCRB` font in the viewer (correct) and when I print it (with the same printer) its there and absolutely correct. I don't understand this because I guess `evince` also uses `lpr` in some way? Any ideas what I can do? (It is very important for me being able to print the .pdf via command line, since it's gonna be part of batch jobs which runs in background) I also tried some approaches like this:               gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=output2.pdf -f test.pdf      Which brings me the output:               ....     Can't find (or can't open) font file Arial-BoldMT.      Didn't find this font on the system!     Substituting font Helvetica-Bold for Arial-BoldMT.     Substituting font Helvetica for OCRB      So what I see here is, that `gs` substitutes `Helvetica` for `OCRB` even though there is no message `Can't find or can't open font...` as it is for `Arial-Bold`. Any idea why?


title: Why could the size of the "dot" file "." exceed 4096?

text: Today I found an "empty" directory with a size of 4MB. It had no visible contents, so I tried `ls -lah`. This showed me some hidden files (not very large). Searching for the reason why the directory was so large I found that the dot file (`.`) had a size of 3.9MB. Maybe this is a newbie question, but what gets stored in that file? Isn't that just a kind of link to the same directory? Here is the shell output (anonymized):               -bash# more /proc/version     Linux version 2.6.18-8.1.15.el5 (mockbuild@builder6.centos.org) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Mon Oct 22 08:32:04 EDT 2007     -bash# pwd     /data/foo/bar/tmp     -bash# ls -lah     total 4.1M     drwxrwxrwx  3 nobody nobody 3.9M Nov 21 10:02 .     drwxrwxrwx 16 nobody nobody 4.0K Aug 27 17:26 ..     -rw-------  1 root   root    20K Oct 25 14:06 .bash_history     ...


title: Start 4 programs on startup in Linux Mint via terminal

text: I'm working on a project and I hope you can help me solve a problem. I have four programs that are written in C. They have been compiled using `gcc` and they work as they should. Because the four programs are drivers for some devices, I need to start them again if the PC resets for any reason, or if the power supply is lost. In the programs I have some parts where I am printing some statuses, and for the moment I start the programs using a console. How can I start the programs on startup in Linux Mint? Is it possible on startup to activate four consoles and with the consoles so start the program? If not do I have to transfer the output of the programs in file? (Four devices is connected to the PC via four serial ports.)


title: Can not explain ACL behavior

text: So this is situation: got server for web-developers. There are many developers. All `developers` + `PHP` + `Apache` belongs to `www` group. There is a development directory - `development`. The goal is that every file in `development` directory has `755` permissions and whenever a any developer creates, modifies a file in `development` directory, files will still have `755`. So I have read a number of `acl` tutorials, guides and howto's but I still can not get the result I want.   1. my disk is mounted with `acl`   2. I got `chown -R www:www development`   3. added `chmod g+s development`   4. I set a number of `acl` rules on `development` directory and got this:              $ getfacl development     # file: development     # owner: www     # group: www     # flags: -s-     user::rwx     user:www:rwx     group::rwx     group:www:rwx     mask::rwx     other::r-x     default:user::rwx     default:user:www:rwx     default:group::rwx     default:group:www:rwx     default:mask::rwx     default:other::r-x          p.s. I know its messy, was doing a number of tests        5. According to my idea of `ACL`, if directory had such rules, my task should be achieved, but when I try to create a file in `development` dir, I get:              -rw-rw-r--+ 1 www     www      0 Nov 21 09:14 newfile      I can not seem to understand why it creates `rw-` instead `rwx`. It is probably something simple that I missed or some general concept that I don't understand.


title: Count words: what will use less CPU, wc or a perl script?

text: My objective is to count the words in a file while using the minimum possible CPU. I could use the `wc` command or write a simple perl script for this, which of the two options will be less CPU intensive?


title: Why SSH key login asking me the Passphrase every time?

text: I use PuTTY and followed this tutorial:   * http://www.howtoforge.com/ssh_key_based_logins_putty Every time I login I"m being asked to input the passphrase. How do I avoid having to do this?


title: What is the number prefix in config files from .d directory

text: A lot of unix config files in `xx.d` folders are prefixed by a number, like :               $ ls /etc/grub.d/     00_header        10_linux      30_os-prober      40_custom       05_debian_theme  20_linux_xen  30_uefi-firmware  41_custom      Is there any convention on this number? What does it mean ? Might just be to avoid name clashing but I'm curious if there's anything more.


title: redirection and pipeline

text: I was wondering about differences and relation between redirection and pipeline.   1. Is pipeline only used to connect stdout output of a command to stdin input of another command?   2. Is redirection only used to connect a stdout output of a command to a file, and to connect a file to a stdin input of a command? But there seems to be `command >& 2`.   3. A pipeline `com1 | com2` can be replaced by redirection as `com1 > tempfile; com2 < tempfile`. Can the replacement be modified to be without using a file?   4. Can a redirection be replaced by a pipeline? Thanks and regards!


title: Automated test for install script

text: I'm writing an install script for an appliance that modifies system config files under `/etc` (amongst other things). How can I test this script non- destructively? Ideally I would like to run the script in a pseudo-sandbox that provides a layer over the existing filesystem, and then see examine any changed files afterwards. I'm not worried about the script being intentionally malicious, but would like to protect against system files being modified or deleted in any way.


title: What are core.mountd.######### files? OpenSolaris

text: I and gaining an ever expanding list of of core.mountd.12009999475 type files in my root directory? What are these? Can I just delete them? What causes them to be created?


title: understand a sequence of redirections

text: If several redirections are used together, does changing their order make difference? How shall one understand the meaning of their order? Is the chained channel of redirections built as reading the redirections from left to right, or from right to left? For example               command 2>&1 > somefile          command > somefile 2>&1      Thanks and regards!


title: Open luks-encrypted partition from virtual DomU LVM disk containing another LVM

text: I've gotten myself in a bit of a bind, here. A while ago I set up an encrypted Unbuntu 13.04 under Xen. It's virtual disk is an LVM LV. This LV was presented to the DomU as a (whole) physical disk during installation, and I let Ubuntu's installer set up encrypted root and swap (using LVM). However, I forgot to write down the root pw. Or I wrote it down wrong. After a power failure the other day I cannot get back into the machine as root. I have the passphrase for the DomU:s LVM partition though, so the DomU goes up. I just can't log in. Booting with `init=/bin/bash` does not work, since init needs to unlock the encrypted partition. I can't figure out how to open the LVM-containg partition the LVM LV from Dom0, either, since ´cryptsetup luksOpen´ won't accept an offset in the LVM LV. Does anyone know how to get into the LV - Partition - (LVM) - LV and reset the root password?


title: Fixing mount points

text: I recently install steamOS (a debian fork) and I had to change the mount point on my second hard drive because it was the same as the mount point for steam os "/". Unfortunatly now I cannont access that hard drive. As far as error messages go in gparted all of the partitions on the 2nd hard drive say:               Unable to detect filed system! Possible reasons are:     -The filesystem is damaged     -The filesystem is unkown to GParted     -There is no file system availible(unformatted)     -The device enty /dev/sda5 is missing       I'm pretty sure I didn't format the drive or manipulate the data on it so here are my questions: 1. What did I actually do when I changed the mount point? 2. Can I fix it? if so how? 3. If I can't fix it how do I get access the the disk back? Just format and partition?


title: What's the problem with this script to change wallpaper?

text: I'm very new to Linux's world, so I would ask to forgive me for every stupid or too simple thing I will ask now. I installed Elementary OS from their website just yesterday. I wanted to change my wallpaper automatically with Bing's wallpaper, so I found on Google a script that downloads from Bing's servers the image... That's good, it works (I see the images downloaded inside the folder). The problem is that it doesn't always change the wallpaper. Sometimes yes, sometimes not. I don't understand really when and why. It seems that it happens when the downloaded image is not new. Sorry for my bad english, what I mean is that I put this script starting on boot with the tool given with Elementary OS, and if I turn on my pc >1 times per day, (and Bing's image change one time per day) the other times I just get everything black as wallpaper. Here is the part of the code that changes wallpaper, maybe it is there the problem:               #!/bin/bash          # $bing is needed to form the fully qualified URL for     # the Bing pic of the day     bing="www.bing.com"          # $xmlURL is needed to get the xml data from which     # the relative URL for the Bing pic of the day is extracted     #     # The mkt parameter determines which Bing market you would like to     # obtain your images from.     # Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA.     #     # The idx parameter determines where to start from. 0 is the current day,     # 1 the previous day, etc.     xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=1&n=1&mkt=en-US"          # $saveDir is used to set the location where Bing pics of the day     # are stored.  $HOME holds the path of the current user's home directory     saveDir=$HOME'/Pictures/BingDesktopImages/'          # Create saveDir if it does not already exist     mkdir -p $saveDir          # Set picture options     # Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned     picOpts="zoom"          # The desired Bing picture resolution to download     # Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"     desiredPicRes="_1366x768"          # The file extension for the Bing pic     picExt=".jpg"          # Extract the relative URL of the Bing pic of the day from     # the XML data retrieved from xmlURL, form the fully qualified     # URL for the pic of the day, and store it in $picURL          # Form the URL for the desired pic resolution     desiredPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$desiredPicRes$picExt          # Form the URL for the default pic resolution     defaultPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<url>(.*)</url>" | cut -d ">" -f 2 | cut -d "<" -f 1)          # $picName contains the filename of the Bing pic of the day          # Attempt to download the desired image resolution. If it doesn't     # exist then download the default image resolution     if wget --quiet --spider "$desiredPicURL"     then              # Set picName to the desired picName         picName=${desiredPicURL##*/}         # Download the Bing pic of the day at desired resolution         curl -s -o $saveDir$picName $desiredPicURL     else         # Set picName to the default picName         picName=${defaultPicURL##*/}         # Download the Bing pic of the day at default resolution         curl -s -o $saveDir$picName $defaultPicURL     fi          # Set the GNOME3 wallpaper     DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$saveDir$picName'"'          # Set the GNOME 3 wallpaper picture options     DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts           # Remove pictures older than 30 days     find $saveDir -atime 30 -delete          # Exit the script     exit


title: Why is Linux's filesystem designed as a single directory tree?

text: Can anyone explain why Linux is designed as a single directory tree? Whereas in Windows we can have multiple drives like `C:\`, and `D:\`, there is a single root in Unix. Any specific reason there?


title: How do I set up a PostScript print queue to share a PCL laser printer and add PS fonts?

text: I would like to take a $100 PCL-compatible laser printer and hook it to my home network either through Wi-Fi or by connecting it directly to a Linux server by USB. Instead of using the manufacturer-provided drivers, though, I want to be able to print PostScript documents directly. I imagine I will want to set up a print queue, GhostScript, and an IP address and port at which I can point other machines on the network. Also, I have a stack of CDs with PostScript fonts on them, and I would like to make these available to any machine that wants to print to the networked printer. I'm guessing this is done by copying the fonts somewhere where GhostScript can find them. Basically, I want to make the cheap printer look to other machines on the network like an old-school expensive PostScript-capable networked laser with lots of built-in fonts, like one of the high-end LaserWriters that Apple used to sell. In the old days with dot matrix printers and HP LaserJet printers that only had a parallel interface this sort of thing was common, but it seems like it's actually more obscure now that most printers are network-capable out of the box and are configured through a GUI. In particular I think I have an idea how I would have done the GhostScript setup with LPD by defining filters, but now all Linux distros seem to have CUPS installed out of the box.


title: LD_PRELOAD or similar to warn user about modifications to a file?

text: I am running a (complex) script that seems to modify at some point a file. I would like to get warnings whenever the script / program tries to write, chmod, chown or perform any other attempt that I disapprove of. I want the program to have normal access to the rest of the filesystem. Denying access is one solution, but since I have to run the script as root, it won't work. The script could override any access control settings. Even if I could run the script as non-root, the script could decide to take a different branch on access failure. That's why I prefer a warning-on-access instead of an access denial. Is there a solution (e.g. SE Linux)?


title: List all available ssl ca certificates

text: My git client claims               error: Peer's Certificate issuer is not recognized.      That means it can not find the corresponding ssl server key in the global system keyring. I want to check this by looking at the **list of all system wide available ssl keys** on a gentoo linux system. How can I get this list?


title: How to send AT commands to a modem in Linux?

text: In Linux (Ubuntu) I am trying to send AT commands to a modem at `/dev/ttyACM0`. I tried to do it as:               sudo socat - /dev/ttyACM0      but when typing anything I just get a line repeating this command (I expect an `OK`). When I do               sudo minicom modem1      it seems to work. I type an `AT` and get an `OK`. I type some crap, I get an `ERROR`. It seems that `modem1` for minicom is somehow configured to use the modem at `/dev/ttyACM0`. How can I use socat to send AT commands? Do I need to configure something? Maybe I can use configurations for `modem1` of minicom (I do not know how to find/see this configuration)? ## Additional information Is the given `socat` command correct? Should I play with some options? With the `-v` option I see the following:               AT     > 2013/10/23 17:10:28.917413  length=3 from=0 to=2     AT     < 2013/10/23 17:10:28.921598  length=3 from=0 to=2     AT     AT     ksjdhfjdgfhjkdfh     > 2013/10/23 17:10:30.244923  length=17 from=3 to=19     ksjdhfjdgfhjkdfh     < 2013/10/23 17:10:30.251383  length=29 from=3 to=31     ksjdhfjdgfhjk\b \bd\b \bf\b \bh\b \b     ksjdhfjdgfhj       The device itself is found with the following dmesg output:               [5983726.808063] usb 2-1: USB disconnect, device number 3     [5983730.800021] usb 2-1: new full-speed USB device number 4 using uhci_hcd     [5983730.920014] usb 2-1: device descriptor read/64, error -71     [5983733.629524] usb 2-1: New USB device found, idVendor=0572, idProduct=1329     [5983733.629533] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3     [5983733.629539] usb 2-1: Product: USB Modem     [5983733.629544] usb 2-1: Manufacturer: Conexant     [5983733.629549] usb 2-1: SerialNumber: 24680246     [5983733.632673] cdc_acm 2-1:1.0: ttyACM0: USB ACM device      And the tty is configured as follows:               speed 57600 baud; line = 0;     eof = ^A; min = 1; time = 0;     -brkint -icrnl -imaxbel     -opost -onlcr     -isig -icanon -echo -echoe


title: Locking Desktop just Like Windows

text: Whenever I am at work, I would like to lock the computer so my desktop isn't accessible to others. In windows it's trivial, press the `Windows`+`L` key. Is there something similar available in Linux, particularly Fedora.


title: OpenVPN dropping connection every time interval

text: I have setup OpenVPN. The server is a router running DD-WRT with OpenVPN setup. The client is Ubuntu 12.04. The connection is established without issues. I can ping clients at the VPN side. The problem is every 5-10min (seems slightly variant) the following occurs on the Ubuntu Client:               Fri Jan 18 17:01:45 2013 OpenVPN 2.2.1 x86_64-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Mar 30 2012     Fri Jan 18 17:01:45 2013 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables     Fri Jan 18 17:01:45 2013 WARNING: file 'client1.key' is group or others accessible     Fri Jan 18 17:01:45 2013 UDPv4 link local: [undef]     Fri Jan 18 17:01:45 2013 UDPv4 link remote: [AF_INET]VPN_IP_ADDY:1194     Fri Jan 18 17:01:47 2013 [VPN_HOST_NAME] Peer Connection Initiated with [AF_INET]VPN_IP_ADDY:1194     Fri Jan 18 17:01:49 2013 TUN/TAP device tun0 opened     Fri Jan 18 17:01:49 2013 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0     Fri Jan 18 17:01:49 2013 /sbin/ifconfig tun0 192.168.66.6 pointopoint 192.168.66.5 mtu 1500     Fri Jan 18 17:01:49 2013 WARNING: potential route subnet conflict between local LAN [192.168.1.0/255.255.255.0] and remote VPN [192.168.1.0/255.255.255.0]     Fri Jan 18 17:01:49 2013 Initialization Sequence Completed          Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:10 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)     Fri Jan 18 17:04:12 2013 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)          Fri Jan 18 17:07:11 2013 [VPN_HOST_NAME] Inactivity timeout (--ping-restart), restarting     Fri Jan 18 17:07:11 2013 SIGUSR1[soft,ping-restart] received, process restarting     Fri Jan 18 17:07:13 2013 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables     Fri Jan 18 17:07:13 2013 Re-using SSL/TLS context     Fri Jan 18 17:07:13 2013 UDPv4 link local: [undef]     Fri Jan 18 17:07:13 2013 UDPv4 link remote: [AF_INET]VPN_IP_ADDY:1194     Fri Jan 18 17:07:14 2013 [VPN_IP_ADDY] Peer Connection Initiated with [AF_INET]VPN_IP_ADDY:1194     Fri Jan 18 17:07:17 2013 Preserving previous TUN/TAP instance: tun0     Fri Jan 18 17:07:17 2013 Initialization Sequence Completed      It then auto reconnects and 5-10min later it repeats this cycle forever. It times out even though I'm running a rsync transfer over the VPN. The timeout and reconnect does not effect the rsync transfer except stalling it for 30s. Clients do not notice except that file transfers will stop for 30s while it attempts to reconnect. I'm using in my server config 'keepalive 10 120'. I also tried 'keepalive 1 180' which made no difference. I think the connection refused errors are the keepalive ping attempts?


title: USB Driver Compilation Error

text: I'm currently trying to compile a Linux USB UART driver, which is provided here: http://www.exar.com/connectivity/uart-and-bridging-solutions/usb- uarts/xr21v1410 The driver consists of 2 header files and one large C file. These are the contents of the Makefile:               obj-m := vizzini.o          KERNELDIR ?= /lib/modules/$(shell uname -r)/build     PWD       := $(shell pwd)          EXTRA_CFLAGS    := -DDEBUG=0          all:         $(MAKE) -C $(KERNELDIR) M=$(PWD)          modules_install:         $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install          clean:         rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty      This is the error the compiler is throwing when I run make:               [sj755@localhost xr21v141x-lnx-2.6.35-pak]$ make     make -C /lib/modules/3.4.9-2.fc16.x86_64/build M=/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak     make[1]: Entering directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'       LD      /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/built-in.o       CC [M]  /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: initialization from incompatible pointer type [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: (near initialization for ‘vizzini_device.ioctl’) [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: initialization from incompatible pointer type [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: (near initialization for ‘vizzini_device.tiocmget’) [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: initialization from incompatible pointer type [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: (near initialization for ‘vizzini_device.tiocmset’) [enabled by default]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘vizzini_init’:     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1663:9: error: implicit declaration of function ‘usb_serial_register’ [-Werror=implicit-function-declaration]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1677:9: error: implicit declaration of function ‘usb_serial_deregister’ [-Werror=implicit-function-declaration]     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘__check_debug’:     /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1698:83: warning: return from incompatible pointer type [enabled by default]     cc1: some warnings being treated as errors     make[2]: *** [/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o] Error 1     make[1]: *** [_module_/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak] Error 2     make[1]: Leaving directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'     make: *** [all] Error 2      These are the headers included in the main c source file:               #include <linux/kernel.h>     #include <linux/jiffies.h>     #include <linux/errno.h>     #include <linux/tty.h>     #include <linux/tty_flip.h>     #include <linux/module.h>     #include <linux/usb.h>     #include <linux/usb/serial.h>     #include <linux/serial.h>     #include <linux/slab.h>     #include <asm/unaligned.h>     #include <asm/uaccess.h>          #include <linux/usb/cdc.h>     #ifndef CDC_DATA_INTERFACE_TYPE     #define CDC_DATA_INTERFACE_TYPE 0x0a     #endif     #ifndef USB_RT_ACM     #define USB_RT_ACM      (USB_TYPE_CLASS | USB_RECIP_INTERFACE)     #define ACM_CTRL_DTR            0x01     #define ACM_CTRL_RTS            0x02     #define ACM_CTRL_DCD            0x01     #define ACM_CTRL_DSR            0x02     #define ACM_CTRL_BRK            0x04     #define ACM_CTRL_RI             0x08     #define ACM_CTRL_FRAMING        0x10     #define ACM_CTRL_PARITY         0x20     #define ACM_CTRL_OVERRUN        0x40     #endif          #include "linux/version.h"          #include "vizzini.h"      Running Linux kernel 3.4.9-2.fc16.x86_64 I would greatly appreciate any help in resolving the errors.


title: Missing 32 bit library on a 64 bit Linux install

text: I am trying to figure out why Eclipse is complaining about being unable to find a library. I've managed to reproduce/reduce the java problem to:               $ ldd /home/jhendrix/.swt/lib/linux/x86/libswt-pi-gtk-3833.so             linux-gate.so.1 =>  (0xf76fa000)             libgtk-x11-2.0.so.0 => not found             libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0xf7674000)             libXtst.so.6 => not found             libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74c9000)             libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xf73cd000)             /lib/ld-linux.so.2 (0xf76fb000)             libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xf738d000)             libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7372000)             librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf7368000)      And indeed java is complaining about being unable to locate `libgtk-x11-2.0.so.0`. But when I check `ldconfig`, the library is right there:               $ sudo ldconfig -v 2>&1 | grep -E '(libgtk-x11-2.0.so.0|libXtst.so.6)'             libXtst.so.6 -> libXtst.so.6.1.0             libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.13      I suspect it has something to do with running a 64 bit system, running a 32-bit customized Eclipse build (Texas Instruments Code Composer 5):               $ locate libgtk-x11-2.0.so.0 libXtst.so.6     /usr/lib/x86_64-linux-gnu/libXtst.so.6     /usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0     /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0     /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.13      I think the question is: How can I install the 32 bit version for this library on a 64 bit Ubuntu 12.10? And secondary: Is it likely this will solve the problem?


I regularly read development updates from various components of the Linux ecosystem. Of all these, the kernel is the one that seems least transparent to me. Typical kernel release notes mention tons of new and upgraded drivers, filesystem work (such as the ever-experimental `btrfs`), occasional network stack adjustments (such as the recent reworking of the firewall and iptables architecture) and many minor changes. **What I'm missing here is the _big picture_.** Where is Linux kernel development headed? What large-scale architectural changes are on the roadmap (is there even a published roadmap?)? What hardware platforms does the focus lie on (servers, Android, embedded)? Is there a slow shift from a monolithic to a hybrid kernel architecture? What other major changes are on the horizon? How can I keep up with those plans to get a rough idea of how the Linux kernel might look like in six months, in two years? Given the huge importance of Linux to the world of computing, I am certain that such long-term plans must exist somewhere.


title: How come crontab -e is different from less /etc/crontab?

text: Im pretty new to unix and crons, I was currently about to try to add crons to an existing cron file. I read you could do this with `crontab -e`. The confusing thing to me is just that `crontab -e` shows different crons/commands than `less /etc/crontab` - how come? Which one is the correct way/file to edit?


title: Why using cat on binary files messed up the terminal and how?

text: If I understand correctly the `cat` manual: > concatenate files and print on the standard output `cat` will take files as argument and print them on standard output.   What I don't get is if I use the command               cat img.png > copy.png      I will obtain 2 png files identical while if I just               cat img.png        I have all chance that my terminal get messed up and misinterpret what I type. How's that possible ?   Binary value are still binary data why it does not simply shows a series of 0 and 1 or the interpretation of those binary data in ASCII or whatever the encoding in terminal is ?   Is this behavior also possible by `cat`ing a text file containing strange characters ? ### Edit 1: Should a mechanism to prevent this behavior like try{}catch{} statement should be implemented ?


title: Xen / Grub2 - Domain 0 allocation causes boot panic

text: Current setup / versions :   * Ubuntu Desktop 12.04   * Linux 3.2.0-32   * Xen 4.1-amd64   * Grub2 After following the documentation to set up xen-hypervisor-amd64 and configuring grub2, when I reboot I get the below error:               (XEN) ********************     (XEN) Panic on CPU 0:     (XEN) Domain 0 allocation is too small for kernel image.     (XEN) ********************      My current /etc/default/grub               GRUB_DEFAULT="Xen 4.1-amd64"     GRUB_TIMEOUT=10     GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`     GRUB_CMDLINE_LINUX_DEFAULT=""     GRUB_CMDLINE_LINUX=""     GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=1024M"      Which results in the following menuentry after `update-grub`               submenu "Xen 4.1-amd64" {     menuentry 'Ubuntu GNU/Linux, with Xen 4.1-amd64 and Linux 3.2.0-32-generic' --class ubuntu --class gnu-linux --class gnu --class os --class xen {             insmod part_gpt             insmod ext2             set root='(hd0,gpt3)'             search --no-floppy --fs-uuid --set=root dfeb1395-8583-4bed-bc97-8f2317a7e9dd             echo    'Loading Xen 4.1-amd64 ...'             multiboot       /boot/xen-4.1-amd64.gz placeholder  dom0_mem=1024M             echo    'Loading Linux 3.2.0-32-generic ...'             module  /boot/vmlinuz-3.2.0-32-generic placeholder root=UUID=dfeb1395-8583-4bed-bc97-8f2317a7e9dd ro               echo    'Loading initial ramdisk ...'             module  /boot/initrd.img-3.2.0-32-generic     }      I have tried just about every possible `dom0_mem=` value that I can think of including but not limited to: `dom0_mem=2097152`, `dom0_mem=min:1024M,max:1024M`, moving the entry to the vmlinuz module, and including it in the follow-up linux menuentry. I don't know what to try next. Any help is greatly appreciated. * * * With the addition of `dom0_max_vcpus=2`               multiboot /boot/xen-4.1-amd64.gz placeholder dom0_mem=1024M dom0_max_vcpus=2      I get the same boot panic. But interestingly in the info displayed at boot it continues to display "Brought up 4 CPUs". Thanks again for any help!


title: exec() and system() system calls

text: I do understand that while exec() does not return after it executes in Unix ,system() may or may not return depending on the situation.But can anyone explain why exec() system call does not return and also the differences between exec() and system() in Unix operating system


title: How to extract values from a file using pattern(s) from a column in another file, and insert such values as a new column to the latter?

text: I sample "winning" sets of 60 game cards such as this one and extract the card _names_ and _count_ and format it for use with some software. The output _format_ is: > .<ID><tab> _count_ <tab> _name_ _Step 1_ I start with the text version of the set using the link provided on the page(next to _print_ ) and keep the data(2 columns separated by a space) removing the _Sideboard_ cards. _Step 2_ For each card name, I search a local `list` file containing a list of cards properties separated by semicolons and match the card name on the second field to extract the first field which is the _ID number_ for the corresponding card(lines were shortened here as only the first fields matter):               ID;Full Name;...     0;Air Elemental;1;Air Elemental;0800h;;;;;;;     1;Ancestral Recall;1;Ancestral Recall;0800h;;;;;;;;     2;Animate Artifact;1;Animate Artifact;0800h;;;;;;;     ...         10780;Jace, the Mind Sculptor;1;Jace, the Mind Sculptor;0008h;;;;;;;;     10871;Aura Finesse;0;Aura Finesse;0008h;;;;;;;      ...I then prefix each line from _step 1_ with _.ID_ , making sure the 3 columns are separated with a tabulation. The final _output_ file looks like this(I'm not concerned with the header part):               ;MY1 - Shardless BUG - #1     ;     ;User     ;User E-Mail     ;28/08/2014     ;1     ;4th Edition     ;          .12516  2   Baleful Strix     .12533  4   Shardless Agent     .12700  4   Deathrite Shaman     .9038   4   Tarmogoyf     .10780  2   Jace, the Mind Sculptor     .12004  2   Liliana of the Veil     .12     2   Bayou     .10747  2   Creeping Tar Pit     .12645  4   Abrupt Decay     .1547   4   Brainstorm     .2285   3   Force of Will     .1456   1   Hymn to Tourach     .13650  1   Toxic Deluge     .9286   3   Thoughtseize     .239    1   Swamp     .1486   4   Polluted Delta     .258    3   Underground Sea     .10706  4   Verdant Catacombs     .3329   2   Wasteland     .1      4   Ancestral Recall     .10612  2   Misty Rainforest     .252    2   Tropical Island      Considering the aforementioned source _text_ file and the `list` file, how can produce the output file with the required _format_?


title: How much space for /home on a hadoop cluster?

text: What is a reasonable size to provide for a /home partition for 100 users on a hadoop cluster? Assume that a landing zone has been provided to store files/data for ingestion into the cluster, so the /home partition would be non-project type storage.


title: How do I route bittorrent through a second interface?

text: I've managed to configure openvpn on my DD-WRT router such that the tunnel is up and working, but that it doesn't mess with routes at all (the default configuration wants all traffic to go through it). I would like to port forward port 51413 on tun1 to a specific host on my network (192.168.77.145). I also need to masquerade ports 6881-6890 so that they are routed through tun1. I know this involves packet mangling/marking, and setting up routes manually as well, but it's been 12 years since I've even thought about iptables (I think I still had dialup at the time). Is there some recipe out on the internet somewhere that I'm not stumbling over? [edit] I've been experimenting with tcpdump, and it appear that the client I use (Transmission on OSX) has a curious feature: it uses 51413 (user configurable) as the source port for all outgoing packets, and as the destination for all incoming packets. Even when I look for port 6881-6889 in tcpdump, those are always the source port for the remote end, and it's always being sent to the 51413. So this is a rather simpler than I imagined it would be. I just need to route/masquerade anything with that src port number through the tun1 interface. I think that the iptables rules might be something like the following:               # mark bittorrent packets     iptables -t mangle -A OUTPUT -p udp --sport 51413  -j MARK --set-mark 7     iptables -t mangle -A OUTPUT -p tcp --sport 51413  -j MARK --set-mark 7          # allow responses     iptables -A INPUT -i tun1 -m conntrack --ctstate ESTABLISHED -j ACCEPT          # allow bittorrent     iptables -A INPUT -i tun1 -p udp --dport 51413 -j ACCEPT     iptables -A INPUT -i tun1 -p tcp --dport 51413 -j ACCEPT          # block everything incoming on vpn     #iptables -A INPUT -i tun1 -j REJECT          # masquerading     iptables -t nat -A POSTROUTING -o tun1 -j MASQUERADE      Do these look sane? Still no clue on the routing rules. [edit 2] I think -A is wrong, as this appends it to the end of the iptables rules. My router is adding god-knows-what first, and if those rules match, these are ignored. I'm pretty sure they should all be -I. Even with that change though, I'm unable to get anything to work. The packets show up on my private network on br0, the bridge interface. If I change nothing, DD-WRTs configuration will do NAT out over vlan2. And of course, OpenVPN's interface is tun1 (the interface I want to send bt traffic through). [edit 3] The initial two iptables statements are wrong. I was working off of examples where the author was using his desktop machine as a router (I think), and so this is different than a desktop machine that sends packets over a local network to a router with two external interfaces. The correct set of statements is something like this:               # routing table setup     ip route replace default via $VPNGW dev tun1 table 100     ip rule add fwmark 7 table 100          # mark bittorrent packets     iptables -t mangle -I PREROUTING -p udp --sport 51413 -j MARK --set-mark 7     iptables -t mangle -I PREROUTING -p tcp --sport 51413 -j MARK --set-mark 7          # allow responses     iptables -A INPUT -i tun1 -m conntrack --ctstate ESTABLISHED -j ACCEPT          # allow bittorrent     iptables -A INPUT -i tun1 -p udp --dport 51413 -j ACCEPT     iptables -A INPUT -i tun1 -p tcp --dport 51413 -j ACCEPT          # block everything incoming on vpn     iptables -A INPUT -i tun1 -j REJECT          # masquerading     iptables -t nat -I POSTROUTING -o tun1 -j MASQUERADE      This still isn't perfect. The bulk of bt traffic now goes over tun1, but I continue to see incoming packets for 51413 on vlan2. It's unclear to me why this is happening.