title: Can iptables be used to convert a single-homed host into a NAT server?

text: **Given:** I have a machine (HostA) with **only** one NIC which has Internet connectivity. I have another machine (HostB) with one NIC on the same switch. HostB is _not_ configured for Internet access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17. **What I want:** Now, I would like HostB to have Internet connectivity, too. Is this possible using 'some' combination of `iptables`, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc? **What I already know and can do:** Currently, I can use an `ssh`-based SOCKS proxy on HostB (`ssh -D 9050 UserA@HostA`) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. Now, I know very well that if HostA had 2 NICs, I could have used some `iptables` rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me. PS: I had posted this earlier on superuser.com but got no useful information. **edit 1:** network information Host A:               :> ip addr     [...]     2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000     link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff     inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1           :> ip route     default via 192.168.22.254 dev p4p1 proto static     192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9      Host B:               :> ip addr     [...]     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000     link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff     inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0           :> ip route     169.254.0.0/16 dev eth0 scope link metric 1000     192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1


title: Undocumented pppd exit code

text: If my machine (OSX 10.9.2) is not connected to the Internet and I want to establish pptp connection by using **pppd** :               $ sudo /usr/sbin/pppd serviceid 5BE14D3A-7B94-4704-ADE0-9883B189199E debug logfile /tmp/ppp.log plugin /System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp plugin pptp.ppp remoteaddress 11.22.33.44 redialcount 1 redialtimer 5 idle 1800 mru 1500 mtu 1448 receive-all novj 0:0 noipdefault ipcp-accept-local ipcp-accept-remote user bbbbbb password cccccc hide-password noaskpassword looplocal defaultroute usepeerdns mppe-128 nodetach logfd 1      pppd outputs:               Thu Mar 27 15:09:30 2014 : publish_entry SCDSet() failed: Success!     Thu Mar 27 15:09:30 2014 : publish_entry SCDSet() failed: Success!      and terminates with exit code **25** :               $ echo $?     25      **Why pppd returns with exit code which is notdocumented?** Expected exit codes are in the range [0, 19]. Where does this exit code come from? Does this exit code have description? Are there any other "hidden" exit codes for pppd? If I connect to the Internet and run the same command, pptp connection gets established. Last couple of lines of _dtruss_ output are:               $ /usr/bin/sudo dtruss /usr/sbin/pppd serviceid 5BE14D3A-7B94-4704-ADE0-9883B189199E debug logfile /tmp/ppp.log plugin /System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp plugin pptp.ppp remoteaddress 11.22.33.44 redialcount 1 redialtimer 5 idle 1800 mru 1500 mtu 1448 receive-all novj 0:0 noipdefault ipcp-accept-local ipcp-accept-remote user bbbbbbb password cccccccc hide-password noaskpassword looplocal defaultroute usepeerdns mppe-128 nodetach logfd 1     Fri Mar 28 10:31:10 2014 : publish_entry SCDSet() failed: Success!     Fri Mar 28 10:31:10 2014 : publish_entry SCDSet() failed: Success!     Fri Mar 28 10:31:10 2014 : PPTP connecting to server '11.22.33.44' (77.75.123.187)...     Fri Mar 28 10:31:10 2014 : PPTP connect errno = 49 Can't assign requested address     SYSCALL(args)        = return     close(0x3)       = 0 0     getuid(0x0, 0x1103, 0x7FFF772B14E0)      = 0 0     getgid(0x0, 0x1103, 0x0)         = 0 0     getuid(0x7FDEA8D00A80, 0x0, 0x1)         = 0 0     seteuid(0x0, 0x0, 0x0)       = 0 0     open_nocancel("/var/root/.ppprc\0", 0x0, 0x1B6)      = -1 Err#2     seteuid(0x0, 0x7FFF76AB4430, 0xFFFFFFFFFFFFFFFF)         = 0 0     open("/tmp/ppp.log\0", 0xA09, 0x1A4)         = -1 Err#17     open("/tmp/ppp.log\0", 0x9, 0xFFFFFFFFFFFFFFFF)      = 3 0     open_nocancel("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp\0", 0x1100004, 0x7FDEA8D00D70)       = 4 0     __sysctl(0x7FFF54902F38, 0x2, 0x7FFF76AB4180)        = 0 0     fstatfs64(0x4, 0x7FFF54902F88, 0x0)      = 0 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 88 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x4)      = 0 0     open_nocancel("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents\0", 0x1100004, 0x7FDEA8D01173)      = 4 0     fstatfs64(0x4, 0x7FFF54902F58, 0x0)      = 0 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 240 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x4)      = 0 0     open("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/Info.plist\0", 0x0, 0x1B6)       = 4 0     fstat64(0x4, 0x7FFF54903218, 0x0)        = 0 0     read(0x4, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>BuildMachineOSBuild</key>\n\t<string>13C40z</string>\n\t<key>CFBundleDevelopmentReg", 0x4F1)      = 1265 0     close(0x4)       = 0 0     stat64("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x7FFF54903C08, 0x7FFF54904156)   = 0 0     stat64("/usr/lib/libesp.dylib\0", 0x7FFF549031C8, 0x7FFF54904070)        = -1 Err#2     stat64("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x7FFF54902E88, 0x7FFF54903D30)   = 0 0     stat64("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x7FFF54903B18, 0xF9A90)      = 0 0     open("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x0, 0x1FF)         = 4 0     read(0x4, "\317\372\355\376\a\0", 0x200)         = 512 0     close(0x4)       = 0 0     stat64("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x7FFF54902E68, 0x7FFF54903D10)   = 0 0     open("/System/Library/SystemConfiguration/PPPController.bundle/Contents/PlugIns/PPPDialogs.ppp/Contents/MacOS/PPPDialogs\0", 0x0, 0x0)       = 4 0     pread(0x4, "\317\372\355\376\a\0", 0x1000, 0x0)      = 4096 0     fcntl(0x4, 0x3D, 0x7FFF54901190)         = 0 0     mmap(0x10B38C000, 0x2000, 0x5, 0x12, 0x4, 0x0)       = 0x10B38C000 0     mmap(0x10B38E000, 0x1000, 0x3, 0x12, 0x4, 0x2000)        = 0x10B38E000 0     mmap(0x10B38F000, 0x26F0, 0x1, 0x12, 0x4, 0x3000)        = 0x10B38F000 0     close(0x4)       = 0 0     open_nocancel("/System/Library/Extensions/pptp.ppp\0", 0x1100004, 0x7FDEA8D02370)        = 4 0     fstatfs64(0x4, 0x7FFF54902F88, 0x0)      = 0 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 88 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x4)      = 0 0     open_nocancel("/System/Library/Extensions/pptp.ppp/Contents\0", 0x1100004, 0x7FDEA8D02573)       = 4 0     fstatfs64(0x4, 0x7FFF54902F58, 0x0)      = 0 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 232 0     getdirentries64(0x4, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x4)      = 0 0     open("/System/Library/Extensions/pptp.ppp/Contents/Info.plist\0", 0x0, 0x1B6)    = 4 0     fstat64(0x4, 0x7FFF54903218, 0x0)        = 0 0     geteuid(0x100000001103, 0x110000001100, 0x10B356308)         = 0 0     setsid(0x50000000603, 0x60000000600, 0x7FFF772B15A8)         = 3077 0     socket(0x22, 0x3, 0x1)       = 3 0     connect(0x3, 0x7FFF549046B0, 0x8)        = 0 0     fcntl(0x3, 0x3, 0x0)         = 2 0     fcntl(0x3, 0x4, 0x6)         = 0 0     socket(0x2, 0x2, 0x0)        = 4 0     open_nocancel("/usr/sbin\0", 0x1100004, 0x7FFF922AEB6E)      = 5 0     fstatfs64(0x5, 0x7FFF549031B8, 0x0)      = 0 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 4080 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 4072 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 648 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x5)      = 0 0     stat64("/usr/sbin/Contents\0", 0x7FFF549039D8, 0x7FFF54903ABF)       = -1 Err#2     stat64("/usr/sbin/Resources\0", 0x7FFF549039D8, 0x7FFF54903ABF)      = -1 Err#2     stat64("/usr/sbin/Support Files\0", 0x7FFF549039D8, 0x7FFF54903ABF)      = -1 Err#2     stat64("/usr/sbin\0", 0x7FFF54903F58, 0x7FFF5490406B)        = 0 0     open_nocancel("/usr/sbin\0", 0x1100004, 0x7FFF922AEB6E)      = 5 0     fstatfs64(0x5, 0x7FFF54903188, 0x0)      = 0 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 4080 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 4072 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 648 0     getdirentries64(0x5, 0x7FDEAA000600, 0x1000)         = 0 0     close_nocancel(0x5)      = 0 0     stat64("/usr/sbin/pppd\0", 0x7FFF54903DC8, 0x7FFF54903E7E)       = 0 0     open("/usr/sbin/pppd\0", 0x0, 0x1FF)         = 5 0     read(0x5, "\317\372\355\376\a\0", 0x200)         = 512 0     close(0x5)       = 0 0     geteuid(0x7FDEA8D00030, 0x7FFF76F80258, 0x49656E69)      = 0 0     kevent64(0x5, 0x7FFF549043A8, 0x1)       = 1 0     open("/dev/null\0", 0x2, 0x0)        = 6 0     __sysctl(0x7FFF54903AC0, 0x2, 0x7FFF54903AD0)        = 0 0     getuid(0x7FDEAA001743, 0x7FFF54903D60, 0x0)      = 0 0     getgid(0x7FDEAA001748, 0x7FFF54903D60, 0x0)      = 0 0     sigaction(0x1, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x2, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0xF, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x14, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x12, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x13, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x1E, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x1F, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x6, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0xE, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x8, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x4, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0xD, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x3, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0xB, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0xA, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x7, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x1B, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0xC, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x5, 0x7FFF54904758, 0x0)      = 0 0     sigaction(0x1A, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x18, 0x7FFF54904758, 0x0)         = 0 0     sigaction(0x19, 0x7FFF54904758, 0x0)         = 0 0     stat64("/System/Library/Frameworks/Security.framework/Security\0", 0x7FFF549040D0, 0x7FFF8E1A1463)       = 0 0     stat64("/System/Library/Frameworks/Security.framework/Security\0", 0x7FFF54903188, 0x7FFF54904030)       = 0 0     csops(0xC05, 0x7, 0x7FFF54904510)        = 0 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x0, 0x0)      = 1 0     kevent64(0x5, 0x10B3AC3C8, 0x1)      = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x0, 0x0)      = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x7FFF75519130, 0x1)       = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x10BC80D88, 0x1)      = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     __sysctl(0x7FFF54903A90, 0x2, 0x7FFF54903AA0)        = 0 0     getuid(0x7FDEAA00170E, 0x7FFF54903D30, 0x0)      = 0 0     getgid(0x7FDEAA001713, 0x7FFF54903D30, 0x0)      = 0 0     csops(0x0, 0x0, 0x7FFF54903F04)      = 0 0     issetugid(0x0, 0x0, 0x0)         = 0 0     pread(0x3, "\312\376\272\276\0", 0x1000, 0x0)        = 4096 0     pread(0x3, "\317\372\355\376\a\0", 0x1000, 0x1000)       = 4096 0     fcntl(0x3, 0x3D, 0x7FFF54901350)         = 0 0     mmap(0x10B357000, 0x2000, 0x5, 0x12, 0x3, 0x1000)        = 0x10B357000 0     mmap(0x10B359000, 0x1000, 0x3, 0x12, 0x3, 0x3000)        = 0x10B359000 0     mmap(0x10B35A000, 0x2050, 0x1, 0x12, 0x3, 0x4000)        = 0x10B35A000 0     close(0x3)       = 0 0     stat64("/usr/lib/libbsm.0.dylib\0", 0x7FFF54902D98, 0x7FFF54903C30)      = 0 0     stat64("/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration\0", 0x7FFF54902D98, 0x7FFF54903C30)      = 0 0     stat64("/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation\0", 0x7FFF54902D98, 0x7FFF54903C30)        = 0 0     stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF54902D98, 0x7FFF54903C30)       = 0 0     stat64("/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit\0", 0x7FFF54902D98, 0x7FFF54903C30)      = 0 0     stat64("/System/Library/Frameworks/Security.framework/Versions/A/Security\0", 0x7FFF54902D98, 0x7FFF54903C30)        = 0 0     stat64("/usr/lib/system/libcache.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)   = 0 0     stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)        = 0 0     stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0x7FFF54902908, 0x7FFF549037A0 = 0 0     stat64("/usr/lib/system/libcopyfile.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)    = 0 0     stat64("/usr/lib/system/libcorecrypto.dylib\0", 0x7FFF54902908, 0x7FFF549037A0) = 0 0     stat64("/usr/lib/system/libdispatch.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)    = 0 0     stat64("/usr/lib/system/libdyld.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)    = 0 0     stat64("/usr/lib/system/libkeymgr.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)  = 0 0     stat64("/usr/lib/system/liblaunch.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)  = 0 0     stat64("/usr/lib/system/libmacho.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)   = 0 0     stat64("/usr/lib/system/libquarantine.dylib\0", 0x7FFF54902908, 0x7FFF549037A0) = 0 0     stat64("/usr/lib/system/libremovefile.dylib\0", 0x7FFF54902908, 0x7FFF549037A0) = 0 0     stat64("/usr/lib/system/libsystem_asl.dylib\0", 0x7FFF54902908, 0x7FFF549037A0) = 0 0     stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)       = 0 0     stat64("/usr/lib/system/libsystem_c.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)    = 0 0     stat64("/usr/lib/system/libsystem_configuration.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)        = 0 0     stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)        = 0 0     stat64("/usr/lib/system/libsystem_info.dylib\0", 0x7FFF54902908, 0x7FFF549037A0 = 0 0     stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)       = 0 0     stat64("/usr/lib/system/libsystem_m.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)    = 0 0     stat64("/usr/lib/system/libsystem_malloc.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)       = 0 0     stat64("/usr/lib/system/libsystem_network.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)      = 0 0     stat64("/usr/lib/system/libsystem_notify.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)       = 0 0     stat64("/usr/lib/system/libsystem_platform.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)         = 0 0     stat64("/usr/lib/system/libsystem_pthread.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)      = 0 0     stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)      = 0 0     stat64("/usr/lib/system/libsystem_stats.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)        = 0 0     stat64("/usr/lib/system/libunc.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)     = 0 0     stat64("/usr/lib/system/libunwind.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)  = 0 0     stat64("/usr/lib/system/libxpc.dylib\0", 0x7FFF54902908, 0x7FFF549037A0)     = 0 0     stat64("/usr/lib/libobjc.A.dylib\0", 0x7FFF54901B48, 0x7FFF549029E0)         = 0 0     stat64("/usr/lib/libauto.dylib\0", 0x7FFF54901B48, 0x7FFF549029E0)       = 0 0     stat64("/usr/lib/libc++abi.dylib\0", 0x7FFF549015F8, 0x7FFF54902490)         = 0 0     stat64("/usr/lib/libc++.1.dylib\0", 0x7FFF549015F8, 0x7FFF54902490)      = 0 0     stat64("/usr/lib/libDiagnosticMessagesClient.dylib\0", 0x7FFF549014D8, 0x7FFF54902370)       = 0 0     stat64("/usr/lib/libicucore.A.dylib\0", 0x7FFF54902B18, 0x7FFF549039B0)      = 0 0     stat64("/usr/lib/libz.1.dylib\0", 0x7FFF54902B18, 0x7FFF549039B0)        = 0 0     stat64("/usr/lib/system/libkxld.dylib\0", 0x7FFF54902C48, 0x7FFF54903AE0)    = 0 0     stat64("/usr/lib/libxar.1.dylib\0", 0x7FFF54902BA8, 0x7FFF54903A40)      = 0 0     stat64("/usr/lib/libsqlite3.dylib\0", 0x7FFF54902BA8, 0x7FFF54903A40)        = 0 0     stat64("/usr/lib/libpam.2.dylib\0", 0x7FFF54902BA8, 0x7FFF54903A40)      = 0 0     stat64("/usr/lib/libOpenScriptingUtil.dylib\0", 0x7FFF54902BA8, 0x7FFF54903A40) = 0 0     stat64("/usr/lib/libbz2.1.0.dylib\0", 0x7FFF54902A78, 0x7FFF54903910)        = 0 0     stat64("/usr/lib/libxml2.2.dylib\0", 0x7FFF54902A78, 0x7FFF54903910)         = 0 0     getpid(0x7FFF54903CF8, 0x10B352004, 0xEA60)      = 3077 0     shm_open(0x7FFF92E96CE4, 0x0, 0x0)       = 3 0     mmap(0x0, 0x1000, 0x1, 0x1, 0x3, 0x0)        = 0x10B38B000 0     close_nocancel(0x3)      = 0 0     geteuid(0x20000000303, 0x30000000300, 0x10B356308)       = 0 0     __sysctl(0x7FFF54904640, 0x2, 0x7FFF54904650)        = 0 0     umask(0x1FF, 0x0, 0xFFFFFFFFFFFFFFE0)        = 18 0     umask(0x12, 0x0, 0x0)        = 511 0     getuid(0x12, 0x0, 0x0)       = 0 0     getgroups(0x10, 0x10B33EE20, 0x0)        = 13 0     __sysctl(0x7FFF54904738, 0x2, 0x7FFF5490472C)        = 0 0     getrlimit(0x1008, 0x7FFF54903DA0, 0x7FFF8BF3CE7C)        = 0 0     open_nocancel("/etc/ppp/options\0", 0x0, 0x1B6)      = -1 Err#2     getuid(0x4, 0x7FFF76AB4430, 0xFFFFFFFFFFFFFFFF)      = 0 0     read(0x4, "\317\372\355\376\a\0", 0x200)         = 512 0     open_nocancel("/etc/ppp/postoptions\0", 0x0, 0x1B6)      = -1 Err#2     geteuid(0x20000000303, 0x30000000300, 0x7FFF772B15A8)        = 0 0     socket(0x22, 0x3, 0x1)       = 4 0     close(0x4)       = 0 0     close(0x3)       = 0 0     getuid(0x7FDEA8E000C0, 0x0, 0xFFFFFFFFFFFFFF01)      = 0 0     getgid(0x7FDEA8E000C0, 0x0, 0x0)         = 0 0     write(0x1, "Fri Mar 28 10:31:10 2014 : \0", 0x1B)        = 27 0     write(0x1, "publish_entry SCDSet() failed: Success!\0", 0x27)        = 39 0     write(0x1, "\n\0", 0x1)      = 1 0     __sysctl(0x7FFF54902800, 0x2, 0x7FFF54902810)        = 0 0     getuid(0x7FDEA9802330, 0x7FFF54902AA0, 0x0)      = 0 0     getgid(0x7FDEA9802335, 0x7FFF54902AA0, 0x0)      = 0 0     write(0x1, "Fri Mar 28 10:31:10 2014 : \0", 0x1B)        = 27 0     write(0x1, "publish_entry SCDSet() failed: Success!\0", 0x27)        = 39 0     write(0x1, "\n\0", 0x1)      = 1 0     guarded_kqueue_np(0x7FFF54903E98, 0x3, 0x7FFF86283A77)       = 5 0     kevent64(0x5, 0x7FFF86296C48, 0x1)       = 0 0     workq_kernreturn(0x10, 0x0, 0x58)        = 0 0     workq_open(0x10, 0x0, 0x0)       = 0 0     bsdthread_create(0x7FFF86283E77, 0x7FFF75518940, 0x10000)        = 188403712 0     kevent64(0x5, 0x7FFF54903F18, 0x1)       = 1 0     kevent64(0x5, 0x10BC80D88, 0x1)      = 1 0     kevent64(0x5, 0x0, 0x0)      = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     thread_selfid(0x0, 0x1DC0, 0x7FFF65505550)       = 88904 0     shared_region_check_np(0x7FFF54901E38, 0x10B2FB000, 0x4)         = 0 0     stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF54902FE8, 0x7FFF54903F20 = 0 0     open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0)         = 3 0     ioctl(0x3, 0x80086804, 0x7FFF54903D78)       = 0 0     kevent64(0x5, 0x7FFF75519130, 0x1)       = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     thread_selfid(0x10BD04000, 0x7FFF77A55258, 0x1010101)        = 88912 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     open("/dev/dtracehelper\0", 0x2, 0x7FFF54903DF0)         = 3 0     __sysctl(0x7FFF54903648, 0x2, 0x7FFF54903658)        = 0 0     thread_selfid(0x7FFF77A55310, 0x7FFF77A55258, 0x10101)       = 88904 0     bsdthread_register(0x7FFF92F30FBC, 0x7FFF92F30FAC, 0x2000)       = 0 0     mprotect(0x10B353000, 0x88, 0x1)         = 0 0     mprotect(0x10B35D000, 0x1000, 0x0)       = 0 0     mprotect(0x10B373000, 0x1000, 0x0)       = 0 0     mprotect(0x10B374000, 0x1000, 0x0)       = 0 0     mprotect(0x10B38A000, 0x1000, 0x0)       = 0 0     mprotect(0x10B355000, 0x1000, 0x1)       = 0 0     mprotect(0x10B353000, 0x88, 0x3)         = 0 0     mprotect(0x10B353000, 0x88, 0x1)         = 0 0     issetugid(0x7FFF75518480, 0x7FFFFFE00034, 0x7FFFFFE00036)        = 0 0     getpid(0x1, 0x10B356000, 0x49656E69)         = 3077 0     __mac_syscall(0x7FFF853DCE3F, 0x2, 0x7FFF549034C8)       = 0 0     stat64("/AppleInternal\0", 0x7FFF54903548, 0x0)      = -1 Err#2     audit_session_self(0x7FFF54903400, 0x7FFF54903238, 0x4)      = 4099 0     geteuid(0x7FFF54903400, 0x7FFF54903238, 0x0)         = 0 0     getegid(0x7FFF54903400, 0x7FFF54903238, 0x0)         = 0 0     getaudit_addr(0x7FFF549034D8, 0x30, 0x0)         = 0 0     csops(0xC05, 0x7, 0x7FFF549030C0)        = 0 0     getuid(0x7FFF5490371C, 0x7FFF54903718, 0x7FFF54904960)       = 0 0     geteuid(0x103, 0x10000000100, 0x7FFF778F8198)        = 0 0     getuid(0x103, 0x10000000100, 0x0)        = 0 0     __sysctl(0x7FFF54902BC0, 0x4, 0x7FFF54902BD8)        = 0 0     issetugid(0x7FFF778D3DC0, 0x0, 0x7FDEA8C062C8)       = 0 0     getuid(0x7FFF54902EE4, 0x0, 0x7FFF54904960)      = 0 0     issetugid(0x7FFF8808BA90, 0x7FFF549045F4, 0x7FFF54904960)        = 0 0     issetugid(0x7FFF758FA678, 0x0, 0x0)      = 0 0     read(0x4, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>BuildMachineOSBuild</key>\n\t<string>13C40z</string>\n\t<key>CFBundleDevelopmentReg", 0x4E5)      = 1253 0     close(0x4)       = 0 0     stat64("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x7FFF54903C08, 0x7FFF54904156)      = 0 0     stat64("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x7FFF54902E88, 0x7FFF54903D30)      = 0 0     stat64("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x7FFF54903B18, 0xF4290)         = 0 0     open("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x0, 0x1FF)    = 4 0     close(0x4)       = 0 0     stat64("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x7FFF54902E68, 0x7FFF54903D10)      = 0 0     open("/System/Library/Extensions/pptp.ppp/Contents/MacOS/PPTP\0", 0x0, 0x0)  = 4 0     pread(0x4, "\317\372\355\376\a\0", 0x1000, 0x0)      = 4096 0     fcntl(0x4, 0x3D, 0x7FFF54901170)         = 0 0     mmap(0x10B392000, 0x5000, 0x5, 0x12, 0x4, 0x0)       = 0x10B392000 0     mmap(0x10B397000, 0x1000, 0x3, 0x12, 0x4, 0x5000)        = 0x10B397000 0     mmap(0x10B398000, 0x3B00, 0x1, 0x12, 0x4, 0x6000)        = 0x10B398000 0     close(0x4)       = 0 0     __sysctl(0x7FFF54902800, 0x2, 0x7FFF54902810)        = 0 0     getuid(0x7FDEA9001D30, 0x7FFF54902AA0, 0x0)      = 0 0     getgid(0x7FDEA9001D35, 0x7FFF54902AA0, 0x0)      = 0 0     access("/etc/localtime\0", 0x4, 0x7)         = 0 0     open_nocancel("/etc/localtime\0", 0x0, 0x0)      = 5 0     fstat64(0x5, 0x7FFF54902B30, 0x0)        = 0 0     read_nocancel(0x5, "TZif\0", 0x2A64)         = 1323 0     close_nocancel(0x5)      = 0 0     thread_selfid(0x10B3AD000, 0x7FFF77A55258, 0x1010101)        = 88910 0     __pthread_sigmask(0x1, 0x10B3ACECC, 0x0)         = 0 0     kevent64(0x5, 0x10B3AC458, 0x1)      = 1 0     madvise(0x10B401000, 0x1000, 0x5)        = 0 0     madvise(0x10B601000, 0x1000, 0x5)        = 0 0     kevent64(0x5, 0x10B3AC4F8, 0x1)      = 1 0     kevent64(0x5, 0x0, 0x0)      = 1 0     madvise(0x10B801000, 0x1000, 0x5)        = 0 0     kevent64(0x5, 0x10B3AC4F8, 0x1)      = 1 0     thread_selfid(0x10BC81000, 0x7FFF77A55258, 0x1010101)        = 88911 0     kevent64(0x5, 0x10BC80D28, 0x1)      = 1 0     kevent64(0x5, 0x7FFF75519130, 0x1)       = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x0, 0x0)      = 1 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     socket(0x20, 0x3, 0x1)       = 7 0     ioctl(0x7, 0x800C6502, 0x7FFF549042D0)       = 0 0     __sysctl(0x7FFF54902460, 0x2, 0x7FFF54902470)        = 0 0     getuid(0x7FDEA9001D45, 0x7FFF54902700, 0x0)      = 0 0     getgid(0x7FDEA9001D4A, 0x7FFF54902700, 0x0)      = 0 0     write(0x1, "Fri Mar 28 10:31:10 2014 : \0", 0x1B)        = 27 0     write(0x1, "PPTP connecting to server '11.22.33.44' (11.22.33.44)...\0", 0x3C)       = 60 0     write(0x1, "\n\0", 0x1)      = 1 0     socket(0x2, 0x1, 0x0)        = 8 0     setsockopt(0x8, 0x6, 0x20)       = 0 0     connect(0x8, 0x7FFF549042E0, 0x10)       = -1 Err#49     __sysctl(0x7FFF54902460, 0x2, 0x7FFF54902470)        = 0 0     getuid(0x7FDEA9001D3F, 0x7FFF54902700, 0x0)      = 0 0     getgid(0x7FDEA9001D44, 0x7FFF54902700, 0x0)      = 0 0     write(0x1, "Fri Mar 28 10:31:10 2014 : \0", 0x1B)        = 27 0     write(0x1, "PPTP connect errno = 49 Can't assign requested address\0", 0x36)     = 54 0     write(0x1, "\n\0", 0x1)      = 1 0     close(0x7)       = 0 0     close(0x8)       = 0 0     workq_kernreturn(0x20, 0x0, 0x1)         = 0 0     kevent64(0x5, 0x7FFF75519130, 0x1)       = -1 Err#4      25 in hexadecimal is 0x19 but this number does not appear anywhere.


