Make Compose not compose after certain key presses

On my laptop, I use the `Win` as a modifier. With the `Fn` key pressed, the key sends a different keysym and I use that as a Compose key.               keycode 133 = Hyper_L     keycode 134 = Multi_key     add mod4 = Hyper_L      I have some window manager key bindings of the form `Hyper`+`KP_ _N_`. On a laptop, this requires pressing and holding `Win`, then pressing and holding `Fn`, then pressing `KP_ _N_` and finally releasing everything. If I press `Fn` before `Hyper`, this sends the `Multi_key` keysym instead of `Hyper_L`, so I'm pressing Compose. I find the finger coordination required to press `Fn` before `Hyper` to be a lot less, so I'd like to be able to do that. If I then press a keypad key (which requires `Fn`), I want the key press to be interpreted as the `mod4` modifier instead of `Multi_key`. I can add the `mod4` modifier to the `Multi_key` keysym, and this makes my window manager bindings work when I press `Fn` and `Hyper` in either order. However, if I press `Fn` first (which is how it happens naturally), this records a `Multi_key` keysym, so a key sequence like `Fn`+`Hyper`+`KP_1`, `a`, `'` ends up switching to workspace 1 and inserting `á` instead of `'a`, because the application that is focused after the keyboard shortcut activates receives a key release event for `Multi_key`. How can I have my cake and eat it?   * If I press `Hyper` and `Fn` in either order, then press a keypad key, this should only trigger my window manager binding and not leave a pending `Compose`. Either the application should not receive a key release event for `Multi_key`, or it should receive another event (injected by the window manager) that will effectively cancel the first one.   * If I press and hold `Fn` and press `Hyper`, then release them both, this should send a press and release event for `Multi_key`. I don't mind whether this is done through a change of my keyboard configuration, or of my window manager bindings, or both. The window manager is sawfish, so it's pretty flexible. If the solution involves XKB, I don't want to define my whole keyboard configuration through XKB. The XKB part should focus on defining a group for the affected keys (or whatever it takes).


forward outgoing traffic port using iptables

I am trying to forward all outgoing traffic from port 80 to port 8080 using `iptables` and I tried the following rule, though it did not work:               iptables -t nat -A OUTPUT -p tcp --dport 80 -j  REDIRECT --to-port 8080      Also, for incoming traffic I need a rule that forward port on the same host not to be as proxy.


Extract file name from path in awk program

I have an awk script and I have passed a CSV file to it.               awk -f script.awk /home/abc/imp/asgd.csv      What am I doing is to get FILENAME within `script.awk`. FILENAME gives me the whole path. As I am in awk I cannot use `basename FILENAME`.               print FILENAME;     /home/abc/imp/asgd.csv      I have tried with this within `script.awk`               echo $FILENAME | awk -F"/" '{print $NF}'      but I cannot execute this within `script.awk`. How can I get `asgd.csv` within an awk program?


Kioptrix Level 1: Determining IP information for eth0 failed

I'm trying to set up a Kioptrix VM in VMware Player, in order to analyze it from a separate VM using Kali Linux. The VM can be found on this page: http://www.kioptrix.com/blog/test-page/ When booting Kioptrix Level 1, it fails to set up its `eth0` interface with the following error message: > Determining IP information for eth0… failed I've checked the VM's MAC address and it hasn't been changed from the one in the original downloaded archive (I have noticed that this was a potential issue when searching for answers to my problem). The network adapter from this VM is set to bridged by default. I have also tried setting it to use NAT but to no avail. Moreover, by booting a third Ubuntu 12 VM (and configuring its connection to use NAT), I can ping it from Kali and vice-verse just fine. The host OS is an x64 Windows 8 machine. What could be causing Kioptrix to fail to start up its network interface?


GCC (toolchain) for Ralink SoC - ELF not found and syntax error

I bought a Chinese P2P camera and there was no MJPEG stream, so I wanted to compile `mjpg-streamer` for it. Here's my CPU's info:               # cat /proc/cpuinfo      system type             : Ralink SoC     processor               : 0     cpu model               : MIPS 24K V4.12     BogoMIPS                : 239.61     wait instruction        : yes     microsecond timers      : yes     tlb_entries             : 32     extra interrupt vector  : yes     hardware watchpoint     : yes     ASEs implemented        : mips16 dsp     VCED exceptions         : not available     VCEI exceptions         : not available          # uname -a     Linux (none) 2.6.21 #878 Tue Oct 29 09:53:25 CST 2013 mips unknown      I tried to use Sourcery CodeBench for MIPS GNU/Linux (latest version) and attempted to compile a simple 'Hello world' example with this command:               $ mips-linux-gnu-gcc -Wall hello.c -o hello      After execution I received the following message:               # ./hello      ./hello: line 1: ELF@04: not found     ./hello: line 2: syntax error: "(" unexpected      Next I tried to recompile with this command:               $ mips-linux-gnu-gcc -mips16 -Wall hello.c -o hello      But the result was:               # ./hello      ./hello: line 1: syntax error: "(" unexpected        * Am I using the wrong compiler, if so which is the correct one?   * Am I missing or using the wrong arguments? **EDIT:**               $readelf -h HKIPC #Extracted file from the device     ELF Header:       Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00        Class:                             ELF32       Data:                              2's complement, little endian       Version:                           1 (current)       OS/ABI:                            UNIX - System V       ABI Version:                       0       Type:                              EXEC (Executable file)       Machine:                           MIPS R3000       Version:                           0x1       Entry point address:               0x406420       Start of program headers:          52 (bytes into file)       Start of section headers:          643764 (bytes into file)       Flags:                             0x10001007, noreorder, pic, cpic, o32, mips2       Size of this header:               52 (bytes)       Size of program headers:           32 (bytes)       Number of program headers:         6       Size of section headers:           40 (bytes)       Number of section headers:         25       Section header string table index: 24          $file HKIPC      HKIPC: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked (uses shared libs), stripped      -               $readelf -h hello #Compiled with mips-linux-gnu-gcc -mips2 -EL -mabi=32 hello.c  -o hello     ELF Header:       Magic:   7f 45 4c 46 01 01 01 00 01 00 00 00 00 00 00 00        Class:                             ELF32       Data:                              2's complement, little endian       Version:                           1 (current)       OS/ABI:                            UNIX - System V       ABI Version:                       1       Type:                              EXEC (Executable file)       Machine:                           MIPS R3000       Version:                           0x1       Entry point address:               0x400430       Start of program headers:          52 (bytes into file)       Start of section headers:          2732 (bytes into file)       Flags:                             0x70001005, noreorder, cpic, o32, mips32r2       Size of this header:               52 (bytes)       Size of program headers:           32 (bytes)       Number of program headers:         8       Size of section headers:           40 (bytes)       Number of section headers:         34       Section header string table index: 31          $file hello     hello: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped


Changing permission from read only in linux?

I am trying to get the automatic brightness bug fixed in Linux Mint 17 based on the new Ubuntu release. In order to do this i had to create a file named                   20-intel.conf      in location                   /usr/share/X11/xorg.conf.d      but this file and every other file in this directory has read only permissions on it. How do I change this permission to at least this file so that I can edit it?


Anyway to use HTTP Authentication with Axel Downloader?

Is there anyway to use http authentication with axel downloader? I don't want to use another solution such as aria2c because they don't support more than 16 concurrent connections.


Daylight saving option on Linux servers

My CentOS server is not updating showing correct time. I have set               $ ln -sf /usr/share/zoneinfo/Europe/London  /etc/localtime      Still I am on GMT. I do see the following entries in `/etc/sysconfig/clock`:               $cat /etc/sysconfig/clock     ZONE="Europe/London"     UTC=true     ARC=false Still it is not showing correct time. NTP is running on this server:               $ ntpq -p     remote           refid      st t when poll reach   delay   offset  jitter     +         IP Address      3 u   42 1024  377    0.476   63.077   0.001     *         IP Address      3 u   53 1024  377    1.183   30.425   0.001 The ntp servers have the correct time. These are Windows Domain Controllers. I have checked out the answer from here http://serverfault.com/questions/267629/configure-centos-with-ntp but that hasn't helped on this case. Any ideas?


Launch 2 celery processes via cron

I'm trying to chain some commands to periodically check/launch two processes via `cron` (I'm on a shared host, can't change things around). After a lot of googling around, all the things I've done don't work properly: Trying to launch them separately in two cron jobs cascades and crushes the server (maybe because the `grep` command doesn't manage to catch the search words because they are parameters, I don't understand):               ps -fu $USER | grep celeryd >/dev/null || $HOME/python27/bin/python $HOME/utilities/manage.py celeryd -E -B --concurrency=1     ps -fu $USER | grep celerycam >/dev/null || $HOME/python27/bin/python $HOME/utilities/manage.py celerycam      And these other variants where I try to launch the processes together on the same `cron`, launch only the first process:               ps -u $USER | grep python >/dev/null || $HOME/python27/bin/python $HOME/utilities/manage.py celeryd -E -B --concurrency=1 & $HOME/python27/bin/python $HOME/utilities/manage.py celerycam &          ps -u $USER | grep python >/dev/null || ( $HOME/python27/bin/python $HOME/utilities/manage.py celeryd -E -B --concurrency=1 & $HOME/python27/bin/python $HOME/utilities/manage.py celerycam; )          ps -u $USER | grep python >/dev/null || ( $HOME/python27/bin/python $HOME/utilities/manage.py celeryd -E -B --concurrency=1; ) sleep 30s; ( $HOME/python27/bin/python $HOME/utilities/manage.py celerycam; )      I gave up trying to use grep and took advantage of the `\--pidfile` option of the `celery worker`; `celerycam` doesn't allow multiple instances so I don't need any `grep` there to check for it:               $HOME/python27/bin/python $HOME/utilities/manage.py celery worker -E -B --concurrency=1 --pidfile=worker.pid     $HOME/python27/bin/python $HOME/utilities/manage.py celerycam