title: rebuilding kernel without using apt-get

text: I am setting up my Macbook Air 6.2 with Debian Jessie. since I do not have any wireless, I need to set it up manually, but all documentation I find how to do it are using apt-get               apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms      source How can I do it without apt-get? I did install the linux-headers and other essential packages manually, but now I am stuck rebuilding my kernel without this short and beautiful command .. -.-'


title: What is ELF Magic?

text: I've seen discussion before about ELF magic (most recently the comments in this Security stack exchange question. I've seen it mentioned before, and I've seen it in my own boot logs.. But I'm not sure what it is. The man page on elf is a bit over my head, as I don't do C or lower level languages. As someone who uses Linux as an every day operating system, what is ELF?


title: How can I figure out why gnome-panel is frequently misbehaving?

text: On my system (Debian Lenny AMD64), `gnome-panel` seems to act up now and again. I've not found a way to force it to happen, but it seems to be related to launching processes. Basically, I launch some process, and I see 1 core max itself out, and the taskbar freezes. I `pkill gnome-panel`, the taskbar reappears, and everything is ok. If I don't notice it, eventually my entire computer freezes and I have to hard boot. How would I go about getting some kind of information on why this is happening that could help me or developers? Is there a debug build or something I could run?


title: Why do some default bindkey keys do not work in tcsh?

text: I'm using tcsh and I'm seeing that some of my custom and some of the default bindkey bindings do not work. Why don't they work? For example: I load some default bindings: `bindkey -e` I check the default bindings for backward-word `bindkey | grep backward-word` and see:               "\302"         ->  backward-word     "\342"         ->  backward-word     "^[B"          -> backward-word     "^[b"          -> backward-word      When I try to use backward-word, Alt+Shift+b works just fine, but Alt+b does not work. What gives? I try to create a new binding for backward-word `bindkey "^[u" backward-word`, but when I try to use it (Alt+u), it acts like backward-char instead.


title: How do I add PC BSD / FreeBSD to Grub 2 boot loader?

text: I have Ubuntu 10.04 installed as my primary operating system, and I installed PC BSD in a different partition: `/dev/sda4` without installing it's boot loader. I figured out that I need to edit `/etc/grub.d/40_custom` to add an entry for PC-BSD. So far, nothing seems to work, though. EDIT: this sort of works, but doesn't fully boot the OS, it then asks me for the MOUNTROOT partition.               menuentry "PC-BSD 8.1" {         insmod ufs2         set root=(hd0,4)         kfreebsd /boot/kernel/kernel     }      The selected answer below is correct. If you are dual-booting with Linux I suggest _NOT_ installing the PC-BSD bootloader as the documentation suggests, unless you enjoy pain.


title: Getting a short wifi password to work on Linux Mint

text: Wifi password became a problem to me. My wifi password consists of only 4 letters but my Linux Mint 12 is expecting more than 7 letters - until then connect button is disabled. Can I work around this issue?


title: linux disk caching affects access times reported by stat?

text: On Ubuntu 12.04 I did the following   1. stat a file   2. cat the same file   3. stat the file again   4. cat the file again after 5 min   5. stat the file The access time reported at 3. reflects the point at which 2. was run. However, the access time reported at 5. coincides with 2. and not 4. Is this because Linux serves the file out of cache and avoids disk access in the second instance? Also is there a way to retrieve a list of files that are currently resident in disk cache?


title: What File Transferring Method (i.e. FTP) Can I Use for rlogin (Solaris 8 on SPARC)

text: For all my other Unix Virtual Machines, I use `SSH` and I use WinSCP to transfer files from my Windows Vista machine to the VM's. Now, One of the VM's is using `rlogin`, **What can I use to transfer files from my machine to the VM?** I use PuTTY to connect remotely to the machine, but through `rlogin`. Please can someone help me? Thanks.


title: How to generate folder ownership lists for each user?

text: I'd like to generate several separate lists for each user in Ubuntu. The lists contains the files and folders belong to each user. Using the command following list me all the users in the system:               cat /etc/passwd | awk -F: '{print $1;}'      Suppose "user1" is the first result, I'd like to get the list as:               find / -user "user1" > user1.txt      Thus, my problem is how can I get all the lists using commands as little as possible. Thanks in advance.