Recover Windows partition in a GPT disk (previously MBR)

I have tried installing Arch Linux and what I ended up with was a partition scheme like this:               /dev/sda:      /dev/sda1  NTFS partition (Windows 7)      /dev/sda2  ext4 (Arch)      /dev/sda3  swap      I don't know why, but for some reason I have been unable to mount the NTFS partition under Linux. It's worth mentioning that the first partition is, for some reason, detected as an EFI partition and as on a GPT-formatted disk (my computer doesn't have an EFI bootloader and the drive has always had an MBR partition table). I deleted the `sda2` and `sda3` using the Windows repair disk and was about to install a second Windows 7 installation alongside the first partition, but an error reported that the entire disk is a GPT drive! The "Used" and "Free space available" sections indicate that the data on the first partition is still there, it's just that I cannot access the actual partition by any means. **It seems that the first partition is with an MBR partition table on a GPT style disk.** How do I access the data on the partition?


How can I mount vxfs FS to two or more Solaris servers?

I want to have two Solaris servers share the same SAN vxfs Filesystem. Though at a time just one would be accessing the share. This is to allow for a quick failover in case the primary server undergoes an unplanned outage for some reason. From the Oracle Solaris Cluster Software Installation Guide, it seems a cluster needs to be setup and VxVM Software needs to be running on both servers to manage the cluster - which seems quite complicated in comparison to simply mounting a NAS share on two or more servers, for creating a shared filesystem. Could someone kindly point me in the right direction?


How can I access the log via a php script?

I have a statistics-file on my apache server on               /var/www/vhosts/test/statistics/logs/access_log      I tried using               echo system('cat /var/www/vhosts/test/statistics/logs/access_log');      in a php script to access it but I get no output.               echo system('dir');      gives the expected dir output.               cat /var/www/vhosts/test/statistics/logs/access_log      using a putty connection and as root works though. How can I access the log via the php script?


How to see that what disks are on a QLogic FC adapter on linux?

So that example I can check:               lrwxrwxrwx 1 root root   9 Jul 23 11:20 scsi-3600508e000000000XXXe71e04ffYYY0f -> ../../sda     lrwxrwxrwx 1 root root  10 Jul 23 11:20 scsi-3600508e000000000XXXe71e04YYY1f0f-part1 -> ../../sda1     lrwxrwxrwx 1 root root  10 Jul 23 11:20 scsi-3600508e000000000XXXe71e04fYYYf0f-part2 -> ../../sda2     lrwxrwxrwx 1 root root   9 Jul 23 14:15 scsi-360080e5000230fc0000001ca4XXX8e06 -> ../../sdd     lrwxrwxrwx 1 root root   9 Jul 23 14:15 scsi-360080e500023139c000001cf4dXXXe68 -> ../../sde      that sda is a physical RAID disk and the other two is FC.


Can I reload variable in a watch command?

Part of my job involves some data handling. One of the tasks is to 'flatten' a set of directories (which we'll call _Dir_ for now), and copy them to a new location called DirFlat. This can take a long time (30 minutes ->2-3 hours)! I'd like to be able to watch the progress, so I use `find Dir -type f|wc -l` to get the number of files (lets call this `$Filenum`, and then I run a very short command that I wrote (retyping from my notebook, may have copied it wrong, I hope you get the gist): `echo $(echo "($ls DirFlat |wc -l)*100/$FileNum"|bc) "%" $(date)` However, if I run `watch -n 100 "!!"` it takes the output of the echo, and keeps printing that (even the date doesn't change). Can I get this to refresh the variable/re-run the assignment of the internal variables in BASH? Hopefully this will help me in automating some of my tasks.


What does the Virtual kernel Memory Layout in dmesg imply?

While going through the **"Output of dmesg"** I could see a list of values which i am not able to understand properly.               Memory: 2047804k/2086248k available (3179k kernel code, 37232k reserved, 1935k data, 436k init, 1176944k highmem)     virtual kernel memory layout:         fixmap  : 0xffc57000 - 0xfffff000   (3744 kB)         pkmap   : 0xff800000 - 0xffa00000   (2048 kB)         vmalloc : 0xf7ffe000 - 0xff7fe000   ( 120 MB)         lowmem  : 0xc0000000 - 0xf77fe000   ( 887 MB)           .init : 0xc0906000 - 0xc0973000   ( 436 kB)           .data : 0xc071ae6a - 0xc08feb78   (1935 kB)           .text : 0xc0400000 - 0xc071ae6a   (3179 kB)      From the values i understand that i have 2GB RAM(Physical memory). But rest of the things seems to be Magic Numbers for me. I would like to know about each one (fixmap, pkmap,.. etc.) in brief(if more doubts, I will post each one as a separate Question)? Could someone explain that to me?


How do you make samba follow symlink outside the shared path

This is ubuntu server 10.04 64 and samba 3.4.7 I have a shared directory /home/mit/share and another one /home/temp that I link into the shared one:               ln -s /home/temp /home/mit/share/temp      But on windows, after net use'ing I cannot open S:/temp, on linux it is possible to access /home/mit/share/temp like expected. This works if I link directories inside /home/mit/share/temp, so I guess samba is restricting to jump with a link outside/above the shared directory. EDIT: See also this question: http://superuser.com/questions/128716/ubuntu-latest- samba-version-symlinks-no-longer-work-on-share-mounted-in-windo It seems best to put `unix estensions = no` into the global section and `follow symlinks = yes` and `wide links = yes` only into the shares section, where you really need it. The `unix extension` flag has to live in the global section and not in the individual shares sections. But for security reasons it is better to use the other options only where you need it, and not globally.


How to backup all installed software/packages on AIX?

Are there any ways to backup all the packages on an AIX 6.1 machine?


Linux webcam software

What are some good full-featured (whatever that means) webcam applications in linux. I know about cheese, but found some of its features lacking. Are there any others?


What's the name of the technology that instantly boots to Linux from within Windows?

I once had some package that you could run to instantly replace a running Windows instance with a running Linux instance. I'm not talking about virtualization or coLinux. I'm talking about the moral equivalent of hot- swapping out the Windows kernel and replacing it with a Linux kernel. It may have only worked on Win9x for all I can remember. But I haven't been able to think of the name or find it since I happened upon it many years ago.


Is it possible to define where the .bash_profile is located on the bash command line?

I'm running bash programmatically from objective c to create a terminal-like application. Once launched I would like to execute some commands prior to turning control over to the user. Normally these would be in the `.bash_profile`. This file is not accessible to me and not something I would want to mess we anyway as I don't want to effect the standard bash environment for the user. I tried the `-c script.sh` switch but after script.sh is done running, bash exits. Are there any other options I have other than programmatically typing out the command I need run? I would rather not have the user see everything.


Cut on both characters and field

I have a record like :               2011-05-29 17:51:34 => 'HS|CMGC|RN431|CI13950|CH7-4a37-afe2-acabfc9d262d|DA110529|TI175133|'      I want my final output to be something like:               2011-05-29 17:51:34  CI13950      I can get each part using cut like this:               $ cut -c 1-19     2011-05-29 17:51:34     $ cut -d  '|' -f 4     CI13950      I am unable combine the two as:               $ cut -c 1-19 -d  '|' -f 4     cut: only one type of list may be specified      Any suggestions?


ls outputs multiple columns even if piped to grep with grml's zsh config

I just decided to give zsh a go against Bash and came across some unhandy behaviour about which I couldn't find anything on the net: If you do a `ls | grep foo` in Bash, the `ls` only contains one file per line so that `grep` only outputs the matching files. It seems like somewhere (and since I couldn' find anything in the config I think it must be the Bash code itself), the `-1` option is passed to `ls`.   zsh however doesn't do that magic: If you pass `ls` without further options to `grep`, it does just that and you also get result's which coincidentally appeared on the same line as a match. My idea to achieve the Bash behaviour in zsh would have been to detect whether a `ls` output will be piped into `grep` and define something like an alias for such cases. But I'm not sure how and if that's possible at all. **Update:** As larsks points out below, Bash doesn't do anything special here and it's really `ls` which is supposed to work that way if the output doesn't go to a terminal. Nevertheless, here's what happens to me:               > ls     a  b  c  d  e  f  g  h          bash$ ls | grep b     b          zsh> ls | grep b     a  b  c  d  e  f  g  h      I've been able to reproduce that on Ubuntu 11.10 with zsh 4.3.11 and GNU coreutils 8.5 as well as on a Debian Squeeze machine with zsh 4.3.10. **Update 2:** While investigating a bit more, I found out that this error only appears when the grml .zshrc is active. There must be something in there which which opens a terminal for the output if it is piped. Does anybody know what to look for?


Do I need root (admin) permissions to run userspace 'perf' tool? (perf events are enabled in Linux kernel)

Do I need to have to run `perf` userspace tool as system administrator (root), or can I run it (or at least some subcommands) as an ordinary user?


CutyCapt seems to ignore the Xvfb screen size parameters

I have a problem using CutyCapt to create images rendered for a particular screen size. For example, if I do these:               xvfb-run --server-args="-screen 0, 800x600x24" \       ~/bin/CutyCapt/CutyCapt --url='http://stackoverflow.com/search?page=2&tab=relevance&q=cutycapt%20xvfb' \         --out=STACKOVERFLOW_1.png     xvfb-run --server-args="-screen 0, 800x600x24" \       ~/bin/CutyCapt/CutyCapt --url='http://stackoverflow.com/questions/65078/what-is-the-best-way-to-create-a-web-page-thumbnail' \         --out=STACKOVERFLOW_2.png      I get images of sizes:               STACKOVERFLOW_1.png : 975x2611     STACKOVERFLOW_2.png : 975x2226      I believe any stackoverflow page will be of a width of 975 pixels. This is not what I asked (w=600). Is it possible to create images using CutyCapt with Xvfb that are rendered for a particular screen width? PS: `uname -a` yields `Linux yalabs-linux0.yandex.net 2.6.27-17-server #1 SMP Fri Mar 12 02:48:52 UTC 2010 x86_64 GNU/Linux`


How can I find out what keys gpg-agent has cached? (like how ssh-add -l shows you cached ssh keys)

`ssh-add -l` shows you all ssh-keys that have been added with `ssh-add ~/.ssh/id_yourkey`. How do I do the analogous thing with gpg and gpg-agent, in other words, ask it to show a list of cached keys?


Modifying resolv.conf when when bringing network interface up on system startup

My Linux box currently has a network interface that allows me to connect to a network on a different subnet. I've achieved this by modifying the routing table when the network interface is brought up. The 'remote' network also has a DNS server so I want to add that to my /etc/resolv.conf file when the interface enabled. My `/etc/network/interfaces` file currently has the following:               # Secondary network interface (using NAT)     allow-hotplug eth1     iface eth1 inet dhcp             post-up route add -net 172.16.0.0 netmask 255.255.255.0 gw 10.0.3.2             post-up echo 'Up and running...' >> /home/sysadmin/net-result.txt; date >> /home/sysadmin/net-result.txt             post-up sed -i '1inameserver 172.16.0.1' /etc/resolv.conf             post-down sed -i '/^nameserver 172.16.0.1/d' /etc/resolv.conf      (The line `post-up echo...` is just there to prove that the commands are being run and that they have access to the file system.) This works fine when I use `ifup eth1` and `ifdown eth1` from the command line to control the interface. The line `nameserver 172.16.0.1` appears (and disappears) in `/etc/resolv.conf` as expected. However, it's not working on system startup for some reason. The `route` command _is_ being executed (because I can see the modifications in the routing table) and the `/home/sysadmin/net-status.txt` file is also being modified as expected, but `/etc/resolv.conf` does not change. I can't work out what the problem is. Does anyone have any suggestions? (The Linux box is actually a virtual machine, and the remote network is accessed via a VPN, but I don't think either of these details really have a bearing on the problem in this context.)


Trying to install gearman on CentOS, and ./configure cannot find event.h even though libevent is installed

I'm trying to compile and install gearman onto a CentOS 6 box, and am getting an error when I compile from its source code. It requires the boost libraries, and was failing on that at first, but I installed those and it gets past that. Now, however, when I run ./configure it is failing with the message:               . . .     checking for ld that supports -Wl,-z,relro... yes     checking event.h usability... no     checking event.h presence... no     checking for event.h... no     configure: error: Unable to find libevent      So I installed libevent like so:               yum install libevent.i686      And that didn't help. So I downloaded the source to my home directory, extracted it to a sub directory within my home directory, ran `./configure` and then `make install` and then tried `./configure` on the gearman source, but it still gives me the `configure: error: Unable to find libevent` message. You can imagine how annoying that is! Especially after I tried installing libevent via yum and then installed it from source. Any tips to get gearman ./configure to get past this message? Thanks!


How can I see which package manager is running?

I'm on Debian 6.0.5 (squeeze) and every now and then I see the following icon in the notifications area of the GNOME2 pannel: ![enter image description here](http://i.stack.imgur.com/hFHrj.png) but black instead of red. It reads **_A package manager is working._** Usually it just displays the red one after a few seconds, which is _Available updates_ , so I assume it was just looking for updates. But sometimes that's not the case. I don't have the option to auto-install updates so that's probably not it, so I was wondering if there's a way to see which package manager is running. Clicking on it just opens Synaptic Package Manager, but it does not says what's running.


2.6.35 armel header files?

Debian does not seem to include a package linux headers 2.6.35-9 for the armel chipset - compiling drivers work, but insmod, and insmod -f is failing with a version mismatch and invalid moduel format. Could anyone point me to the debian linux headers for 2.6.35-9 please?


How come zipping a created disk image, makes smaller files than piping?

Case 1. I use `dd` to create an image:               dd if=/dev/rdiskx of=/path/to/image bs=1m.       It's 16 GB in size. I zip it, and it's suddenly around 100 MB. Case 2. I use `dd` to create an image, piping it through gzip:                dd bs=1m if=/dev/rdiskx | gzip > image.gz.       It's 11 GB in size. How come, and is there anything I can do about it?


Which Linux distro has a first-class KDE desktop experience and is stable and simple?

I am using Ubuntu 12.04 currently and I love it for: It just works for all hardware Wide selection of packaged applications that are configured by `dpkg` scripts Painless configuration for what matters (Wifi and wired connections, extra screens, power saving) Very easy to install proprietary software I want to switch to a KDE-based distros. But most choices seem to fall among:   1. second-rate KDE experience(not tweaked for anything, no native configuration tools)   2. Against proprietary software, very difficult to configure, brittle to many use cases, unstable (Mageia 2 was one) I considered: Debian: Its stable, but a bit untweaked and not satisfy my need of cutting edge Kubuntu: Unstable, consumes too much CPU * * * I shortlisted Mint which is based on Ubuntu. And Maybe Aptosid. Are there better choices?


PS1 variable no longer shows coloured bash prompt

I'm running a VPS with Centos 6.5 I've setup `~/.bash_profile` as in the following screenshot: ![enter image description here](http://i.stack.imgur.com/o76m6.png) It used to give me an output like this: ![enter image description here](http://i.stack.imgur.com/wvUAC.png) Now that I've installed WHM/Cpanel I no longer see coloured prompt. `echo $PATH` shows:               /usr/local/jdk/bin:/home/jay/perl5/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home/jay/bin      How can I fix this? Can anyone help me? Everything else works according to the configuration. Grep and ls shows coloured outputs. I need this to work as I find it convenient to quickly spot previous commands and outputs.


Make a symbolic link to a relative pathname

I can do this:               $ pwd     /home/beau     $ ln -s /home/beau/foo/bar.txt /home/beau/bar.txt     $ readlink -f bar.txt     /home/beau/foo/bar.txt      But I'd like to be able to do this:               $ pwd     /home/beau     $ cd foo     $ ln -s bar.txt /home/beau/bar.txt     $ readlink -f /home/beau/bar.txt     /home/beau/foo/bar.txt      Is this possible? Can I somehow resolve the relative pathname and pass it to `ln`?


Transition to linux

How does someone with major experience in other OS's make a transition to Linux if one's been using it for a while, on and off for two years. By transition I mean everyday use without booting to something else. How does someone learn some advanced operation skills with shell for everyday use? Note that I'm not asking about the basic skills, I get stuck with other things that are deeply involved with the system itself and can only come with everyday use. I know there are books and sites around that can help, but I guess I'm asking what the easiest way is to do it instantly.


How to reorder a large number of columns?

I'm looking for a pipeable one-liner to reorder a large number of columns (where manually entering the column numbers in e.g. an `awk` command such as `awk '{print $3,$2,$1}'` is not feasible). The order could be given by a sorting scheme (alphabetical, numerical - so like 'sort' but acting on columns rather than rows.) or be arbitrarily given in a text file.


systemd start unit after another unit goes inactive

Is there any way to delay a unit from starting up once another unit goes inactive? I have a startup process (oneshot.service) that runs as a one-shot and sets up the environment for all other processes to utilize and then exits (which makes the service report inactive). However, I want to wait till that process is done before kicking off all the other processes. I was hoping there would be some type of signal or something that other service files could queue off of. Using the "After=oneshot.service" doesn't yield what I want as it will start up other processes before the oneshot.service finishes. A more practical example is having a SNMPD SubAgent delay it's startup until after the SNMPD Agent is up and running... otherwise there is no communication between the Agent and Subagent unless you startup the Subagent an unknown amount of time after the SNMPD Agent is started.


Error "ssh_exchange_identification" with Corkscrew

I'm trying to reach my ssh server (i'm behind a corporate proxy) so I tried to use Corkscrew. My ssh server is listening on port 443, I put `sshd: ALL` in my /etc/hosts.allow and there's nothing into my /etc/hosts.deny. I'm using the following command to launch a ssh session over Corkscrew :               ssh -D991 -p443 user@ssh_server_ip -o"ProxyCommand corkscrew proxy_ip proxy_port %h %p proxy_username proxy_password"      But I get the following error : `ssh_exchange_identification: Connection closed by remote host` I had the same issue when I was trying to use httptunnel (hts) and I wasn't behind a proxy (it was at home for tests). How can I fix that?


How to telnet via proxy authentication?

I am behind a proxy server in my college. It uses a simple username and password authentication. And i connect to the proxy server to port 3128. now i want to telnet simply to say any website on the internet like               $ telnet www.google.com 80      this gives me               error telnet: could not resolve www.udacity.com/80: Name or service not known      How can I define the proxy settings for telnet? I have already set environment variables `http_proxy` and `HTTP_PROXY`. Also have applied system wide proxy.


What provides LSB virtual boot facilities for Debian?

Debian's version of Sysv init uses scripts which reference various LSB "virtual" boot facilities such as `$local_fs` and `$network` as requirements for use by insserv in setting up the boot sequence, but they are not necessarily provided by any `/etc/init.d` script. `/etc/insserv.conf` refers to them to, but only to define what services must "declare the required dependencies of the facility". To me, this would mean that the list of services "must declare the dependencies _of_ the facility", but perhaps it is just a poor choice of words, since looking at an actual `insserv.conf` implies that it actually means this list "must declare the facility _as_ a dependency", which is very different (any clarification of that would be appreciated). It is obvious that things such as `$network` (which seems to refer simply to the possibility of a physical link, i.e., not an actual dhcp lease, etc.) and `$local_fs` would be provided by the kernel during boot, but I cannot find any documentation which explains how they would be considered pre-defined as available or not available by the init system.


Shell script how to read input from a file

I need to read input from a file given in following format.               $ ./process_data.sh arg1 < input_data.txt      How do I read `input_data` in my shell script `process_data.sh`?


Is it possible to redirect X of an ssh session to the display of a connected vncviewer

I have a setup of three machines. Machine `A` runs a vncserver and an ssh server, Machine `B` runs a vncviewer, Machine `C` runs an ssh client. The vncviewer on `B` connects to the vnc server on `A`. The ssh client on `C` connects to the ssh server on `A`. Is it possible that from the ssh session in `C` I spawn a process ( say xclock) on `A` so that the process shows up in the vncviewer on `B`'s screen. Basically I am looking for the value to set DISPLAY variable to so that this can be achieved. PS : Please reword the title of my question if you find that it doesn't appropriately describe my question


find -exec mv stops after first exec

While researching for this question: Find and move directories based on file type and date, I stumbled upon a problem of my own. First I created a bunch of directories with files in them:               seq 10 | while read dir; do       mkdir dir$dir       touch dir$dir/file.txt       seq 5 | while read file; do         touch dir$dir/file${dir}_$file       done     done      Then I tried following find command:               $ find -type f -name "*.txt"     ./dir6/file.txt     ./dir8/file.txt     ./dir10/file.txt     ...      Works as expected. Now with an `-exec`:               $ find -type f -name "*.txt" -exec sh -c 'echo mv -v "${0%/*}" ../bar' {} \;     mv -v ./dir6 ../bar     mv -v ./dir8 ../bar     mv -v ./dir10 ../bar     ...      Works as expected. Now the actual command:               $ find -type f -name "*.txt" -exec sh -c 'mv -v "${0%/*}" ../bar' {} \;     `./dir6' -> `../bar/dir6'      It stops after the first `mv`. No error message. Exit status is 0. The directory `bar` exists and `dir6` is moved correctly. When I execute again this happens:               $ find -type f -name "*.txt" -exec sh -c 'mv -v "${0%/*}" ../bar' {} \;     `./dir8' -> `../bar/dir8'      Again stop after the first `mv`. Exit status is 0. `dir8` is moved correctly. Why does `find` stop after the first `mv`? Because the directory is moved and `find` is confused? Why does it not print an error or return an error exit status? When I create more directories and more files it has the same behaviour. In the question linked above the problem is that `find` executes once without problem but print errors for all matches after that. Is this related? Using `find (GNU findutils) 4.4.2`.


perform remote sqlite command

If this should be moved to the DBA exchange, I apologize. Feels more like linux than DB to me, so here goes: I've got some machines that run scheduled cron jobs every night and email me the output. I do not want emails for things like this. In general I think the way we use email is broken, but that's another story. So I started thinking that I could keep a central SQLite database that stored information about when the jobs started, and finished, and maybe even the output. Then I could just build a webpage that queries that and let's me know was going on last night. So I came up with a simple schema and can run this command at the beginning of a script.               sqlite3 dbname.db "UPDATE data SET LastStart = DATETIME('NOW') WHERE TaskName = 'taskname'"      So now I have a record that states that my job started and at what time. Hooray. Then I can run a similar command to put the time that the job ends. So. That works great if the database and the tasks are on the same machine. I go to another machine and need to update the sqlite database.... How can I do that efficiently? I tried this               ssh aaron@10.1.150.53 'sqlite3 /home/aaron/dbname.db "UPDATE data SET LastStart = DATETIME('NOW') WHERE TaskName = 'taskname'"'      But that returns:               Error: no such column: NOW      I tried some variations but didn't get anywhere. Am I close? Should I be doing something totally different? Am I reinventing the wheel?


How to test the quality of my network connection for VoIP services

Sometimes when using VoIP I experience disruptions. I would like to check if the problems could be caused by my internet provider. How could I best test the quality of my bandwidth (throughput and latency)? Until now, I have used a script which sends 3600 pings per hour and saves min/max/avg., but I am not sure how representative ICMP packets are.


How to combine bash arithmetic with command output?

Suppose you had two commands: First command               let foo=2+2     echo $foo     4      Second command               date "%s"     1377107324      **How would you combine them?** * * * Attempt 1.               echo The epoch time is: `date +%s` in 100 seconds the time \          will be: `let future={date +%s}+100` $future      Attempt 2.               echo The epoch time is: `date +%s` in 100 seconds the time \          will be: `let future=(date +%s)+100` $future      Plus about 30 other similar attempts


Cubian: NAND and Partitions

I have installed Cubian on Cubieboard using SD. After that I moved it to NAND. NAND have 4 Gb memory and I want to leave there only boot, another partitions move to the SD. Maybe leave on NAND something else? But I fear overflow memory when will install more programs. Can I moved partitions and if true how can I do that?


bash equivalent of this use of tcsh "sched" command?

In tcsh, the built-in `sched` command causes a command to be executed by the current shell at a specified time. I have the following `$HOME/.sched` file (this is a simplified version of it):               setenv today `date +%F`     sched +00:01 sched 00:00 source $HOME/.sched      I then `source $HOME/.sched` in my `$HOME/.cshrc`. This sets the environment variable `$today` to, for example, `"2012-06-25"`, and automatically updates it to the current date every night at midnight. The job automatically reschedules itself every time it runs. Note that the `date` command is invoked only once each day, and only when it's needed. Is there a way to do this in bash? Note that the `at` command won't work; it invokes a command externally and cannot affect the current shell's environment. (I know that I can type `$(date +%F)` rather than `$today`, but since I use this interactively, the extra typing is a significant burden.) tcsh also has a number of special aliases that are executed automatically in certain circumstances: > The _beepcmd_ , _cwdcmd_ , _periodic_ , _precmd_ , _postcmd_ , and _jobcmd_ > **Special aliases** can be set, respectively, to execute commands when the > shell wants to ring the bell, when the working directory changes, every > **tperiod** minutes, before each prompt, before each command gets executed, > after each command gets executed, and when a job is started or is brought > into the foreground. Does bash have anything like these?


Why do most distributions chain UEFI and grub?

Most distributions install a additional boot loader on an UEFI system. UEFI itself is a boot loader, it offers a menu to select different operating systems or individual kernels. Furthermore, the UEFI settings can easily be altered with userspace tools like `efibootmgr`. Kernels since 3.3 support EFI_STUB, which means the kernel can be loaded directly from the UEFI. What's the reason distributions decide to use an additional boot loader? Most tutorials on Linux/UEFI focus mainly on how to set up the additional boot loader (rEFInd, grub2, ELILO, etc.) instead of booting Linux with EFI_STUB. The only thing missing in the distributions is support. Since most distributions chain a second boot loader, the kernel is not added to the UEFI boot menu, nor is it copied to the EFI system partition. Three scripts are sufficient to do all the magic. One which copies the initramfs to the ESP. A second one copies kernel to the ESP and creates a new entry in the UEFI boot menu. The third script removes the old kernel and initramfs from the ESP and deletes the UEFI boot menu entry. This allows fully automatised kernel/initramfs updates/purges without user interaction. I am using this approach since more than a year and it has worked flawlessly. Why do most distributions use grub instead of EFI_STUB? Links:   * How to recreate EFI boot partition? EDIT: I'm not talking about removing grub support entirely but to offer a choice for those who want to use it for various reasons. Distributions could provide a package `grub-efi` for those who want to chain UEFI and grub and a package `efistub-boot` which contain the scripts I mentioned above.


What is the difference between .profile and .bash_profile and why don't I have a .profile file on my system?

So I'm pretty new to Linux and recently installed Fedora 19 on my netbook. I want to have a deeper understanding of Linux and the CLI so I'm now reading Learn Linux: The Hard Way. In exercise 3 the author gives the following commands:   * ls -al   * cat .profile I try to follow these instructions but to no avail. There is no .profile file in my user name directory as I can see from ls -al. From what I've learned the .bash_profile and .profile file are practically the same. The only difference I concluded from my research is that .bash_profile gets checked first. What I don't understand is why are there multiple files for the same function in Linux, why is the Author using .profile and not .bash_profile (if I understand correctly .profile won't be read when the system finds .bash_profile first) and how comes that I don't have the .profile file on my system?


How do I iterate the list and copy the files from machineB and machineC efficiently?

I need to scp the files from `machineB` and `machineC` to `machineA`. I am running my below shell script from `machineA`. I have setup the ssh keys properly. If the files are not there in `machineB`, then it should be there in `machineC`.               #!/bin/bash          readonly PRIMARY=/data01/primary/.     readonly FILERS_LOCATION=(machineB machineC)     readonly MAPPED_LOCATION=/bat/data/snapshot     PARTITION=(0 3 5 7 9)          dir1=20131222     dir2=20131222          scp david@${FILERS_LOCATION[0]}:$dir1/weekly_1980_[$el]_200003_5.data $PRIMARY || scp david@${FILERS_LOCATION[1]}:$dir2/weekly_1980_[$el]_200003_5.data $PRIMARY      Now my question is if you take a look into my above scp command, I have `[$el]`, I need to replace this with `PARTITION`, which means I need to iterate `PARTITION` and replace `[$el]` with each number in PARTITION. So my scp command should look like this if I iterate `PARTITION` -               scp david@machineB:/bat/data/snapshot/20131222/weekly_1980_0_200003_5.data /data01/primary/. || scp david@machineC:/bat/data/snapshot/20131222/weekly_1980_0_200003_5.data /data01/primary/.          scp david@machineB:/bat/data/snapshot/20131222/weekly_1980_3_200003_5.data /data01/primary/. || scp david@machineC:/bat/data/snapshot/20131222/weekly_1980_3_200003_5.data /data01/primary/.          scp david@machineB:/bat/data/snapshot/20131222/weekly_1980_5_200003_5.data /data01/primary/. || scp david@machineC:/bat/data/snapshot/20131222/weekly_1980_5_200003_5.data /data01/primary/.          scp david@machineB:/bat/data/snapshot/20131222/weekly_1980_7_200003_5.data /data01/primary/. || scp david@machineC:/bat/data/snapshot/20131222/weekly_1980_7_200003_5.data /data01/primary/.          scp david@machineB:/bat/data/snapshot/20131222/weekly_1980_9_200003_5.data /data01/primary/. || scp david@machineC:/bat/data/snapshot/20131222/weekly_1980_9_200003_5.data /data01/primary/.        1. How do I iterate PARTITION in such a way, so that I can make the above SCP command?   2. And as you can see, I am copying the files one by one into `machineA` `/data01/primary/` folder. Is there any better way of doing this? Meaning, can I copy all the files together in one shot instead of doing it one by one?


The rc0.d,rc1.d,... directories in /etc

I'm running Ubuntu 10.04 LTS where I have the directories `/etc/rc0.d`, `/etc/rc1.d`, `/etc/rc2.d`, ..., `/etc/rc6.d`. Example files from my machine:               directory      example symlinks in the dir     ------------------------------------------     /etc/rc1.d:    K76dovecot, K77ntp     /etc/rc2.d:    S23ntp, S24dovecot     /etc/rc3.d:    S23ntp, S24dovecot     /etc/rc4.d:    S23ntp, S24dovecot     /etc/rc5.d:    S23ntp, S24dovecot      Questions:   1. What's the purpose of the multiple "rc" directories?   2. Why did Ubuntu install duplicates of `dovecot` and `ntp` into all the directories except `rc0.d` and `rc6.d`?   3. If they are specified multiple times like above, are they actually executed multiple times?   4. Can you tell from the above in what order `dovecot` and `ntp` will execute at startup?   5. What is the proper way to tell Ubuntu to always execute `ntp` before `dovecot` at startup?


Download all source files for a webpage

I want to download the source files for a webpage which is a database search engine. Using curl I'm only able to download the main html page. I would also like to download all the javascript files, css files, and php files that are linked to the webpage and mentioned in the main html page. Is this possible to do using curl/wget or some other utility?


Ubuntu eth0 not detected

After installing a new version of this distro, eth0 is not detected automatically. command `inxi -SNxz` result:               Network:   Card-1: Broadcom NetXtreme BCM57786 Gigabit Ethernet PCIe bus-ID: 01:00.0                Card-2: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter driver: ath9k bus-ID: 02:00.0      command `ifconfig -a` result:               lo        Link encap:Local Loopback                 inet addr:127.0.0.1  Mask:255.0.0.0                                                  inet6 addr: ::1/128 Scope:Host                                                       UP LOOPBACK RUNNING  MTU:65536  Metric:1                                             RX packets:1439 errors:0 dropped:0 overruns:0 frame:0                                TX packets:1439 errors:0 dropped:0 overruns:0 carrier:0                              collisions:0 txqueuelen:0                                                                                RX bytes:129263 (129.2 KB)  TX bytes:129263 (129.2 KB)                                                                                wlan0     Link encap:Ethernet  HWaddr 40:f0:2f:30:ba:59                                                                                inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0                                                                                inet6 addr: fe80::42f0:2fff:fe30:ba59/64 Scope:Link               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:502798 errors:0 dropped:0 overruns:0 frame:0               TX packets:287851 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:682169370 (682.1 MB)  TX bytes:26305982 (26.3 MB)      System information detailes:               tux-world@alachiq:~ > sudo uname -a -r     Linux alachiq 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux


Load Linux bzImage in QEMU?

I compiled a Linux by doing `make menuconfig` then `make` and now I have compiled the most recent version of Linux. How can I load the kernel into QEMU?


Library mismatch OpenSUSE 12.3 - totally borked, update gone bad

My workstation at work is OpenSUSE 12.3 KDE. I added the pacman repository to update SVN from 1.7.11 to 1.8.?. Later, I ran zypper update which updates all libraries to the latest "stable" build. Well I think it pulled a lot of packages from the pacman repository because it updated around 1800 libraries. Plus, now when I boot it up it says, "Welcome to OpenSUSE 13.1 (Beta 1)" and it doesn't recognize my network card, the video display a wonky, and eclipse won't start. I get a "pointer xyz not found". Is there a way to reset the libraries without reinstalling? I'm not running brtfs so I have no snapshots.


What is the recommended way to synchronize time using NTP?

This question has come up a number of times in a localized way, this question is meant to provide the preferred/best method for synchronizing a system's clock using NTP. The solution should handle multiple issues correctly, such as:   1. Correct for time at boot-up quickly where the clock has a large skew.   2. Provide a configuration that guards and/or corrects for situations where the clock can sometimes develop a large skew over time.   3. A robust solution that can handle and sync the time quickly when certain problems arise such as: "the time server wasn't accessible during boot" or "the internet is inaccessible during boot". The ideal solution would be a **single** NTP configuration file that is able to handle all this. ### References Many of the pieces that will provide the "ultimate" solution are spread across the U&L site in questions such as these:   * How to force the time and date settings to refresh from the internet?   * Time synchronization of machines on LAN to GPS NTP server on the LAN   * How can I make a Puppet module that fixes time?   * NTP not syncing in a VM There are bound to be others but these are the ones that I've seen that come to mind as being relevant.


System freezes. Can't find anything in the logs

My linux desktop system freezes (aptosid/debian sid) sometimes and after a reboot I can't find any infos about the reason for the freeze in messages/dmesg/syslog/Xorg.*.log. When it "freezes" I can still move the mouse in X and sometimes even move the windows for a short time before the system stops responding. Last time I could even switch to the text-terminal and enter my login name, but every text- console stopped after that and displayed no password prompt. SSH login also does not work after the freeze. I think the problem started some weeks (maybe 1-1.5 months) ago. I have a windows partition (win7 64bit) on the same machine which I use mainly for gaming (in the last time mostly StarCraft2). I can't rember any crashes there in hours of playing. I haven't found a way to force the freeze yet which makes debugging not easier.


Emacs simple arithmetics in query replace

Is it possible to do the following in `emacs`: Query replace all numbers in a region by the number +n, for example if you have:               12 and 7 are nice numbers      let n be 3, then it should transform to               15 and 10 are nice numbers


Saving bash history from multiple Konsole not working correctly

I use multiple Konsole terminals. And I want all the commands I type in every terminal to be saved in command history, so that next konsole i open will have all of them. To prevent each terminal from over writing the other terminal's command history, I gave the following settings in my `.bashrc`               # avoid duplicates and commands starting with space     export HISTCONTROL=ignoredups:erasedups:ignorespace     # append history entries..     shopt -s histappend     #My machine reboots without warning sometimes.Hence to save commands instantaneously.     export PROMPT_COMMAND="history -a"       export HISTSIZE=1000     PS1="\[\e[1;34m\]\! \[\e[0m\]"$PS1      I gave the last line to see the command number in my prompt. The command no. has never gone above 600, but still some of my old commands are disappearing from the history. There are many commands which are given repeatedly, but as expected from `ignoredups`, it never increases the command no in prompt. Yet old commands are still disappearing.And the number of commands in history is always remaining slightly more than 500. The `.bash_history` file still contains a lot of duplicates in spite of ignoredups. PS: The output of echo `$HISTSIZE` and `$HISTFILESIZE` are both `=1000` * * * Update: I found the problem in the above entry to `.bashrc`. Just calling `history -a` in `PROMPT_COMMAND` simply appends the last new command to the .bash_history. So the `ignoredups` and `erasedups` have no effect. Is there any way, I can still write to the .bash_history without duplicates from every terminal? I don't want to load the entire history at each command prompt by `history -r` and write it again back with `history -w`, because the commands I issued in one terminal will appear in another parallel running terminal also. I want the combined commands to appear only in a new terminal. The puzzle, why my history was getting trimmed to 500 is solved. I noticed it happened each time I ssh into this machine. Creating a `.bash_profile` with the following entry solved this problem.               if [ -f ~/.bashrc ]; then     . ~/.bashrc     fi      Now my .bashrc is executed each time I ssh too. And the history file size is now monotonically increasing.


How to Optimize an IPTABLES script?

If I could list that which iptables rule has how many matched packets, then I could create a better/faster iptables script that's faster. That rule would be at top/first that has the more packets matched.


Can I find out which ssh key was used to access an account?

Is it possible to find out which ssh key was used to access an account? I have an account on a server that I let several (trusted!) people have access to via ssh. I'd find it useful to be able to know who logged in and when. I have root access so I can look at the logs, but there doesn't seem to be anything there. Is there some configuration switch that will put some way of identifying the key in the logs?


How do I configure OpenCV and Cygwin to work together?

I'm trying to configure `OpenCV-2.2.0-win32-vs2010` with `Cygwin` to work together. Any ideas on how I can do that?


Which System Call provides an interface for sending messages to devices?

Question is above. I've looked through the man pages, but they are somewhat unclear on the topic. I'm not sure if I'm looking for sendmsg() or msgsend() or if I'm looking for something totally different


What happens when I open and read from /proc?

Does the hard drive need to be accessed or is everything done in memory? Basically I would like to constantly get updated values from meminfo and cpuinfo. Do I need to reopen the file and then reread in order to get an updated value or can I just reread? I don't have access to a Linux install at the moment.


Fast way to build a test file with every second listed in YYYY-mm-dd HH:MM:SS format

I want to create a large test file with lines containg dates listed by the second, but my method is taking inordinately long... (or at least, that's how it feels :) ... 43 minutes to create only 1051201 lines. 20.1 MB file.... I want to crate a much bigger file, with each line's date being unique..   Is there a faster way than how I've approached it?:               # # BEGIN CREATE TEST DATA  ============      # # Create some dummy data.       file=/tmp/$USER/junk       ((secY2 =s3600*24*365*2))       cnt=0       secBeg=$(date --date="2010-01-01 00:00:00" +%s)       secEnd=$((secBeg+secY2))       ((sec=secBeg))       while ((sec<=secEnd)) ; do           date -d '1970-01-01 UTC '$sec' seconds' '+%Y-%m-%d %H:%M:%S' >>"$file"            ((sec+=1))           ((cnt+=1))       done       ls -l "$file"       echo Lines written: $cnt     # END CREATE TEST DATA  ============


What I can I do to make the transition to some new computer hardware safe and smooth?

I normally use machine A, and I make backups of A onto a fileserver B. Sooner or later, I will lose machine A for one reason or another. Its hard drive wears out, or it gets hit by lightening, or some salesperson convinces me that it's an embarrassing piece of obsolete junk, or an overclocking experiment goes horribly wrong, or it suffers a "glitter-related event", etc. Let's assume that computer C is totally different from computer A -- different mass storage interface, processor from a different company, different screen resolution, etc. Is there an easy way to make a list of all the software currently installed on A before disaster strikes, in a way that makes it easy to install the same software on the blank hard drives of computer C? Or better yet, makes it easy to install the latest versions of each piece of software, and the specific sub-version optimized for this particular machine C? If I have plenty of space on B, it seems easiest copy _everything_ from A to B. If I do that, what is a good way of dividing the files I want to copy from B to C from the files I don't? I don't want to copy binary files I can easily re-download (and possibly re-compile) as needed, and probably wouldn't work on machine C anyway. Or is it better in the long run to try to avoid backing up such easily-obtained machine-specific binary files onto B in the first place? Is there a better way to reduce the chances that viruses and trojans get passed on to C and re-activated? When I customize software or write fresh new software, what is a good way to make sure the tweaks I have made get backed up and transferred to the new machine and installed? Such as cron and anacron tasks? What I can I do to make my transition to some new computer C safe and smooth? (This question expands on a sub-question of "Incremental system backup and restore w/ rsync or rdiff-backup issues" that I thought was particularly important).


How to access web server running on Palm Pre from another machine?

I have a Palm Pre, and I've installed my webserver on it, it listens on port 8080. It works, when I open 192.168.1.104:8080 on the Pre's browser (that's the IP address of the device, I've failed with localhost or 127.0.0.1), it shows images, everything is OK. But I can't access the webserver from outside, e.g. from my desktop machine, it shows timeout. Is there a firewall on the Pre, or what's wrong? I can change server's port number, if necessary. I didn't configured the Pre, just installed SSH. Also, I can SSH to Pre, and from Pre to my desktop. **UPDATE:** _ifconfig_ says:               eth0      Link encap:Ethernet  HWaddr 00:1D:FE:B5:99:51                 inet addr:192.168.1.104  Bcast:192.168.255.255  Mask:255.255.0.0               UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1               RX packets:486 errors:0 dropped:0 overruns:0 frame:0               TX packets:284 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:1000                RX bytes:69398 (67.7 KiB)  TX bytes:40051 (39.1 KiB)          lo        Link encap:Local Loopback                 inet addr:127.0.0.1  Mask:255.0.0.0               UP LOOPBACK RUNNING  MTU:16436  Metric:1               RX packets:1248 errors:0 dropped:0 overruns:0 frame:0               TX packets:1248 errors:0 dropped:0 overruns:0 carrier:0               collisions:0 txqueuelen:0                RX bytes:128070 (125.0 KiB)  TX bytes:128070 (125.0 KiB)      _iptables -nvL_ says:               Chain INPUT (policy DROP 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination                370 29404 ACCEPT     tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:22       1248  128K ALLOWED_PACKETS  all  --  lo     *       0.0.0.0/0            0.0.0.0/0                    0     0 INVALID_PACKETS  all  --  !lo    *       127.0.0.0/8          0.0.0.0/0                    0     0 REJECT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:113 flags:0x17/0x02 state NEW reject-with tcp-reset          0     0 DROP       tcp  --  bridge0 *       0.0.0.0/0            0.0.0.0/0           tcp dpts:4444:4445         47 28580 ALLOWED_PACKETS  all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED          0     0 ALLOWED_PACKETS  all  --  bridge0 *       0.0.0.0/0            0.0.0.0/0                    0     0 ALLOWED_PACKETS  all  --  usb0   *       0.0.0.0/0            0.0.0.0/0                    0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 0 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 5 icmp type 0          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 3 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 5 icmp type 3          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 4 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 5 icmp type 4          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 5 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 5 icmp type 5          3   252 ICMPFLOOD  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 8 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 11 state NEW          0     0 ALLOWED_PACKETS  icmp --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 5 icmp type 11          0     0 ALLOWED_PACKETS  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:5353          0     0 ALLOWED_PACKETS  udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:5353          0     0 ALLOWED_PACKETS  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3689          0     0 ALLOWED_PACKETS  udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:3689          0     0 ALLOWED_PACKETS  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp flags:0x04/0x04         36  4604 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 3/sec burst 5 LOG flags 0 level 7 prefix `IPT_PACKET_DROPPED_NO_MATCH: '         36  4604 QUEUE      all  --  *      *       0.0.0.0/0            0.0.0.0/0                     Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination                  0     0 INVALID_PACKETS  all  --  *      *       0.0.0.0/0            0.0.0.0/0           state INVALID           Chain OUTPUT (policy ACCEPT 1541 packets, 166K bytes)      pkts bytes target     prot opt in     out     source               destination                   Chain ALLOWED_PACKETS (20 references)      pkts bytes target     prot opt in     out     source               destination               1298  157K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0                     Chain ICMPFLOOD (1 references)      pkts bytes target     prot opt in     out     source               destination                  3   252            all  --  *      *       0.0.0.0/0            0.0.0.0/0           recent: SET name: ICMP side: source          0     0 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           recent: UPDATE seconds: 1 hit_count: 6 TTL-Match name: ICMP side: source limit: avg 1/sec burst 1 LOG flags 0 level 4 prefix `IPT_ICMPFLOOD: '          0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           recent: UPDATE seconds: 1 hit_count: 6 TTL-Match name: ICMP side: source          3   252 ALLOWED_PACKETS  all  --  *      *       0.0.0.0/0            0.0.0.0/0                     Chain INVALID_PACKETS (2 references)      pkts bytes target     prot opt in     out     source               destination                  0     0 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           limit: avg 1/sec burst 100 LOG flags 0 level 4 prefix `IPT_INVALID_PACKETS_DROPPED: '          0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0                 I assume, TCP should be accepted for port 8080 or whatever I want, just as for 22 (SSH).


WordPress image upload error

I am using **WordPress Version 3.8.1** with the magazine theme but my problem is when I upload an image using the upload media I get this error > An Error Occurred In The Upload.Please Try Again Later and the image is uploaded to the destination. But the media remains with the blocked image or empty and the post does not display images. This problem occurs on my local web server **(127.0.0.1)** with **Ubuntu** but when I shift to a Windows local server (127.0.0.1) the theme works fine. Again the same problem occurs when I hosted a site on a web server with Unix OS but when I hosted on Bluehost web server the theme works fine. I have tried several times changing the permission by using FileZilla FTP up to **777** level which is not recommended but nothing changed. Is there any other guidance on how to change the permission in **Unix** or **Ubuntu** Can anyone help me please because I am so frustrated with this challenge and I want to host the theme officially in **Unix web server** OS because that is the current in use in my working company.


Securely inspect email attachment

I received a really classic spam mail stating that I have to pay a bill. The mail included an attachment (.exe). Just for curiosity reasons: What would happen if I click on the attachment? (I am running Crunchbang, no Wine installed)? Is there a way to securely inspect the attachment?


Bad argument `127.0.0.1' in iptables

-A OUTPUT --destination ! '127.0.0.1' -m state --state NEW -j LOG --log-prefix "new_connection " --log-level 7      gives me               Bad argument `127.0.0.1'      What am I doing wrong? I used this docs : http://www.iptables.info/en/iptables-matches.html


Is that possible to integrate zip and tar.gz files as directory into the file system

I wonder if there is a way to integrate (it's a bit different from mounting, I think) compressed files as directories into the file system? E.g., one could download a `compressed-file.tar.gz` to his local hard drive, then do `cd compressed-file.tar.gz` and run a script from within the compressed folder or do `cp some-file ..` to extract one of the files. I know that Btrfs supports compression, but I don't want to change the file system that I have (ext3) to support this feature.


Command to list assigned dhcp addresses

Is there a command I can use to ask the dhcpd server which addresses have been assigned?


Redirect grep error output to file

I wanted to capture to a file the errors being returned on the command line from `grep`. For example,               grep foo.lookup     No such file in directory      I want to output that to a log file. This is my shell script:               lookUpVal=1     var1=$(grep $lookUpVal foo.lookup) >>lookup.log 2>$1      It creates the file `lookup.log` but doesn't write the error on it.


download pdf files from using curl

How to download hundereds of .pdf files from http://www.ncbi.nlm.nih.gov/pmc/articles using a loop, for example for the following document ids:               PMC3386155     PMC3625956     PMC3477654     PMC3531051     PMC3114846     PMC3117879     PMC3130560     PMC3531173     PMC3546115     PMC3354575     PMC3771521


How to mount '.img' file (extracted cubian file) in ubuntu

I used this command               sudo mount -t ext2 -o loop Cubian-desktop-r1-a20.img mountpoint      Output from this command is               mount: wrong fs type, bad option, bad superblock on /dev/loop0,            missing codepage or helper program, or other error            In some cases useful info is found in syslog - try            dmesg | tail  or so


unrecognized option 'vf'

I'm trying to add SRT subs to an flv video with following code but says unrecognized option 'vf'. Am I missing something or is there a workaround? I read somewhere you need at least ffmpeg version 7 for vf to work(?)               $ ffmpeg -i takeout.flv -vf subtitles=takeout.srt test.flv          FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers     built on Jan 29 2012 17:53:48 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)     configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --   mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-  O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads   --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-  x11grab      libavutil     50.15. 1 / 50.15. 1      libavcodec    52.72. 2 / 52.72. 2      libavformat   52.64. 2 / 52.64. 2      libavdevice   52. 2. 0 / 52. 2. 0      libavfilter    1.19. 0 /  1.19. 0      libswscale     0.11. 0 /  0.11. 0      libpostproc   51. 2. 0 / 51. 2. 0      [flv @ 0x90ce880]Estimating duration from bitrate, this may be inaccurate           Seems stream 0 codec frame rate differs from container frame rate: 1000.00     (1000/1) -> 30.00 (30/1)     Input #0, flv, from 'takeout.flv':     Metadata:     duration        : 5295     width           : 640     height          : 480     videodatarate   : 973     framerate       : 30     videocodecid    : 2     audiosamplerate : 44100     audiosamplesize : 16     stereo          : true     audiocodecid    : 2     filesize        : 661073262     Duration: 01:28:14.89, start: 0.000000, bitrate: 1092 kb/s     Stream #0.0: Video: flv, yuv420p, 640x480, 996 kb/s, 30 tbr, 1k tbn, 1k tbc         Stream #0.1: Audio: mp3, 44100 Hz, 2 channels, s16, 96 kb/s     Unrecognized option 'vf'      I tried converting the SRT to ASS because I have latest version of libass installed with:               $ ffmpeg -i takeout.srt takeout.ass      but am getting: > Invalid data found when processing input Then I tried downloading `mencoder` as another workaround but it ran out of mirror options for download.


LS Command output to file

I want to capture to a file the output of the ls command               ls >> lsOutput.log      This one works if executed in the command line. But when put inside a shell script (`lsOutput.sh`), returns               ./lsOutput.sh: 3: ./lsOutput.sh: total: not found      `lsOutput.sh` code               #!/bin/sh          `ls -lrt` >> lsOutput.log


How to run Firefox in a chroot jail?

I've got this chroot jail all setup. I try to run Firefox in it, and get the message: **"Gtk-WARNING ** cannot open display: "** I know I have to invoke Firefox with --display= something. I probably also have to set the DISPLAY environmental variable to something as well. But I've tried all kinds of combinations, and can't get it to work in the chroot jail. Thanks.


Run nmap via Tor

Is it possible to run`nmap` via Tor? When I googled around, I got the impression that Tor uses Polipo / Privoxy, which are socks5 proxies. So any TCP / UDP aware applications should be able to use them as a gateway to route their traffic. But somewhere it also said that nmap uses raw packets, so it can't be run over Tor!


How do I screencap another Xorg display?

I started another x session from my current one like so:               xinit xterm -- :128      An x session starts in display :128, xterm gets run in it and everything is fine. I switched back to screen :0 (the default), though, and tried to screencap the new display:               $ xwd -root -screen -out screencap.xwd -display :128      and the resulting file was just a big black rectangle. I also tried with imagemagick `import`, to no avail. What is going wrong? Thanks!


Is there a tmux shortcut to go read only?

I've been using screen for years now as a way of ensuring that any remote work is safely kept open in after disconnects/crashes. In fact, as a matter of course, I use screens even when working locally. Recently, my requirements have progressed to the stage that I switched to tmux because of the beauty of:               tmux attach -r      Attaching to my own sessions in readonly mode (-r) means that I don't have to worry about accidentally:   * pasting lines of garbage in IRC   * halting an important compile/deploy process   * typing a password in full view for passersby Of course the issue is that I have to open a session, C-b + d to detach, and then reopen it with the -r flag to go readonly. And then, when I occasionally want to chime in to an IRC conversation, interrupt a task or anything else, I have to detach again and reconnect normally. Does anyone know of a way to make a key binding to switch between modes?


Why doesn't “ping -l” works when ping works?

Bye all,               ping AddressIp     64 bytes from indirizzoIp: icmp_req=1 ttl=42 time=149 ms      while if               ping AddressIp -l 1400      ping: cannot set preload to value > 3          ping AddressIp -t -l 1400     ping: can't set unicast time-to-live: Invalid argument      Why can't I ping?


Search mp3 collection for songs with a certain song length

How would I search a directory of mp3 files for songs between a certain length. Ex:               findmp3 -min=03:00 -max=03:15 /music/mp3/ebm/      Would return all mp3 files in the `emb/` directory having a song length between 3:00 and 3:15 minutes in length. I use Linux Mint, Ubuntu, as well as CentOS.


How to stop application from being suspended by Ctrl+z?

Currently I'm running `dvtm` inside a terminal, and `vim` inside `dvtm`. When I press `Ctrl`+`z` intending to suspend `vim`, `dvtm` got suspended instead. I didn't have this problem with `screen` or `tmux`, so I think it must be `dvtm` doing something wrong (or not doing something right). How can I fix that? Update: I was wrong, this is not a problem with `dvtm`. Indeed I was using the `dtach`+`dvtm` combo and wrongly assumed that dvtm was at fault. The problem is really with `dtach`.


How to run a shell script containing an awk command

How to run this script (called `count.sh`)?               awk 'BEGIN{ x=0 ; while (x < 5) { x+=1 ; print x ; } }'      I'm trying to run it with `sh count.sh` but it's giving me an error.


Faster way than ping for checking if computer online?

I'm writing a wake on lan script for a set of our lab computers. We have sqlite db with a list of the computer hostnames, IPs, and MACs and currently I ping each of them with '-c1' so it doesn't run endlessly - but even that takes some waiting, is there a quicker way to get answer rather than ping? Using ping seems to slow the script quite a bit as it needs the ping answers to continue. Thanks much for any suggestions!


Use case of providing file-like API to terminal/console

It was explained in this Stack Overflow thread that each logical terminal has a "pseudo-terminal", and that writing to one:               $ cat some-file.txt > /dev/ttys002      will cause the data to appear in that terminal window. What's the reason for providing a file-like API to terminal windows? Is there any use case where this is helpful? Till here copied verbatim. Not limited to pseudo-terminals, it is available to `/dev/tty*` as well.


permissions 755 on /home/<user>/

I am wondering why by default my directory `/home/<user>/` has permissions set to `755`. This allows other users to enter into directories and read files in my home. Is there any legitimate reason for this ? Can I set the permissions to `700` for my home and all sub directories , for example:               chmod -R o-xw /home/<user>/      chmod -R g-xw /home/<user>/      without breaking anything ? Also, is it possible to set the permissions on my home, so that all new files created will have `600` and directories `700` ?


btrfs partition not detected

I have some distros installed on a BTRFS partitions under different subvolumes ( for distro-hopping, separate ext4 boot). This btrfs partition is now not getting detected on boot, while I can access them after I boot to another distro living in another ext4 partition. I believe its because I did a `tune2fs` on this BTRFS partition mistakenly assuming its an `ext4` so as to disable journalling. Using `testdisk`, it wrongly identified the partition as ext4. But after an incomplete _deeper_ search, it showed up as btrfs correctly. I think this is problem - the partition getting identified as ext4 on a _quick breeze_. But the boot message is actually saying `dev/sda9` not found. One solution I _should_ try is to fire up `fdisk` and change the type to BTRFS, but I doubt if I will loose the data. Is this operation safe? How can I fix the partition for it to get detected as BTRFS at boot?


Why does SSH show protocol as tcp6 *and* tcp in netstat?

$ netstat -nat     Active Internet connections (servers and established)     Proto Recv-Q Send-Q Local Address           Foreign Address         State           tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN          tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN          tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN          tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN          tcp6       0      0 :::22                   :::*                    LISTEN        Why are there two records of port 22 (`:::22` and `0.0.0.0:22`) and why does one use protocol as `tcp` and the other as `tcp6` This is on Ubuntu 12.04.4


How to recover the partition table (Windows, Ubuntu) of an unallocated disc?

The following screenshot shows the current state of my hard disc. ![GParted](http://i.stack.imgur.com/OCmDH.png) The **unallocated part** of the disc used to contain two operating systems:   * Windows and Ubuntu, in this order. Windows has been installed first. Ubuntu used Grub.   * I do not have information about specific partitioning.   * There was a home partition of Ubuntu was encrypted. I wrote down the passphrase. The **NTFS partition** is not of interest for this question. I already managed to recover data stored there. Do you know any tool for Linux or Windows which is capable of recovering the partitions? I assume that I lost the partition table or just Grub. * * * # Interim results * * * ## Running testdisk After running the `Quick Search` the following shows up:               Disk /dev/sdb - 500 GB / 465 GiB - CHS 969021 16 63          Warning: the current number of heads per cylinder is 16     but the correct value may be 255.     You can use the Geometry menu to change this value.     It's something to try if     - some partitions are not found by TestDisk     - or the partition table can not be written because partitions overlaps.          [Continue]      Then ...               Disk /dev/sdb - 500 GB / 465 GiB - CHS 969021 16 63          Partition             Start        End    Size in sectors      * HPFS - NTFS               2   0 33    205   3 19     204800      P HPFS - NTFS             205   3 20 203174   9 41  204593152      P Linux                203176  10 11 305359   3 51  103000064      L Linux                313112   6  7 373707   2 50   61079552        HPFS - NTFS          373707   2 51 969022  15 47  600078336        HPFS - NTFS          373707   2 58 969020  15 63  600076329      * * * # Success story * * * Finally, I was able to recover the partition table. I cloned the drive using `dd` and had to change the geometry settings of the target drive. Then I was able to detect the Linux partitions on the cloned hard drive. Finally, I wrote the partition table via TestDisk to the clone hard drive. I did not want to alter the original drive to avoid total damage. To actually mount and copy the data from the encrypted home partition I followed this post by rausch. Helpful background information can be read in: Unwrapping passphrase and inserting into the user session keyring failed.


Leave directory out using ls

I am trying to get a vertical list from `ls`, that is recursive but leaves a out a single directory called `node_modules`. I've used:               ls -lt -h -R      This gets me a very long list that is vertical, human readable and recursive. But it has the directory `node_modules` included and that just has too many files and directories.


restore from tar file

I took a backup using: `cd /usr/CCS` `tar cvfz /usr/LARGE/BKUP/hms.tar.gz *` Now I would like to restore `HMS` and overwrite at `/usr/CCS/HMS`. `HMS` is one of the subfolders under `/usr/CCS` Can I get some help in restoring only the `HMS` folder from the tar and overwriting it at `/usr/CCS/HMS`.


log all the email send by the root

I'm new in Linux and just installed a private script and want to capture all traffic, to know if this script send my logs or other things via email.


How to install cacti in SUSE Linux Enterprise Server?

I want to install cacti in my SUSE Enterprise Server 11 Edition. What steps do I need to do to accomplish that?


Any tricks to speed up sort?

For example for `bzip` there is pbzip, a parallel version of `bzip`. Is there any such parallelization tools for `sort` to improve performance?


How to set up the login screen to ask for keyboard layout

I just upgraded my distro, now it no longer has a menu to set the keyboard layout in the login screen (gdm). Previously a user could select there icon, then change the keyboard layout (it would also remember previous choice of this user), and then type in password and continue the session, using there selected layout. I have users using dvorak and qwerty uk. I have looked at various pages of help on the subject of configuring gdm, but have found nothing on keyboard layouts. Can you help with how to add the keyboard layout selector?


What does mdadm's "spare" number mean?

I created a mdadm-based RAID 5 from six hard drives using the following command:               # mdadm --create /dev/md0 --level=5 --raid-devices=5 \     /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 \     --spare-devices=1 /dev/sdg1      I expected the array to have one hot spare, namely /dev/sdg1. However, checking `mdadm --detail` shows 2 spares:               # mdadm --detail --scan      ARRAY /dev/md0 metadata=1.2 spares=2 name=...      Also, the array size as shown by `df` is 2 TB, which would correspond to only four of my 500 GB drives being used. So what exactly is the semantics of `\--spare-devices`? The man page states that it "Specif[ies] the number of spare (eXtra) devices in the initial array.", but that does not seem to be the case here.


Is there a difference between these two commands?

cat a > b      and               cp a b      If they are functionally the same for all intents and purposes, which one is faster?


Postfix vs Google SMTP servers inconsistency

I wanted to host my own mail server and in order to do so I've installed Postfix 2.7.0 and Dovecot 1.2.9 on Ubuntu Server 10.04. I had fun reading the docs and configuring all these great tools, I am also hosting locally a DNS server and a Web server but right now I am stuck on something regarding Postfix. One big problem I face right now is that Google SMTP servers reject my mail **ONLY WHEN** it is being sent remotely. Strange, right? So if I `telnet localhost 25`, issue `AUTH LOGIN`(not an open relay of course) then send the mail I get a `status = sent` and I **actually receive** the mail message in my Gmail's account Inbox. Works like a charm. On the other hand, if I want to send the mail from a remote host, I use               openssl s_client -connect mail.mydomain.com:465      Then I issue `AUTH LOGIN`, the login process is successful. So I don't have a problem communicating with my server. I can see what happens in the log files. But when I try to send mail like this, Google replies with: > Our system has detected an unusual rate of 421-4.7.0 unsolicited mail > originating from your IP address. To protect our 421-4.7.0 users from spam, > mail sent from your IP address has been temporarily 421-4.7.0 rate limited. Why Google accepts my mail if being sent locally but rejects it when I `openssl` to my server and send it remotely? It's like Postfix on my server makes Google aware of how the email it forwards got to it. Any ideas?


How to move or copy list of files referenced in a csv file to a new folder

I'd like to write a shell script (OSX) which copies files listed in a csv file to a particular directory. I need to strip quotes from each line in the csv file. My attempt               for i in $(cat myfile.csv)       temp="${$i%\"}"       temp="${temp#\"}"          do       cp foldername/$temp foldername/subfoldername     done      I get this error:               ./mfcsv.sh: line 2: syntax error near unexpected token `temp="${$i%\"}"'     ./mfcsv.sh: line 2: `  temp="${$i%\"}"'


Comparing two columns with two columns

I have a file that I need to compare the values in two columns with another two columns. For examples:               Item  A     B     C    D     1    201  3101   3101 201     2   3101   201    202 3101       3   3101   201    201 3102      4   3101   201   3202 202       So what I trying to do is comparing column _A_ & _B_ to _C_ & _D_ , but values in column _A_ & _B_ and _C_ & _D_ are interchangeable. And I would like to have a output like _2_ if both values are the same, _1_ if only one is match and _0_ if both are not match. The answer would be something like this               Item  A     B     C      D   Output     1    201  3101   3101   201    2     2   3101   201    202  3101    1     3   3101   201    201  3102    1     4   3101   201   3202   202    0      How would I be able to achieve this?


Some questions compiling linux kernel with make-kpkg

I'm doing my first steps compiling the linux kernel and adding a new system call. I've managed to do it, but I still have some questions. For this task, I has set up a Virtual Machine guesting debian 7 64 bits. I am following a tutorial found in Internet of how to do this (http://arvindsraj.wordpress.com/2012/10/05/adding-hello-world-system-call-to- linux/) And as documentation, overall, a manual of how to create a custom linux kernel in Debian GNU/Linux and the manual page for make-kpkg. So far, I am using the next script to compile:               #!/bin/sh     make-kpkg clean     INSTALL_MOD_STRIP=1 CONCURRENCY_LEVEL=2 time make-kpkg --initrd --append-to-version=-$1 kernel_image      And, well, I have the following questions:   1. Right now, I'm defining kernel_image only as target. Should I include also kernel_headers? when should I compile and install the kernel_headers? what are they for?   2. If I use as target: binary_arch, is exactly the same than using kernel_image and kernel_headers?   3. I put INSTALL_MOD_STRIP=1 because I read that it compiles it faster and the output is much smaller. I know it reduces the number of modules being compiled. how much is this reduction? Should I use this flag for a final compilation for a final use of the kernel in my computer?? Thank you in advance!