title: Git auto-complete

text: I am using Git as many of you do. Also, I don't use any GUI for that — just CLI. So I was wondering: are there any way to make Git commands (`git status`, `git checkout` etc.) complete themselves when hitting Tab? Like other CLI commands do. P.S. I'm using Arch Linux, if that anyhow matters.


title: How can I setup a SOCKS4 or 5 proxy on CentOS 5.8?

text: I live in Iran and due to its restrict censorship, We all have extreme difficulties accessing normal sites and services. So I thought this would be a great idea to setup a proxy server on my VPS, so that I myself could find a way around this censorship. Can anyone show me a step by step working tutorial on this matter? Or guide me in the right direction? I will be grateful.


title: Find out if a specific device is an USB mass storage

text: # Context I'm automating SD card imaging from an existing `dd` factory image. The SD card is always connected through an external USB card reader and thus appears in the system as a SCSI block device `/dev/sd*`. Currently the syntax of my command is: `write-image DEVICE` where `DEVICE` is the SD card block device, eg. `/dev/sdd`. # Problem I'm already doing a basic check on `DEVICE` to verify it is of the form `/dev/sd*` but this is not enough: I fear the users (production people not used to Linux) make a mistake and specify another seemingly valid device, eg. `/dev/sda`. You can see the looming catastrophe, especially since my imaging script needs root privileges (not to write the image itself, mind you, but to modify the SD card afterwards, including adjusting a partition's size depending on the SD card's real size)... # Question I would like to verify that the specified device actually is some USB mass storage (or at the very least a removable device) so that I can protect the system disks from being trashed accidentally. How can I do that? I found nothing relevant in `/proc` or on the web, I'm quite at loss now.


I tried to compile some C code to get object file from a shell prompt:               $cc a.c        But this gives me the following error:               /usr/ucb/cc:  language optional software package not installed      How can I compile C code?


title: Cheap 100% Debian compatible ultrabooks

text: I'm looking for relatively cheap ultrabooks with 100% Debian compatible features. I have several ultrabooks on my list but they contain some additional features which i don't need (additional graphic card or 'beats' studio). When reading the reviews everyone mention that there are 'minor' issues with running linux on them - mute indicator.


title: How to convert a PowerPoint ppt file into HTML files?

text: I have to find a free, gratis command line solution to convert primary Microsoft PowerPoint presentations into HTML files (1 HTML file per foil) on Linux (Debian, OpenSuse). It would be nice if the solution supports OpenOffice Impress presentations as well but this is not necessary. What is/are solution/s for this matter?


title: mv a file to /dev/null breaks dev/null

text: If I do: `touch file; mv file /dev/null` as root, `/dev/null` disappears. `ls -lad /dev/null` results in no such file or directory. This breaks applications which depend on `/dev/null` like SSH and can be resolved by doing `mknod /dev/null c 1 3; chmod 666 /dev/null`. Why does moving a regular file to this special file result in the disappearance of `/dev/null`? To clarify, this was for testing purposes, and I understand how the `mv` command works. What I am curious about is why `ls -la /dev/null` before replacing it with a regular file shows the expected output, but afterwards it shows that `/dev/null` does not exist even though a file was allegedly created via the original `mv` command and the file command shows ASCII Text. I think this must be a combination of the `ls` command behavior in conjunction with `devfs` when a non special file replaces a character/special file. This is on Mac OS X, behaviors may vary on other OS's.


title: How to change the default program for a specific file extension system-wise in kde or xfce?

text: I'd like to have certain file extensions to be opened with some specific programs. What are the files the edit ? I have found in /usr/share/appplications/default.list but it doesn't work.


title: Add arguments from previous command to zsh completion

text: In zsh (as well as bash) you can use some history word expansions to denote arguments from previous commands. This example shows getting the 2nd parameter from the previous command in history with `!:#` expansion:               % echo foo bar baz     foo bar baz     % echo !:2     echo bar     bar      I often forget exactly what # parameter a particular argument is and typing `!:#` isn't always that quick when I do remember which arg it is. I know about `meta-.` to replace the last argument, but sometimes it isn't the last arg that I want. I'd like to add the arguments from the previous command as suggestions to complete any command that I'm typing in zsh. I was able to figure out how to create a shell function that can create an array of arguments (0..N) from the last command and bind it to a particular command.               _last_command_args() {         last_command=$history[$[HISTCMD-1]]         last_command_array=("${(s/ /)last_command}")          _sep_parts last_command_array     }          # trying to get last_command_args to be suggested for any command, this just works for foo     compdef _last_command_args foo      This is what it looks like for completing just foo where I hit the tab key at `<TAB>`:               % echo bar baz qux     bar baz qux     % foo <TAB>     bar   baz   echo  qux       This works great for completing the command "foo", but I'd like these to be options on any zsh expansion that I do. I think it's got something to do with the zstyle completer stuff, but after a few hours of hacking around I realized I'm out of my depth. How can I get the arguments from my previous command as suggested completions for any command in zsh? I've got my full zshrc compinstall file shared out on bitbucket if that helps. Lots of it is cribbed from a variety of sources and some of it I've hacked together myself. UPDATE: @Julien Nicoulaud's answer got me close, I'm marking it as accepted as it got me where I needed to get. With my particular config, using the suggested:               zstyle ':completion:*' completer _last_command_args _complete      Didn't quite work for me as it was causing tab completion to only display the list of arguments from the last command (though it'd actually complete with filenames as well, just not display them). Changing the order to `_complete _last_command_args` did the reverse. It'd display the normal filenames, but not last_command_args I'm guessing this has something to do with the way completer works. I think it only displays the output from the first method that returns successfully, but I'm having trouble parsing the zsh source to understand fully what's going on. I was able to tweak my method to include a call to `_complete` so that it showed both last argument commands as well as the regular autocomplete stuff. Not quite as separated, but works well enough for me. Here's the full function I used along with the other zstyle stuff I have:               # adds the arguments from the last commadn to the autocomplete list     # I wasn't able to get this to work standalone and still print out both regular     # completion plus the last args, but this works well enough.     _complete_plus_last_command_args() {         last_command=$history[$[HISTCMD-1]]         last_command_array=("${(s/ /)last_command}")          _sep_parts last_command_array         _complete      }               _force_rehash() {       (( CURRENT == 1 )) && rehash       return 1  # Because we didn't really complete anything     }          zstyle ':completion:::::' completer _force_rehash _complete_plus_last_command_args _approximate       Other zstyle lines I have, not necessary for this to work, but could affect why this works for me:               zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'     zstyle ':completion:*:descriptions' format "- %d -"     zstyle ':completion:*:corrections' format "- %d - (errors %e})"     zstyle ':completion:*:default' list-prompt '%S%M matches%s'     zstyle ':completion:*' group-name ''     zstyle ':completion:*:manuals' separate-sections true     zstyle ':completion:*' menu select     zstyle ':completion:*' verbose yes      Now, if I'm in a directory with `file1.txt` and `file2.txt`, and my last command was `echo foo bar baz`, I get this for autocomplete which is just what I wanted:               % ls     bar   baz   echo  foo      - files -     file1.txt   file2.txt


title: nc both fails and succeeds

text: Platform: RHEL 5.10 netcat Version: 1.84-10.fc6 I was trying to figure out if my inability to ssh was TCP-level and usually I use `nc` for this. This time, however, I got something unexpected.               [jadavis6@ditirlns01 ~]$ nc -vz dixxxldv02.xxx.xxx 22 -w 15     nc: connect to dixxxldv02.xxx.xxx port 22 (tcp) timed out: Operation now in progress     Connection to dixxxldv02.ncat.edu 22 port [tcp/ssh] succeeded!      Normally if it can't connect within the specified timeout it just prints the first line. Thinking it was just some weird race condition (like the TCP connection kept completing just as I was approaching timeout) I lengthened the timeout period to 30 seconds but got the same exact results. Telnet also fails so I think there is an IDS/Network Firewall blocking the traffic. I was just curious if anyone has seen this before or what it mean.


title: What are ConsoleKit and PolicyKit? How do they work?

text: I've seen that recent GNU/Linux are using ConsoleKit and PolicyKit. What are they for? How do they work? The best answer should explain what kind of problem each one tries to solve, and how they manage to solve it. I'm a long-time GNU/Linux user, from a time when such things didn't exist. I've been using Slackware and recently Gentoo. I'm an advanced user/admin/developer, so the answer can (and should!) be as detailed and as accurate as possible. I want to understand how these things work, so I can use them (as an user or as a developer) the best possible way.


title: saving data from a failing drive

text: An external 3½" HDD seems to be in danger of failing — it's making ticking sounds when idle. I've acquired a replacement drive, and want to know the best strategy to get the data off of the dubious drive with the best chance of saving as much as possible. There are some directories that are more important than others. However, I'm guessing that picking and choosing directories is going to reduce my chances of saving the whole thing. I would also have to mount it, dump a file listing, and then unmount it in order to be able to effectively prioritize directories. Adding in the fact that it's time-consuming to do this, I'm leaning away from this approach. I've considered just using `dd`, but I'm not sure how it would handle read errors or other problems that might prevent only certain parts of the data from being rescued, or which could be overcome with some retries, but not so many that they endanger other parts of the drive from being saved. I guess ideally it would do a single pass to get as much as possible and then go back to retry anything that was missed due to errors. Is it possible that copying more slowly — e.g. pausing every x MB/GB — would be better than just running the operation full tilt, for example to avoid any overheating issues? For the "where is your backup" crowd: this actually is my backup drive, but it also contains some non-critical and bulky stuff, like music, that aren't backups, i.e. aren't backed up. The drive has not exhibited any clear signs of failure other than this somewhat ominous sound. I did have to fsck a few errors recently — orphaned inodes, incorrect free blocks/inodes counts, inode bitmap differences, zero dtime on deleted inodes; about 20 errors in all. The filesystem of the partition is ext3.


title: Lynx is trying to unzip my downloads

text: I am having a problem with the Lynx text browser. When I try to download a some tar.gz files, Lynx is not downloading it. It is putting it in a tmp directory and then trying to unpack it with the command:               /bin/tar tvf -      It does not always do this. Often it does just download the file, but if it is a link on a sourceforge site (one of those redirect "your download will start shortly" links), then it does the unwanted tvf behavior. Obviously this is wrong because it is GZIPPED file, so Lynx then hangs. The apparent reason it is doing this is that there is a line in /etc/mailcap that reads like this:               application/x-tar; /bin/tar tfv -; print=/bin/tar tvf - [etc, more gobblediguck]      This is doubly wrong because I don't want Lynx to put it in a tmp directory and unpack the file. I want it to download it to the current directory. Ideally, I do not want to monkey with my mailcap settings, having no experience with such things. How can I get Lynx to just download tar.gz files when they are coming from sourceforge/auto download sites?


title: Fedora 20. Authentication requires a different password from su

text: In Fedora 20 (using Mate desktop) I have tried to change the default keyboard layout from US English to UK English, but am asked for "Authentication". The password I have for `su` is not accepted, and I do not recall having set a different one anywhere. Please, why does this happen, and how to I get round it? This may be two questions: How to authenticate? and How to set the default keyboard layout? I hope this is acceptable.


title: Split large file into chunks without splitting entry

text: I have a rather large .msg file formatted in the UIEE format.               $ wc -l big_db.msg     8726593 big_db.msg      Essentially, the file is made up of entries of various length that look something like this:               UR|1     AA|Condon, Richard     TI|Prizzi's Family     CN|Collectable- Good/Good     MT|FICTION     PU|G.P. Putnam & Sons     DP|1986     ED|First Printing.     BD|Hard Cover     NT|0399132104     KE|MAFIA     KE|FICTION     PR|44.9     XA|4     XB|1     XC|BO     XD|S          UR|10     AA|Gariepy, Henry     TI|Portraits of Perseverance     CN|Good/No Jacket     MT|SOLD     PU|Victor Books     DP|1989     BD|Mass Market Paperback     NT|1989 tpb g 100 meditations from the Book of Job "This book...help you     NT| persevere through the struggles of your life..."     KE|Bible     KE|religion     KE|Job     KE|meditations     PR|28.4     XA|4     XB|5     XC|BO     XD|S      This is an examples of two entries, separated by a blank line. I wish to split this big file into smaller files without breaking an entry into two files. Each individual entry is separated by a newline (a completely blank line) in the file. I wish to break this 8.7 million line file into 15 files. I understand that tools like `split` exist but I'm not quite sure how to split the file but only have it split on a newline so a single entry doesn't get broken into multiple files.


title: How to read/write to tty* device?

text: I have a device that sends information over USB to my computer. Arch Linux sets up this device by creating a file named `ttyUSB0` in `/dev/`. I have been using `GTKterm` to receive this incoming information and display it in an emulated terminal window. My question is, how exactly does `GTKterm` read/write to this `ttyUSB0` file, and where might I start learning how to implement similar functionality? That is, in the most basic form, how might I write a character to `ttyUSB0`, or, in contrast, receive a byte and write it to a file?


title: Using sudo in openSUSE without actually changing to root user (i.e., like in Ubuntu)

text: I recently started trying openSUSE 12.3 after having used Ubuntu for a few years. I'm still getting used to openSUSE's treatment of `su` (and `sudo`) vs. Ubuntu's use of `sudo`. I've been reading the openSUSE manual, but can't figure out answers to two related questions: 1) In a previous question at http://askubuntu.com/questions/236859/are-there- adverse-effects-from-or-a-better-way-than-writing-to-run-or-dev-sh, I asked about writing a decrypted `gpg` file temporarily to `/run` using the `gpg --output` flag so that the decrypted file would never touch the hard disk. In order to write to `/run`, however, I needed to use `sudo` in Ubuntu (i.e., `sudo gpg --output '/run/temporary_file_name' etc.`). When I try to do the same thing in openSUSE (using either `sudo` or `su`), I get an error message from `gpg`, presumably because the root user cannot see my user account's gpg keys. Can this use of ``sudo` from Ubuntu, in which `sudo` seems to use the same preferences / gpg keys as the regular user, be replicated in openSUSE? I could use `gpg etc. | tee etc.`, I suppose, but that seems unwieldy compared to Ubuntu's way of doing things. 2) I have several bash scripts from Ubuntu that require root privileges for some, but not all, lines (e.g., copying files that I don't want to get owned by root, but then installing new software, which requires root privileges). In Ubuntu, I could just have some lines start with `sudo`. `sudo some_command` doesn't always seem to work in openSUSE, though. Is the best way to adapt these scripts for openSUSE to use `su -c 'command'` on those lines of the script? If I use `su` by itself in the script, the script stops working after I enter the root password. Please note that, while I'm asking about openSUSE specifically, this question presumably applied to many non-Ubuntu distros.


title: "/sbin/yast: fork: Cannot allocate memory" on openSUSE 10.1

text: I guess I'll come across as a total newbie for asking this, but I get the above message right after starting an ssh session. The reason I opened the ssh session was that I came across a 500 internal server error on the plesk panel. I tried to look around for similar problems, but all answers I find seem very specific toward variations on this problem. I guess it is a very generic message, if I should provide more info, please let me know what to run.               free -m                  total       used       free     shared    buffers     cached     Mem:          5020        202       4817          0          0          0     -/+ buffers/cache:        202       4817     Swap:            0          0          0               ulimit -a     core file size          (blocks, -c) 0     data seg size           (kbytes, -d) unlimited     file size               (blocks, -f) unlimited     pending signals                 (-i) 16375     max locked memory       (kbytes, -l) 32     max memory size         (kbytes, -m) unlimited     open files                      (-n) 1024     pipe size            (512 bytes, -p) 8     POSIX message queues     (bytes, -q) 819200     stack size              (kbytes, -s) 10240     cpu time               (seconds, -t) unlimited     max user processes              (-u) 16375     virtual memory          (kbytes, -v) unlimited     file locks                      (-x) unlimited          cat /proc/user_beancounters     Version: 2.5            uid  resource           held    maxheld    barrier      limit    failcnt       1231234:  kmemsize        6061008    6064704   17024866   19647330          0                 lockedpages           0          0       3800       4096          0                 privvmpages      138119     138227     138256     202568     755228                 shmpages          60296      60296     131072     131072          0                 dummy                 0          0 2147483647 2147483647          0                 numproc              64         64        232        232          0                 physpages         30682      30671          0 2147483647          0                 vmguarpages           0          0      66400 2147483647          0                 oomguarpages      50128      50117 2147483647 2147483647          0                 numtcpsock           28         28        500        500          0                 numflock             14         14        200        232          0                 numpty                1          1         64         64          0                 numsiginfo            0          0        512        512          0                 tcpsndbuf        275520     275520    4683256    6102456          0                 tcprcvbuf        458752     458752    4683256    6102456          0                 othersockbuf      48576      49280    1503232    4063232          0                 dgramrcvbuf           0          0     240000     262144          0                 numothersock         38         38        382        382          1                 dcachesize       773048     774892    2194304    2317184          0                 numfile            2874       2874       5432       5432       6308                 dummy                 0          0          0          0          0                 dummy                 0          0          0          0          0                 dummy                 0          0          0          0          0                 numiptent            64         64        128        128          0


title: What does "XOFF ignored, mumble mumble" error mean?

text: While trying to save a file out of Nano the other day, I got an error message saying "XOFF ignored, mumble mumble". I have no idea what that's supposed to mean. Any insights?


title: Prevent Java to escalate CPU usage on Slackware64?

text: I use Slackware64-current on my work laptop and though I love running Slackware, sometimes it hangs on me near to the point of starting considering falling back to Windows. I develop on Java and use Eclipse IDE. I know Java IDE's are not supposed to be lightweight, but, on occasions, it really gets stuck and as I normally have a console open, I run top only to find out Java is taking 90%+ of CPU load. How can I make sure it does not gets (much!) in my way? I know this is a rather open question, but I'll be more than happy to provide more details as needed. EDIT: Hardware specs               CPU: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz     RAM: 4GiB (probably DDR3, not sure though!)


title: What are the other congestion control algorithms specially designed for lossy Wireless Networks like LTE and WiMax?

text: I am trying different congestion control algorithms for getting maximum throughput and minimum delay across my setup for TCP flow.Please suggest other available algorithms apart from > Veno, Westwood ,Reno and Cubic whose implementation (or Kernel Modules) are freely available on Internet ?? And also suggest if there is some other way of obtaining higher throughput in tcp runs between linux (Fedora) and Windows 7's tcp protocol stack at different ends.


title: Solid State drive vs. traditional hard disk in a virtual server environment

text: I am currently considering upgrading my virtual-hosting plan because of very bad write performance (mostly writing to a MySQL database, but I notice it also when compiling a program or copying files - or any other write operation). At some times (probably when many other customers on other vhosts are using the hard-drive) a write can take up to several dozens(!) of seconds, even when it's a small write operation, which is unacceptable. Read performance is much better, probably because of good caching (in fact when we start using the database at the morning each day, we notice how slow it is at first which would suggest that the cache is being filled - but that is OK with us). I don't know the specifics of how the hard-drive is used and prioritized in a Linux/vhost environment, but I can imagine that a lot of time is lost by jumping between vhost-partitions. On the other hand, it may also be possible that an SSD pretty much behaves like an HDD (only a bit faster, which would not be enough for me - 20 instead of 30 seconds is still unacceptable) from the user's point of view. Does anybody have experience with both HDDs and SSDs in an vhost-environment? Is there a different "character" (regarding relative speeds of reads and writes and especially latency) noticeable as a user? How is the hard-drive prioritized and in which ways does an SSD make a difference, especially on a overloaded vhost-system? Do you think that changing to an SSD can prevent this extremely bad write- performance spikes?


title: System sending SIGTERM and SIGKILL during normal work

text: I have a program (C++) that works with TCP sockets in multithreaded manner. The multithreading is intensive, about 100 threads (POSIX threads). Sometimes, not quite sure when, the program gets terminated by `SIGTERM`. After some googling I found out that it is not normal for system to send `SIGTERM`. I've decided to look what happens if I ignore the signal. Now the system sends `SIGKILL`. I assume it tries with `SIGTERM` and when the application does not terminate, the system kills it. I have tried running it in gdb, and got no signals. I've run it in valgrind, no signals. No valgrind errors either. Memory consumption was normal, it seems I have no memory leaks. Upon exit it had 7Mb heap in use. Nothing suspicious in `/var/log/messages, /var/log/syslogd`. The system is Debian 2.6.32-5. Basically, the question is why may the system send `SIGTERM` followed by `SIGKILL` to an arbitrary process? And how can I stop at that point to see what happens (gdb alters the behavior).


title: Problems setting up TigerVNC and firewall

text: I have a box running a fresh install of Fedora 15. I've installed TigerVNC server on it and client on my Windows machine. I've added `-A INPUT -m state --state NET -m tcp -p tcp --dport 5900 -j ACCEPT` to `/etc/sysconfig/iptables` then, added to `/etc/sysconfig/vncservers`: VNCSERVER="1:UNAME" VNCSERVERARGS[1]="-geometry 1024x768" then I try to start the server, but I get `job failed. See bla bla for details` ((mentions some files i have no idea to find)) What am I doing wrong? -thanks! **iptables -nvL:**               Chain INPUT (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination       173 12044 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED         0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0         0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0         0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22      1518 85858 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited         0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:5900          Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination         0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited          Chain OUTPUT (policy ACCEPT 1613 packets, 146K bytes)      pkts bytes target     prot opt in     out     source               destination``      **systemctl:**               vncserver.service         loaded failed failed        LSB: start|stop|restart|try-restart|status|force-reload vncserver


title: rm command returns a message [1] 12345 What does this mean?

text: I'm trying to remove a file and I keep getting a message similar to: > [1] 12345 and nothing happens, I run a directory search (dir) and the file remains and I get a stopped message


title: How can I configure fair bandwidth sharing between cgroups?

text: It's fairly easy to use `tc` with Stochastic Fairness Queueing (SFQ) to configure fair bandwidth sharing between _flows_ , but an application can open multiple flows and get an unfair share of bandwidth. Is it possible to configure fair bandwidth sharing between _applications_ instead? Grouping each application into a cgroup seems like a clear first step. If SFQ supported hashing on the class ID, it would be easy to use `tc filter` to assign each cgroup a class ID. Unfortunately, SFQ doesn't seem to support this. Another promising approach is to use CBQ, which does Weighted Round Robin across classes. Unfortunately, making the weights all equal doesn't seem to work. Is there another way to fairly share bandwidth between cgroups?


title: What is the difference between egrep, fgrep, find and grep commands?

text: i am new to linux console, however i know i can use grep to find files however i am wondering what the particular difference between these common commands ? They all seems to be equal in meaning to me.               egrep      fgrep     grep      find     locate      as windows search and find command.


title: Handbrake for wheezy?

text: Has anyone figured out how to install/backport a Debian Handbrake package on Debian wheezy? The only version of Handbrake currently in Debian is in experimental, and the dependencies are not available on wheezy, so I can't easily rebuild it. In particular the version of `libav` used is the version in experimental. The unofficial deb-multimedia repository is a possibility, but I have had problems in the past with its packages being incompatible with Debian. Using a Ubuntu PPA might also be a possibility. But Linux multimedia is a complicated mess, and I would prefer not to have to mess with it.


title: Package php5-json breaks firephp

text: ### Background Recently I upgraded php to version 5.5. Within this upgrade module for json was moved out from php5 package into a new package php5-json. So I installed it. **Now the connection with firephp (and firebug).**   Before sending, firephp::log encodes the variable with json_encode.   There might occur an issue with json_encode. The json_encode may fail to encode the input variable. This might happen in a string with unencoded unicode or a string with some ill encoded characters. ### Behaviour in previous version of php   * In firebug instead of the value with the wrong coding white space appears.   * After the wrong value firebug continues to display next values which arrived from firephp. ### Behaviour with separate php5-json   * When the ill encoded value arrives to firebug, following error message appears: > SyntaxError: JSON.parse: unexpected character   >  chrome://firephp/content/lib/renderer.js   >  Line 159 >   * After this listing logs from firephp stops. > > > ### Question I understand that there was an 'unexpected character'. But I'd just like to move on and see the following messages. Not stop on the first unexpected character.   What shall I do to solve the issue? Or at least get back to the previous bevior? ### Software versions:   * Debian testing jessie    * Linux host 3.10-2-amd64 #1 SMP Debian 3.10.5-1 (2013-08-07) x86_64 GNU/Linux    * php5 5.5.1+dfsg-2    * php5-json 1.3.1+dfsg-1    * iceweasel 22.0    * FirePHPCore-0.3.2    * Firebug 1.11.4    * Firephp 0.7.2  ### Edit: I also can see in Firebug header X-Wf-1-1-1-2: > > [{"Type":"LOG","Label":"$someVar","File":"/home/GIT/www/some/path/someFile.php","Line":"156"},] Which **does** miss the value part and thus is **not valid JSON** , which is why the rendering fails. The header with the correct message, which gets printed: > [{"Type":"LOG","Label":"POST > data","File":"/home/GIT/www/some/path/someFile.php","Line":"22"},{"data":{"myarray":["117"]},"getA":"true","getB":"true"}] ### Edit2: I submitted this as a bug in Debian 719942. But it doesn't seem that someone is willing to have a look at it :-(


title: `tail -f` until text is seen

text: I've got a CI server with a command-line interface that allows me to remotely kick-off a job (`jenkins` CI server and the `jenkins-cli.jar` tool). After I kick the job off I `tail -f` the log (sorry for the messy command):               ssh -t my-jenkins-host.com "tail -f \"/var/lib/jenkins/jobs/$job_name/builds/\`ls -ltr /var/lib/jenkins/jobs/$job_name/builds/ | grep '^l' | tail -n 1|awk '{print \$9}'\`/log\""      After the job successfully completes, usually after at least 5 minutes, I get the following line on the output:               Finished: SUCCESS      Is there a good way to stop tailing the log at this point? i.e. is there like a `tail_until 'some line' my-file.log` command? _**BONUS:_** extra credit if you can supply an answer that returns 0 when SUCCESS is matched, 1 when FAILURE is matched, and your solution works on mac! (which i believe is bsd based)


title: Setting up boot scripts for BeagleBone/Angstrom

text: I'm working on setting up the pinmux on a BeagleBone so that I can access multiple UARTS. The OS is Angstrom Linux (the demo image, if that helps). I have a shell script:               #!/bin/sh          echo "Configuring Pinmux"          echo 0 > /sys/kernel/debug/omap_mux/uart1_txd     echo 20> /sys/kernel/debug/omap_mux/uart1_rxd          echo "UART 1 (TX):"     cat /sys/kernel/debug/omap_mux/uart1_txd     echo          echo "UART 1 (RX):"     cat /sys/kernel/debug/omap_mux/uart1_rxd     echo          echo 1 > /sys/kernel/debug/omap_mux/spi0_d0     echo 21> /sys/kernel/debug/omap_mux/spi0_sclk          echo "UART 2 (TX):"     cat /sys/kernel/debug/omap_mux/spi0_d0     echo          echo "UART 2 (RX):"     cat /sys/kernel/debug/omap_mux/spi0_sclk     echo      Which sets up the UARTS for use. Now, I want this script to run on boot, so that I don't have to mess with it every time. Where should I put this/ make a link in order to do that?


title: How to display the name of the current Virtualenv?

text: I'm using `virtualenv`, `virtualenvwrapper`, `zsh`, `oh-my-zsh`, terminator, on Crunchbang. I'm trying to display the name of the current `virtualenv` like so               workon example     (example)...       I've tried many solutions none seems to work, here's my .zshrc file, I know it's no big deal to fix it but I can't find the right solution. It has been a long time since the last time I used Linux for Django development, I forgot what I used to do. Right now, I see `username@crunchbang`, I can't tell which virtualenv I'm using.


title: How can I sort a list of file names by some substring of the name?

text: I have a number of files with names like:               beginning_num1_734_num2_1.363e+12_num3_800.pdf     beginning_num1_735_num2_7.453e+13_num3_800.pdf     beginning_num1_1007_num2_9.453e+12_num3_1200.pdf      I'd like to be able to sort a list of these filenames by the various `num`s, and pass the sorted list to various command line utilities. For example, if I were sorting by `num2`, I'd want the order:               beginning_num1_734_num2_1.363e+12_num3_800.pdf     beginning_num1_1007_num2_9.453e+12_num3_1200.pdf     beginning_num1_735_num2_7.453e+13_num3_800.pdf      I have a python script to do this, but it seems like it _should_ be possible with nothing but filters like `sed` and `sort`. Is there any easy way to sort by parts of a file name, using only common command line filters?


title: Delete specific line number(s) from a text file using sed?

text: I want to delete one or more specific line numbers from a file. How would I do this using sed?


title: Why does echo >file use more real time than echo | sed >file?

text: The example, below, surprised me. It seems to be counter intuitive... aside from the fact that there is a whisker more _user time_ for the `echo | sed` combo. Why is `echo` using so much _sys time_ when it runs alone, or should the question be, How does `sed` change the state of play? It seems that `echo` would needs to do the same _echo-ing_ in both cases...               time echo -n a\ {1..1000000}\ c$'\n' >file          # real    0m9.481s     # user    0m5.304s     # sys     0m4.172s          time echo -n a\ {1..1000000}\ c$'\n' |sed s/^\ // >file          # real    0m5.955s     # user    0m5.488s     # sys     0m1.580s


title: Vimrc autosourcing not working

text: My vim configuration lives in `$HOME/.vim/vimrc`, which is symlinked to `~/.vimrc`. Inside my vimrc I have:               if has("autocmd")       autocmd bufwritepost vimrc source $HOME/.vim/vimrc     endif      But is not working. I also tried sourcing `$MYVIMRC`. Am I missing something?


title: How can I tell what version of OpenGL my machine supports on Arch Linux?

text: How can I tell what OpenGL versions are supported on my (Arch Linux) machine?


title: Looking for an advanced Linux podcast

text: I am looking for some more advanced linux podcasts then I have been able to find so far. I commute 3+ hours each way. This is a great time to catch up on tech, learn some things I may have missed.   * Looking for some enterprise level discussions line RHEL or CentOS.   * Looking for something more CLI based as I never use the gui.   * Looking for anything above entry level/new to linux casts. Here's to hoping there is a linux podcasts for practicing professionals, not just entry level hobbyists trying to convert people to the OS. Ideally I would love a more advanced format with some in depth discussions on regex/cli/bash scripting/services/etc. I have tried _linux for the rest of us_ , _everyday linux_ , _podnutz pro_ , _linux reality_ , etc. The majority seem to follow the "morning radio" style format, but I would love to find any podcasts that keep my mind engaged during my 3 hour commute. I am willing to try any podcasts you want to suggest I will take a look at. Thanks This is not bashing, trolling, polling etc. The basic podcasts help lots of new users come to our side. However, I've been using linux since the first edition of "Running Linux" came out. I need something with some bite! Just an honest engineer looking for some new podcasts to broaden my mind. Thanks all!


title: How to upgrade from Ipython Notebook .12 to .13 (Linux)?

text: I installed using `sudo apt-get install ipython-notebook`. But when I check `ipython notebook --version` it is 0.12.1. I am new to Linux, so forgive me if this is obvious, but I tried `sudo apt-get --only-upgrade install ipython notebook`, and it did not work. I could not find other advice.


title: ubuntu + how to install the patch command

text: Please advice how to install the patch command on Ubuntu Linux I download the following file , patch_2.6-2ubuntu1_amd64.deb ( from site - http://packages.ubuntu.com/lucid/patch ) But not clearly how to install it? I tried by ./patch_2.6-2ubuntu1_amd64.deb , ( but I get errors ) Please advice how to install the pkg patch_2.6-2ubuntu1_amd64.deb In order to use thepatch command on my unbuntu linux


title: Only print rows that have 2 or more fields?

text: I've got a text file and I'm trying to figure out how to filter out any lines with data in only 1 field, leaving lines with 2 fields. I came across the following code: `awk '$NF > 1'` but I can't get it to work as I want it to. Any ideas what I might be doing wrong? Here is a sample of my data:               simpledaddy11,EastOfBrussels     simpledaddy11,thomaswatkins     simpledaddy11,     simpledaddy11,     simpledaddy11,     simpledaddy11,     simpledaddy11,     simpledaddy11,     simpledaddy11     Moral_Animal,EastOfBrussels     Moral_Animal,     Moral_Animal,     Moral_Animal,     Moral_Animal,     Moral_Animal,     Moral_Animal,     Moral_Animal,     Moral_Animal     skilur_ua,EastOfBrussels     skilur_ua,thomaswatkins     skilur_ua,     skilur_ua,     skilur_ua,     skilur_ua,      Here is what I want to end up with:               simpledaddy11,EastOfBrussels     simpledaddy11,thomaswatkins     Moral_Animal,EastOfBrussels     skilur_ua,EastOfBrussels     skilur_ua,thomaswatkins      Thanks for the help!


title: Backup of svn repository and mysql database on daily basis

text: How do I instruct Ubuntu 13.10 server to:   1. zip svn repository   2. dump mysql database into .sql script   3. tar both files   4. copy backup tar onto sdb disk Are there any premade tools for such kind of operations?


title: How to execute a script on gdm login automatically for all users?

text: What file should I modify to execute some instructions when any user logs in through gdm? I tried `/etc/bashrc` but that is executed ony when starting bash (and each time an xterm is open). I'd like to execute something only once when the user logs in. What I want to do is to "reset" some user preferences each time the user logs on (including the window manager), so the script should run before the WM is initialized.


title: SSH Login Alert Using pam_exec

text: Hi I have been trying to follow the information about pam_exec from here: Ssh login hook? When a user log's in they get:               /etc/pam.d/email-alert.sh failed: exit code 8      My sshd file has this at the end:               session optional pam_exec.so debug seteuid /etc/pam.d/email-alert.sh      My email-alert.sh script has this,               echo 'ALERT - Remote SSH Shell Access (SERVERNAME) on:' `date` `who` |      mail -s "Alert: Remote SSH Access from `who |      cut -d'(' -f2 | cut -d')' -f1`" MYEMAIL@MYEMAIL.com      I have tested the script on its own and it emails me no problem. If anyone could point me in the right direction it would be much appreciated as I've been scratching me brain's out trying to figure it out.


title: mod_rewrite: undefined symbol: lstat error

text: I compiled the mod rewrite for apache (version 1.3.0) however, when I try to run the server I have this error about mod_rewrite:               Syntax error on line 27 of /home/myuser/apache/etc/httpd.conf:     Cannot load /home/myuser/apache/libexec/mod_rewrite.so into server:      /home/myuser/apache/libexec/mod_rewrite.so: undefined symbol: lstat     ./sbin/apachectl start: httpd could not be started      A similar problem is here https://bugzilla.redhat.com/show_bug.cgi?id=101837 but the solution provided does not help me...I get an error after __THROW, the classic "missing , ; before {" and, removing the THROW clause leads me to an "lstat already defined here" (pointing at sys/stat.h header). Can you help me?


title: Splitting and renaming a file

text: I need to split a file with a particular format and rename it later... The Split works fine but I'm unable to refer the $file-$each inside my awk command? Any tips?               for file in *.csv     do       split -n 3 -d -a 2 "$file" "$file--"       for each in $(seq -w 2 10)       do             echo $file--$each            awk '{filename = $file--$each ".txt"  ; print >> filename}' $file--$each       done     done


title: Why is umask setting a different permission for a directory and file I have created?

text: Consider:               [user@server1 ~]$ umask     0770     [user@server1 ~]$ mkdir TEST2; touch TEST2.txt;     [user@server1 ~]$ ls -l     d------rwx 2 user group_name 4096 Mar  5 05:16 TEST2     -------rw- 1 user group_name    0 Mar  5 05:16 TEST2.txt      Now shouldn't the file TEST2.txt have the permission `007` as `umask` is set to `0770` ? Thanks.


title: Virtualbox export appliance

text: I have an Ubuntu OS installed using virtualbox. Inside the Ubuntu OS, I have installed QEMU, GCC for ARM and GDB for communicating between ARM and QEMU. My question is, if I export this image using the "Export Appliance" option from VirtualBox and use it another machine, will that contain the QEMU, GCC for ARM and GDB installation in that image?


title: Scroll inside Screen, or Pause Output

text: I use screen for my command-line tasks while managing the servers where I work. I usually run small commands (mostly file-system tasks) but sometimes I run more extensive tasks (like DBA). The _output_ of those tasks is important to me. Since I use Ubuntu and OS X (both Terminal Windows) for my tasks, yet I need to use screen, the scrolling is not available, so any long output (think a 500-row table from a select) is invisible for me. Mouse-wheel is out of the question. When I say "scroll is invisible for me, I mean this: ![top while using screen, in Mac OS X, while scrolling](http://i.stack.imgur.com/kAIBx.png) I was thinking about two options:   1. Pause (think _paginate_ ) the output of a certain command. When the output begins, it would let me read what's happening, then I press "Enter", then the output continues... until there's nothing more to show.   2. Scroll inside screen. But I don't know if this is possible. Of course, I don't know if those options are actually _possible_. If they are, how can acheive them? Other alternatives will be well received. Thanks!


title: Cannot connect to any localhost connections

text: I'am using Centos 6.5 with latest updates. My problem is that whenever i try to connect to some local service it just hangs for example: # wget               wget 127.0.0.1     --2014-03-11 12:43:42--  http://127.0.0.1/     Connecting to 127.0.0.1:80...     After a while timeout...      # ssh               # ssh 127.0.0.1 -p 6060 -v     OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013     debug1: Reading configuration data /etc/ssh/ssh_config     debug1: Applying options for *     debug1: Connecting to 127.0.0.1 [127.0.0.1] port 6060.     debug1: connect to address 127.0.0.1 port 6060: Connection timed out     ssh: connect to host 127.0.0.1 port 6060: Connection timed out      and it hangs out to timeout. Same with telnet, and same with connecting to irc server. External connections are running fine... # netstat -tpln               # netstat -tpln     Active Internet connections (only servers)     Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name        tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      589/sendmail             tcp        0      0 127.0.0.1:6060              0.0.0.0:*                   LISTEN      520/sshd                 tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      619/nginx                tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      478/sshd                 tcp        0      0 ::1:6060                    :::*                        LISTEN      520/sshd                 tcp        0      0 :::22                       :::*                        LISTEN      478/sshd                  # netstat -rn               # netstat -rn     Kernel IP routing table     Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface     169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 venet0     0.0.0.0         0.0.0.0         0.0.0.0         U         0 0          0 venet0      # iptables I arleady flush out iptables, without luck. Output form iptables:               # iptables -nvL     Chain INPUT (policy ACCEPT 634 packets, 49819 bytes)      pkts bytes target     prot opt in     out     source               destination                   Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)      pkts bytes target     prot opt in     out     source               destination                   Chain OUTPUT (policy ACCEPT 517 packets, 47027 bytes)      pkts bytes target     prot opt in     out     source               destination               # Loopback config               # ip a     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00         inet 127.0.0.1/8 scope host lo         inet6 ::1/128 scope host             valid_lft forever preferred_lft forever     2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN          link/void          inet 127.0.0.1/32 scope host venet0         inet 176.122.224.115/32 brd 176.122.224.115 scope global venet0:0      Turning of SELinux didn't improve it with anything. # ip route show table local               # ip route show table local     local 176.122.224.115 dev venet0  proto kernel  scope host  src 176.122.224.115      broadcast 176.122.224.115 dev venet0  proto kernel  scope link  src 176.122.224.115      broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1      broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1      local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1      local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1       # traceroute               # traceroute 127.0.0.1     traceroute to 127.0.0.1 (127.0.0.1), 30 hops max, 60 byte packets      1  localhost.localdomain (127.0.0.1)  0.029 ms  0.014 ms  0.012 ms      # ping 127.0.0.1 works ok               # ping 127.0.0.1     PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.     64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.024 ms     64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.036 ms      The weirdest thing about it is that, i can connect to ssh, nginx server from **external** address (for ex. computer from which i ssh'ing) without problems. This happens after ISP has rebooted my server. Thing that maybe useful is that, server was frequently updated without reboots.


title: How to change height and width of each page of a pdf

text: I was wondering how to change width and height of each page of a pdf? In my scanned pdf, each page has paper size too big, 31.98 × 49.20 inch. I would like to shrink the width and height to smaller ones which are normally seen in pdf files. Are there some applications or programming tools to accomplish this?


title: Adding public is_rsa.pub to known_hosts automatically - how to?

text: How to automatically add server to known_hosts ? (and not use md5 fingerprint, as I mean secure way, please not send "auto yes/accept" solutions. I want to bring required credentials from server to machine) I'd like to update automatically my ssh `known_hosts` file to accept new server. I assume, that I need to add server's public key (`id_rsa.pub` obtained through secure channel), but what I see is that format is different (I've tried adding like this `awk '{print "server "$1" "$2}' id_rsa.pub > .ssh/known_hosts` with verification failed. Please note that I don't want to use md5 fingerprint due to flaws in md5). If something else than `id_rsa.pub` would be useful I can run commands on server and obtain results though trusted channel. (Please note that it is not network channel (think of physically bringing pendrive from place to another), so `ssh-keyscan` does not solve the problem, what's more id_rsa.pub is key of dropbear server that is not running at server, so only files with keys are available, not server)


title: Is `Tru64 UNIX` open source?

text: Is `Tru64 UNIX` an open source/free or commercial system? Does it work on 32-bit platform? and what are its features in compare with `*BSD` & `Linux` system?


title: killing processes automatically

text: I need to kill all processs in a certain shell excluding certain processes. Like sh which is my shell. And the comand. This is what currently in my shell right now.               rcihp146 :/home/msingh2> ps        PID TTY       TIME COMMAND       8880 pts/258   0:00 ps       5908 pts/258   0:00 sh      But if there are some extra processes I would like to kill all of them excluding the above two. I tried a one liner for this purpose and it didn't work:               rcihp146 :/home/msingh2> ps | awk '{system("kill -9 $1")}'     sh: kill: The number of parameters specified is not correct.     sh: kill: The number of parameters specified is not correct.     sh: kill: The number of parameters specified is not correct.     sh: kill: The number of parameters specified is not correct.      But it works if I only give a specific pid like below:                rcihp146 :/home/msingh2> ps | awk '{system("kill -9 23456")}'      I need to exclude two or three process (like `ps`, `sh`) from being killed. Is there any way to do this?


title: sed inline editing fails for multiple sed statements

text: I want to append `#SB#` at the beginning of every line where it matches a given string ### incron.sh               sed -i -e'/test1/s/^/#SB#/g' file1     sed -i -e'/test2/s/^/#SB#/g' file1     sed -i -e'/test4/s/^/#SB#/g' file1      ### file1               /apps/pmserver $ cat file1     00 45 /ser/bat/ab.sh test1     00 45 /ser/bat/ab.sh test2     00 45 /ser/bat/ab.sh test3     00 45 /ser/bat/ab.sh test4     /apps/pmserver $      I am using Korn Shell. I can output to a new file but it doesn't work if I have more than one `sed` statement in a script as shown above. I am getting error               sed: Not a recognized flag: i      What I am trying to do is comment out a few `crontab` entries belonging to particular team. test1 test2... are their file names and these need to be turned off.


title: Inconsistent behaviour of "wmctrl -i -a <WIN>"

text: I'm trying to use `dmenu` and `wmctrl` to write a script that would present to me a list of all currently open windows and then switch to the one I select. It looks something like this: ![switch_to script](http://i.stack.imgur.com/DuGPi.png) Now, I'm using the window id I get from `wmctrl -l` (for instance, the "0x00c0005c" visible in the screenshot on the 2nd line) to determine exactly which window has been selected (I'm not using the window class because 2 windows belonging to the same application will have the same class, but different ids). The only problem is: `wmctrl -i -a` works sometimes, but doesn't work other times - and some times, it switches, but to the wrong window! It's quite random. After searching online, the only web page I found that even _mentions_ the issue is this one. It says: > WIN as a numerical window ID doesn't seem to work consistently. Perhaps not > all options support it or something crazy is going on. It used to work very > well for me. Re-test. Can anyone tell me how I can resolve or work around this issue? I'm using version 1.07-3 of `wmctrl` from the official repositories on an up- to-date Arch Linux machine, and Awesome Window Manager, if it helps. Thanks


title: Fast way to determine if a file is a SQLite database

text: I am looking for a way to determine file types in a folder with thousands of files. File names do not reveal much and have no extension but are different types. Specifically I am trying to determine if a file is a sqlite database. When using 'file' command, it determines type of 2-3 files in a second. This seems like a good way to adress the problem, except it is too slow. Then I tried opening each file with sqlite3 and check if I get an error. That way I can check 4-5 files per second. Much better, but I think that there might be a better way to do this.


title: Emptying a directory owned by another user weekly

text: I have a temp directory set up where users can place whatever files they need to send to other users via HTTP. The owner of this directory is an SFTP user, and cannot run cron jobs. I have one shell user that can run cron jobs, but does not have permission to edit files in the SFTP user's directory. I have an admin user that can access the SFTP user's directory when using sudo, but can't (read: I'd really rather not) run cron jobs. So, here's the conundrum. How do I get a nightly cron job to run as a shell user to delete files older than 1 week within the SFTP user's directory, with the admin user's privileges?


title: How to return the exit code? Error: return: Reading: numeric argument required

text: Here's a simplified version of my script. My question is, How do I return the exit code from `apt-get` in this case?               #!/bin/bash     install_auto() {     apt-get -h > /dev/null 2>&1     if [ $? -eq 0 ] ; then         return $(sudo apt-get install --assume-yes $@)     fi     return 1     }     echo "installing $@"     install_auto "$@"     echo $?     echo "finished"     exit 0      The output is:               ./install_test.sh: line 5: return: Reading: numeric argument required      Update: I came up with something that works:               return $(sudo apt-get install --assume-yes "$@" >/dev/null 2>&1; echo $?)      Is that a good approach?


title: Debian package to install closed-source

text: I'm writing an application that relies on a closed-source (but free-as-in-beer available) library. I'm currently making a Debian repository to host it, and need a way to depend on that library, so I want to make a package that downloads the archive from a third party and installs it. I'm not sure how to do the install such that it will uninstall nicely. Any ideas for how to do this such that it integrates nicely into apt?


title: Optimal SSD configuration

text: I am thinking about buying an SSD for my Debian system. However, because I don't know what is the optimal arrangement (i.e. what goes on the SSD), I am not sure what is the optimal size. Obviously I would like to find the sweet spot between performance and cost. Currently I have one partition for the root of the system, one for /home and one for the swap. What should I move to the SSD? I was thinking to move the root filesystem, and leave the rest as it is. But on the other hand there is lots on configuration files in home, and these may slow the system as well. Obviously I don't want to have photos and multimedia files on SSD, but what about the rest of the /home? And the swap partition?


title: How do I tunnel SSH over SSH?

text: I have successfully setup a tunnel over SSH on linux mint, and can browse the web. However, when I try to ssh using the same port, I get: > Couldn't establish connection to proxy: Network is unreachable > ssh_exchange_identification: Connection closed by remote host In my `mate-network-properties` I have selected manual proxy configuration, and socks host is `127.0.0.1` So why doesn't ssh use that proxy information, and can I make it use said proxy?


title: Lost access to grub after installation of Peppermint 4

text: I am hoping someone would be able to help me. I have installed peppermint 4 but after restarting it, the grub menu didn't show up and now it boots straight into Windows. I went back into peppermint by using "Try out Peppermint" option from the boot USB. I've also run               sudo fdisk -l      and this is the output.               Disk /dev/sda: 500.1 GB, 500107862016 bytes     255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0xd9aacbf3          Device Boot Start End Blocks Id System     /dev/sda1 * 2048 821247 409600 27 Hidden NTFS WinRE     /dev/sda2 821248 489330687 244254720 7 HPFS/NTFS/exFAT     /dev/sda3 489330688 976773119 243721216 7 HPFS/NTFS/exFAT          Disk /dev/sdb: 500.1 GB, 500107862016 bytes     255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0x99954f66          Device Boot Start End Blocks Id System     /dev/sdb1 2048 557340671 278669312 7 HPFS/NTFS/exFAT     /dev/sdb2 * 557340672 557828095 243712 83 Linux     /dev/sdb3 557830142 691828735 66999297 5 Extended     /dev/sdb5 557830144 567828479 4999168 83 Linux     /dev/sdb6 567830528 667828223 49998848 83 Linux     /dev/sdb7 667830272 691828735 11999232 82 Linux swap / Solaris          Disk /dev/sdc: 16.2 GB, 16231956480 bytes     140 heads, 32 sectors/track, 7076 cylinders, total 31703040 sectors     Units = sectors of 1 * 512 = 512 bytes     Sector size (logical/physical): 512 bytes / 512 bytes     I/O size (minimum/optimal): 512 bytes / 512 bytes     Disk identifier: 0xc3072e18          Device Boot Start End Blocks Id System     /dev/sdc1 * 32 31703039 15851504 c W95 FAT32 (LBA) The `/boot` partition for peppermint was set at `/dev/sdb`. I have also tried to use type this code:               sudo mount /dev/sdb2 /mnt     chroot /mnt      It has managed to mount it but after trying `chroot /mnt` it says: > Operation not allowed. What can I do to enable grub now?


title: Why do I get 3048 MB from a 64 MB flash memory?

text: I have a Linux based STB (set-top-box) and it features a 64 MB flash memory and 256 MB of RAM. I wanted to take a backup of some of my settings before I flash it with another image, but I wasn't sure where exactly they were located. I figured I would look into that later on. So I decided to connect to the box over FTP and download all the files and folders. Within the FTP client, I right-clicked on the root of the box and chose do download it to a dedicated folder on my desktop in Windows. The download just kept on going, it seemed like it would never stop... but then the FTP connection got terminated by the FTP server (I think it said in the log). I ended up with 2.97 GB of data. How is this possible? Where is all this data coming from?... it can't even hold more than 256 MB at most?!... Why can't you just copy the root of a Linux machine right off, and expect all the other files and folders to follow? Is it not the same as copying the C:\ on Windows? Is it because it's a live system?... maybe I have to shut it down first or log off and stop processes? It was in standby at the time... I am a complete noob when it comes to Linux. I thought I was gonna kill my STB there for a moment!


title: Distro recommendation for "Out The Box Multi Touch Tablet Support"

text: I have a Dell Inspiron Duo - The tablet netbook, the 1090. It's beautiful, and I want to get the most out of it. I don't mind digging deep into a distro and installing patches and such to get multitouch working, but that's me. I have to think of others that also would like this goodness. So my question, which distro has the best multi touch / tablet support out the box. > Imagine I have to recommend something to someone about to go on an Arctic > expedition, who has a touch screen laptop, and needs FOSS installed because > of cutbacks :)


title: Text pre-processing How to run many scripts at once

text: I have many scripts for text cleaning, is there a way to execute all of them at once instead of doing that one by one, for example I have :               sed -i -r "s/[’'–]/ /g" *.txt          sed -i 's/Aβ/ ABeta /g' ./*.txt      I have about 10 of them, how can I run all of them at once?


title: How do I elevate privileges in the middle of pipeline?

text: My guess was as follows:               echo "Generating some text" | su - -c cat >/output/file      But `su` says:               su: must be run from a terminal      What would you do?


title: ls --color: how to color executable hard links?

text: I created some hardlinks on an NTFS drive, but because of that, they are all executable and colored as executable instead of as hardlinks (regular file with more than one link). I did a test on my ext4 drive and it's the same problem: Any file with more than one link gets nicely highlighted when using ls --color, but as soon as it has one executable bit, it gets the "executable" coloring (bold by default, no highlighting). I tried various LS_COLOR settings, but no change. My current ~/.dir_colors file is simplified to this:               RESET 0     HARDLINK 44;37     #EXEC 01;32;41      And I test it with this:               eval "$(dircolors ~/.dir_colors)"; ls -l --color      The file seems to work for changing the colors, highlighting, etc, but I can't get executable hardlinks to be colored according to the HARDLINK setting. Update: After some research, it seems that "exe coloring takes precedence". Looks like it is hardcoded into ls itself:   * tests/ls/multihardlink.sh 54   * src/ls.c 4335-4338 So the only solution would be a customized "ls", is that correct?