samedi 28 février 2015

Why is Firefox so slow over SSH?


I try to launch Firefox over SSH, using



ssh -X user@hostname


and then



firefox -no-remote


but it's very very slow.


How can I fix this? Is it a connection problem?



Outgoing masquerade address changes after adding a second interface to the bridge


In fact I have the following configuration:


extrouter(192.168.1.1) <- wifi -> [eth2 (192.168.1.11) Centos 6/6 based host br0 (172.22.5.254)]


br0 contains two tap interfaces (tap0/172.22.5.1 tap1/172.22.5.2) from virtual machines (kvm), the gw inside VMs is 172.22.5.254.


If only a single virtual machine is connected to br0 all works well. I cant ping from VM 192.168.1.1 and tcpdump for eth2 shows 192.168.1.11 as outgoing address, masquerading works as expected. But if I add the second VM (the order of VMs are not important) the outgoing address changes to the 172.22.5.254. After removing one of VM from the bridge all goes back and starts working again.


Bridge has its own mac address, so adding an interface shouldn't change anything.


Any ideas what may be wrong?



Bash cannot see PATH update


I am running Debian on a VM. I login to the GUI and go to Applications > Accessories > Terminal.


# echo shell: /bin/bash


I modified ENV_SUPATH, ENV_PATH inside of /etc/login.defs. I restarted the shell. In superuser mode echo $PATH shows my update. In normal mode echo $PATH does not show my update. I added and modified ~/.bash_profile. I still can't see my change and I'm starting to chase my tail.


/etc/login.defs contents:



ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/brian/.linuxbrew/bin
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/brian/.linuxbrew/bin


~/.bash_profile:


PATH=/home/brian/.linuxbrew/bin:$PATH


How can I troubleshoot and resolve this?



How to change mouse hovering background in Emacs


When mouse is over a Dired file line, it shows strange background regardless of the highlight-line color.


How can I set the background color?


enter image description here



what is the value for setting a hostname in installation of oracle enterprise linux r6u5 should have?


I am installing oracle linux r6u5 for my personal use in vmware workstation. While going through installatio i came to a point where I have to enter hostname, format specified init is "localhost.localdomain". What value should I give there? should that be a live domain name over internet or it can be any in the format specified in it "localhost.localdomain" or IP address of host OS(Windows 8 where VmWare is installed on).


Please help me with this I am installing Linux for first time.



Does X mangle prompt environment variables?


I'm starting it with startx. Before that I have PS1 in my environment:



$ cat /proc/self/environ | tr '\0' '\n' | egrep '^PS'
PS1=[\u@\H \w]
PS3=>
PS2=>
PS4=+


From inside X I get:



$ cat /proc/self/environ | tr '\0' '\n' | egrep '^PS'
PS3=>
PS4=+


I checked in both GNOME and awesome. Is it expected behavior? Can I do something about it?



Disk numbering a drive then mounting in solaris 10


I've a rescued sun v240 (2x 73Gb scsi drives).


Trying my best to get onto the Solaris 10 OS.


Managed to get via console lead and putty on windows machine .


Managed to get cdrom-s single user (used Solaris 10 dvd disc.)


Managed to get PGX64 ,type 6 keyboard and screen working .


I need some instruction on mounting the original SCSI disks . So to vi the shadow file . Can any one suggest the numbering I may use?


Results table of initial scan:



Boot device: /pci@1c,600000/scsi@2/disk@0,0:a File and args:
SunOS Release 5.10 Version Generic_118833-33 64-bit (presume this is my DVD Disk )

Testing /pci@1e,600000/ide@d

Testing /pci@1e,600000/isa@7/rtc@0,70

Testing /pci@1c,600000/scsi@2

Testing /pci@1c,600000/scsi@2,1

Testing /pci@1e,600000/isa@7/serial@0,2e8

Testing /pci@1e,600000/isa@7/serial@0,3f8


So Just need the numbering to use off these scsi disks PLEASE



Why did a recent Ubuntu 14.04 update mess up my PS1 prompt?


I recently updated my Ubuntu 14.04 using the software update.


This caused some problems. Initially I couldn't open up a new terminal window due to unknown errors with my .bashrc I had to use another shell to remove my .bashrc file to fix it. While slowly adding back the .bashrc file I now have a problem with my PS1 prompt settings.


For a while I've used



git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
HOST='\033[02;36m\]\h'; HOST=' '$HOST
TIME='\033[01;31m\]\t \033[01;32m\]'
LOCATION=' \033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`'
BRANCH=' \033[00;33m\]$(git_branch)\[\033[00m\]\n\$ '
PS1=$TIME$USER$HOST$LOCATION$BRANCH
PS2='\[\033[01;36m\]>'


in my .bashrc to show time, user, host, pwd and git branch (in various colors) within my prompt.


After the upgrade I have a strange character at the start of each of those that didn't used to be there. Some sort of small outlined box with 4 tiny numbers in it !


enter image description here


What is causing this & how to fix it?



DBmail / Postfix : Relay Acces Denied


I am currently setting up a FreeBSD mail server with DBmail and Postfix. When i try to send an email from Hotmail.com to my server is gives this error:



Feb 28 10:53:31 keroth postfix/smtpd[1848]: connect from dub004-omc4s17.hotmail.com[157.55.2.92]
Feb 28 10:53:32 keroth postfix/smtpd[1848]: NOQUEUE: reject: RCPT from dub004-omc4s17.hotmail.com[157.55.2.92]: 454 4.7.1 <info@scriptex.nl>: Relay access denied; from=<ruben.urresti@hotmail.com> to=<info@scriptex.nl> proto=ESMTP helo=<DUB004-OMC4S17.hotmail.com>
Feb 28 10:53:32 keroth postfix/smtpd[1848]: disconnect from dub004-omc4s17.hotmail.com[157.55.2.92]


And the email never arrives in the specific inbox: info@domain.com. (Which is added to the Dbmail Database)


I think this problem has something to do with my main.cf file:



queue_directory = /var/spool/postfix
command_directory = /usr/local/sbin
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix

#Permissions
mail_owner = postfix
default_privs = nobody

#Network
myhostname = mail.domain.nl
mydomain = domain.nl
myorigin = $mydomain
inet_interfaces = all

#Recipients
unknown_local_recipient_reject_code = 550

#Misc
smtpd_helo_required = yes
strict_rfc821_envelopes = yes
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/local/sbin/sendmail
mailq_path = /usr/local/bin/mailq
setgid_group = maildrop
html_directory = /usr/local/share/doc/postfix
manpage_directory = /usr/local/man
sample_directory = /usr/local/etc/postfix
readme_directory = /usr/local/share/doc/postfix
inet_protocols = ipv4


Generating a .img from tarball: The /dev/loop devices


I'm trying to make a .img from a tarball using the following script I found:



#!/bin/bash

# Packages required
# dosfstools parted
# Can be run on any Linux system
# loop.max_part=15 must be in kernel cmdline (cmdline.txt for rpi)
# then reboot

echo "creating image to fit on 2Gb card"
dd if=/dev/zero of=arch-rpi.img bs=1M count=1850

echo "Partitioning"
fdisk arch-rpi.img <<EOF
o
n
p
1

+100M

t
c
n
p
2


w
EOF

sleep 5

losetup -f arch-rpi.img
sleep 5

echo "Formatting vfat"
mkfs.vfat /dev/loop0p1
sleep 5
mkdir boot
echo "Mounting boot"
mount /dev/loop0p1 boot
echo "Installing"

echo "Formatting ext4"
mkfs.ext4 /dev/loop0p2
sleep 5
mkdir root
echo "Mounting root"
mount /dev/loop0p2 root

wget http://ift.tt/1BKipqa
echo "Installing"
bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sync
mv root/boot/* boot
sync
umount boot root
losetup -d /dev/loop0p1
losetup -d /dev/loop0p1
losetup -d /dev/loop0
echo "All complete, image arch-rpi.img created, compressing...."
zip -9 arch-rpi.img.zip arch-rpi.img


I'm doing this on my Raspberry Pi - Raspbian Wheezy. And when it gets to the line mkfs.vfat /dev/loop0p1 It says there's no such file / directory. I've read enough on Linux to know I'm trying to mount the .img as a loop device and then use mkfs to prepare the image for the tarball, but I don't quite know why loop0p# files are not there, they are listed by fdisk -l. What do I need to to in order to get this script I found working?



How do I enable remote desktop of the GUI?


I can ssh into my machine. I want to be able to login to the GUI to do dev work. I went go Applications > System Tools > settings > Sharing > and I have Remote login and Screen Sharing both on. I tried to connect to the CentOS box from my Mac OSX box using VNC Viewer. For the server I used my internal IP: 192.x.x.x.


"The connection was refused by the host computer".


I am actively logged into the unix machine with a non-admin account.


How do I get going?



What, as examples, can produce a POLLNVAL?


The reference about poll() just says “The specified fd value is invalid. This flag is only valid in the revents member; it shall ignored in the events member.”.


That's not clear (at least to me): if the file descriptor is invalid, shouldn't poll return an error instead (negative return value)?


I had the same question about POLLERR and learned somewhere it may refers to, as an example, error in a device or network. This one, POLLNVAL, remains mysterious.


Do someone know example cases?



unable establish remote imap connection, why not?


A remote CentOS 7 web server is able to successfully receive email sent from elsewhere on the internet addressed to me@mydomain.com . An app running on the same CentOS 7 server is able to use JavaMail to make an IMAP connection to the dovecot Maildir where the incoming messages get stored. So what do I have to add in order for Thunderbird running on my devbox to be able to make an IMAP connection to the remote CentOS 7 server across the internet?


So far, I added imaps to the public zone of firewalld. I also confirmed that dovecot.conf contains the line protocols = imap pop3. I configure Thunderbird to use IMAP for incoming mail, with mydomain.com as the hostname, with port 993 and SSL with normal password. And I confirmed at my domain registrar's web site that the dns mx entry uses mydomain.com as the mx address.


EDIT


To answer @Celada's question, I have posted the dialog that Thunderbird gives indicating that it has failed to connect to the server when it tries to confirm my login information. I get the same information when I specify port 993 for imap and port 25 for smtp, and when I indicate SSL connection. Also, changing .mydomain.com to mydomain.com does not eliminate the login failure.



I will try to access the firewalld logs next and will post results. My understanding is that firewalld does not log automatically, so I will have to develop some rich rules. It might take some time to identify the proper syntax.


I think it is a server config problem. I hesitated to show the Thunderbird dialog because I did not want to give the impression that it is a client issue. I think the server config needs to be determined/set-up before I can set up Thunderbird.


EDIT#2


As per @Celada's suggestion, I typed telnet localhost 143 and got the following response:



Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready.


I also typed telnet localhost 25 and then got the following in response:



Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mydomain.com ESMTP Postfix


These telnet results pointed out that firewalld was mapping imaps and smtp to the wrong ports, so I typed nano /usr/lib/firewalld/services/imaps.xml and changed the port from 993 to 143. And then I typed nano /usr/lib/firewalld/services/smtp.xml and changed the port to 25.


I then typed firewall-cmd --reload to ensure that the changes were put into effect.


Next, I put the new information into Thunderbird and tried a test connection again, but again got a failure message shown by the following dialog box:



Note that I checked the MX record in the DNS at my domain registrar, and it is exactly mydomain.com, as shown in the screen shots. I don't see how this is irrelevant. I did check and the hostname on the server is also mydomain.com. Is there some other resource I should be checking to confirm the correct mail server name instead?


Also note that dovecot and postfix were installed with a standard configuration. I did not explicitly configure ssl to work with them, though SSL may have been part of the default configuration. I did, however, change the settings in the dialog box above and tested a connection with None specified in the SSL field, but got the same failure message.


The dovecot log in /var/log/maillog after the most recent (bottom) screen shot above is:



Feb 27 00:52:57 mydomain dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=my.DEVBOX.ip.addr, lip=my.SERVER.ip.addr, session=<YsH2egsQAABi9AyF>


EDIT#3


Following @Bandrami's advice, I changed protocols = imap pop3 in dovecot.conf to protocols = imaps pops. I then made sure that /usr/lib/firewalld/services/imaps.xml specifies port 993. I typed firewall-cmd --reload and systemctl stop dovecot then systemctl start dovecot to restart the relevant processes on the server. I then configured the Thunderbird test to specify port 993 and SSL/TLS and re-ran the connection test in Thunderbird, only to get the same result in Thunderbird.


The dovecot logs, however, are a little more explicit, and are as follows:



Feb 27 01:18:20 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
Feb 27 01:18:20 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$
Feb 27 01:18:38 mydomain dovecot: imap-login: Disconnected (no auth attempts in 18 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$
Feb 27 01:19:15 mydomain dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:15 mydomain dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:15 mydomain dovecot: ssl-params: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:15 mydomain dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:15 mydomain dovecot: auth: Error: read(anvil-auth-penalty) failed: EOF
Feb 27 01:19:15 mydomain dovecot: auth: Error: net_connect_unix(anvil-auth-penalty) failed: Permission denied
Feb 27 01:19:15 mydomain dovecot: auth: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:15 mydomain dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:19:22 mydomain dovecot: master: Dovecot v2.2.10 starting up for pop3, imap (core dumps disabled)
Feb 27 01:19:44 mydomain dovecot: imap-login: Disconnected (no auth attempts in 15 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$
Feb 27 01:23:55 mydomain postfix/qmgr[30121]: 2C915811BD1C: from=<me@mydomain.com>, size=5316, nrcpt=1 (queue active)
Feb 27 01:23:58 mydomain postfix/smtp[27144]: 2C915811BD1C: to=<address@domain_that_sends_to_this_addresson_server.com>, relay=none, delay=290245, delays=290241/0.02/3.6/0, dsn=4.4.3, status=deferred (Host or domain$
Feb 27 01:24:41 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
Feb 27 01:24:41 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$
Feb 27 01:24:41 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
Feb 27 01:24:41 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$
Feb 27 01:24:53 mydomain dovecot: imap-login: Disconnected (no auth attempts in 12 secs): user=<>, rip=my.SERVER.ip.addr, lip=127.0.0.1, TLS handshaking: SSL_accept() failed: error:14$
Feb 27 01:25:05 mydomain dovecot: imap-login: Aborted login (no auth attempts in 1 secs): user=<>, rip=my.DEVBOX.ip.addr, lip=my.SERVER.ip.addr, TLS, session=<Kdrl7QsQxwBi9AyF>
Feb 27 01:27:16 mydomain dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:27:16 mydomain dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:27:16 mydomain dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
Feb 27 01:27:24 mydomain dovecot: master: Dovecot v2.2.10 starting up for pop3, imap (core dumps disabled)
Feb 27 01:27:24 mydomain dovecot: config: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
Feb 27 01:27:24 mydomain dovecot: config: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:26: 'imaps' protocol can no longer be specified (use protocols=imap). to disable n$


EDIT#4


As per @Celada's further clarification, I typed telnet imap.mydomain.com 143, in the local devbox that I've been using for Thunderbird testing, and the terminal replied with:



Trying my.SERVER.ip.addr...
Connected to imap.mydomain.com.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready.


Next, I typed in openssl s_client -CApath /etc/ssl/certs -starttls imap -port 143 -host imap.mydomain.com at the devbox terminal, and the terminal replied by printing out the details which you can read by clicking on this link to a file sharing site.


My complete dovecot.conf can be read at a file sharing site by clicking on this link.


EDIT#5


As per @Celada's suggestion, I typed t1 login USERNAME PASSWORD after . OK Pre-login capabilities listed, post-login capabilities have more., and the terminal replied with the following:



* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE
t1 OK Logged in


However, I then repeated the Thunderbird login test, and I checked to force Thunderbird to use port 143 and "Normal password". When I did this, Thunderbird forced "Autodetect" as the SSL option, and then clicking the "Re-test" button resulted in the same error message:



"Thunderbird failed to find the settings for your email account."


NOTE: @Celada answered this question in comments, and in chat. The answer involved minor changes to firewalld config, using commands like telnet, and others to probe what is happening at port 143, and then tinkering with Thunderbird advanced config to use imap.mydomain.com as the imap server definition (not in the main dialog, but in the advanced settings.) Two people have voted to re-open this. Please vote to re-open this so that she can submit the correct answer for others. If someone has a suggestion as to how I can clean up my posting to get their vote to re-open, please let me know.



Alert when transfering files using SSH?


I used to transfer files through ssh , from one computer to another. is there any way i receive a notification on my computer , when someone tries to transfer files via ssh ?



MongoDB will not uninstall


So, it would appear that following the official MongoDB installation instructions when installing on Debian - you're heading for a world of pain. Firstly, it didn't install correctly so now - i'm trying to remove all installed MongoDB packages so that I can start from scratch.


Frustratingly, because it didn't install cleanly (presumably), it won't uninstall.


Originally, I installed using the instructions here: http://ift.tt/1mvzOen


Currently, i've managed to remove every package apart from mongodb-org-server which, just won't go.


An attempted removal results in the following:



user@host:/$ sudo apt-get remove mongodb-org-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
mongodb-org-server
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 23.9 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 31030 files and directories currently installed.)
Removing mongodb-org-server ...
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
dpkg: error processing mongodb-org-server (--remove):
subprocess installed pre-removal script returned error exit status 100
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 100
Errors were encountered while processing:
mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)


This is causing me untold problems, any ideas how I can properly and cleanly get rid of MongoDB now?


Jordan



No /dev/hidraw device when I plug in a Yubikey


I have a Yubikey NEO, and I'm trying to get it to work on Debian.


When I plug it in, I get udev events, but no /dev/hidraw? device.


Here's what I know so far:


cat /boot/config-$(uname -r) | grep CONFIG_HIDRAW) gives:



CONFIG_HIDRAW=y


lsusb -v -d 1050:0211 gives:



Bus 002 Device 013: ID 1050:0211 Yubico.com
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1050 Yubico.com
idProduct 0x0211
bcdDevice 0.20
iManufacturer 1 Yubico
iProduct 2 Yubico WinUSB Gnubby (gnubby1)
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 30mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)


I have added udev rules, as recommended here and cat /etc/udev/rules.d/70-u2f.rules gives:



ACTION!="add|change", GOTO="u2f_end"

#KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1050", TAG+="uaccess"
ATTRS{idVendor}=="1050", GROUP="plugdev", MODE="0660"


LABEL="u2f_end"


(This didn't work when the commented line was uncommented either.)


I've tried installing libhidapi-hidraw0, but that hasn't seemed to work either.


I've also tried installing and running the Yubikey NEO manager, but both it and the yubikey personalization tool don't think any Yubikey device is plugged in, which why I think the blocker is the lack of a /dev/hidraw0 device (or something at a similar level).


I've reached the limits of both my knowledge of Linux and my ability to Google for solutions, so both further debugging suggestions and (if you know it) solutions would be helpful.



Resizing Extended Partition containing Logic Partitions


I need to expand and move an extended partition that contains a number of logic partitions in Windows 7. Can GParted accomplish this with or without Win7 help?



Sed regex printing into a file.txt


I'm connected to a MQTT stream, and I filter out the data by entering :



mosquitto_sub -d -t +/# 2>&1 |
sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}"


into the Ubuntu terminal. This prints the only things that I am interested from the MQTT stream.


Now that I can do this I would like to dump this information into a qwerty.TXT file. I've tried



mosquitto_sub -d -t +/# 2>&1 |
sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;w qwerty.txt}"


and got the following error:



sed: -e expression #1, char 0: unmatched '{'


I've looked into sed regex, and the examples are that w file.type writes into the file file.type where type can be .txt for example.


I've also tried



mosquitto_sub -d -t +/# 2>&1 |
sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p >> qwerty.txt}"


and



mosquitto_sub -d -t +/# 2>&1 |
sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;1a qwerty.txt}"


How can I print my filtered MQTT stream into a file named qwerty.txt?



Setting Kali Linux as default system instead of using VirtualBox?


so I'm a complete noob and I just installed Linux using VirtualBox. Is there any method to set Linux as my default system and get rid of the current one (win7)? Or is it neccessary to delete both and install the fresh Linux on "empty" PC using CD?


Regards



How to Config SSH Server with sftp Protocol?


How to config ssh server only allows users to transfer files using sftp protocol Without being able to login with their username ?

Note: If the user's shell to nologin or null is not possible to change this



Swap two files in bash


How do I swap two files in Linux console with minimum typing?


Boring approach:



$ mv file1.dat fileX.dat
$ mv file2.dat file1.dat
$ mv fileX.dat file2.dat


looping through a file on 2 lines in shell


I have a file which looks like this:



>a
TCCACTCCACGC
>b
ACCTCCAG


I want to loop through the file in such a way that it takes into account 2 lines at a time i.e >a and its sequence and then I want to store those 2 lines in a variable and then further use my bioinformatics tools clustalomega


Some thing like this



for lines in test.fa;
do
clustalo -i $capture -o outputfile;
done


where capture variable first time when the loop goes has this format



>a
TCCACTCCACGC


then next time



>b
ACCTCCAG


How can I do this?



Setting initial configurations of user session for Arch Linux


I have to configure the keyboard every session with the command:



setxkbmap -layout br


And to connect:



systemctl start dhcpcd


I want the system do this automatic, I've tryed change the .bash_profile and the rc.conf but don't worked.



Is it possible to limit the set of English locales on a system?


On Debian and Ubuntu is it possible to limit the locales which have to be configured?


I know that /var/lib/locales/supported.d/local and /var/lib/locales/supported.d/en govern which locales are being configured, but short of manually modifying it more or less after the fact (i.e. after an apt-get dist-upgrade) I haven't found any method to limit it to en_US.* locales as desired.


So whenever the packages language-pack-en and language-pack-en-base gets touched (and they usually get updated in lockstep, from what I saw), I get something like this:



Setting up language-pack-en (1:14.04+20150219) ...
Setting up language-pack-en-base (1:14.04+20150219) ...
Generating locales...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... up-to-date
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
Generation complete.


Unfortunately some upgrades seem to override those two aforementioned files and thus reset modifications I've made to them.


What'd like to see instead is:



Setting up language-pack-en (1:14.04+20150219) ...
Setting up language-pack-en-base (1:14.04+20150219) ...
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.


How can I achieve that?



How to compile without optimizations -O0 using CMake?


I am using scientific linux. I am trying to compile a project that uses a bunch of cpp files.


In the directory user/project/Build, I enter make to compile and link all the cpp files. I then have to go to user/run/ and then type ./run.sh values.txt


To debug with gdb, I have to go to user/run and then type gdb ../project/Build/bin/Project and to run, I enter run -Project INPUT/inputfile.txt. However, I am trying to print out the value of variable using p variablename. However, I get the message s1 = <value optimized out>. I done some research online, and it seems I need to compile without optimizations using -O0 to resolve this. But where do I enter that? In the CMakeLists? If so, which CMakeLists? The one in project/Build or project/src/project?



getting ? in permissions when running ll/ls command


I am trying to remove a folder and I am getting



rm: cannot remove ‘...'


when running the ll command I am getting :



> ll ./folder/
ls: cannot access ./folder: Input/output error
total 64
drwx------ 1 yehudahs yehudahs 0 Feb 15 23:08 ./
drwx------ 1 yehudahs yehudahs 4096 Feb 27 13:30 ../
d????????? ? ? ? ? ? folder/


any ideas ? using ubuntu 14.10.



Use lines in a file to produce string and file name


I have a file, foo.txt, that has a folder name on each line:



folder_1
folder_2
folder_3


And I'd like to do something like this:



cat foo.txt | xargs -I {} echo 'function {}() { return stuff; }' > {}/function.js


In other words, I'd like to read a file line by line, then use each line to both create a string and create the name of the file in which the string is stored.


How does one do something like this from the command line in bash?



How to take virtual machines state/back-up automatically?


My problem is,



I want to take state/back-up of those 4 virtual machines(VMs) automatically after every 2 days.



I am using Oracle virtual box(VB). I just want to know


Is there any way or facility to achieve above thing?



CRON session entries in logs


I'm having this in my RaspberryPi /var/log file



Feb 26 21:17:01 raspberrypi CRON[15182]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 26 21:17:01 raspberrypi CRON[15182]: pam_unix(cron:session): session closed for user root
Feb 26 21:39:01 raspberrypi CRON[15189]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 26 21:39:01 raspberrypi CRON[15189]: pam_unix(cron:session): session closed for user root


in fact... my log file is full of this CRON session opened and closed. Is this a security issue? someone is trying to access my raspberry pi?


if so .. what can I do? Is there any tool that I can install to see from what IP address is coming the attack?



Is it possible to register "virtual" user/group IDs in a Linux system?


Is there a standardized mechanism in Linux which can be used to tie usernames to user IDs without actually creating a system account that can log in?


It would seem something like this is possible, given that there is the ability to connect to a Windows server and give UIDs to the users. Usually in a high number range.


What I need/want this for is to be able to assign meaningful names to groups and users that only exist as subordinate IDs ().



Which log files do I look at to debug copy/paste and Klipper?


Short Version

What log files do I look at to monitor copy/paste actions? And what logs do I look at to monitor all Klipper actions?


Long Version

After using my desktop for a while (could be a few hours, could be a few minutes), copy paste starts doing strange things. When I copy (Ctrl+C or via right click menu), Klipper will sometimes not pick up the highlighted text. It sometimes gets blank lines, sometimes just jumps to a random entry in the history, and sometimes works. Rebooting "fixes" it but after some time, this issue will always return.


As far as I can tell, my system was perfectly fine until a couple months ago when I first noticed the issue. But since it is random and rebooting resets the issue, I have no idea what update might have caused this. So I'm trying to debug and track down the issue myself. With that said, could anyone tell me every possible log file to look at that's related to copy/paste and klipper? Thanks!


System Info: In case this reminds someone of a similar issue, my OS is Netrunner Rolling (this is based off Manjaro), CPU is Intel, and GPU is a Radeon HD 7750 using the open source drivers.



rvm requirements error ruby linux mint


I write



rvm requirements


And get this:

Checking requirements for mint.
Installing requirements for mint.
Updating system.............................
Error running 'requirements_debian_update_system ',
showing last 15 lines of /home/liubovi/.rvm/log/1425156551/update_system.log
+ case "${TERM:-dumb}" in
+ case "$1" in
+ [[ -t 2 ]]
+ return 1
+ printf %b 'There has been error while updating '\''apt-get'\'', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
\n'
There has been error while updating 'apt-get', please give it some time and try again later.
404 errors should be fixed for rvm to proceed. Check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list

+ return 100
Requirements installation failed with status: 100.

What should I do?

Linux min 11 ( But updated to last version)


Samba Tuning (Very low data transfer rates)


I have been trying to tune my Samba server for a while now and have had very little luck. At first I thought it could have had something to do with my router but recently purchased a new one with 10/100/1000 connections. The Samba server and Windows PC that access it are both wired directly to the router.


The maximum speed I am able to obtain is 11 Mbps which seems odd to me because I have (now) a very fast LAN and also the Samba Server has a very good 1TB 7200 RPM HDD.


My conf file is as follows



socket options = TCP_NODELAY

[BackupHDD]
path = /media/BackupHDD
available = yes
valid users = user
read only = no
browseable = yes
public = yes
writable = yes


Very simple yet I still cannot manage over 11 Mbps. Putting in the socket option is what allowed me to go from 3 Mbps to 11. Is there anything else you guys could suggest? I am running Ubuntu 14.04 LTS if that helps.


Any information would be great. Theortically I should be able to obtain much higher speeds right? I know the HDD specs posted much much higher read write speeds.


Edit: I would just like to point out that the network drive I am using has about a speed transfer of 50 +/- Mbps according to the dd command.



dd if=/media/BackupHDD/dev/zero of=speetest bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 1.9879 s, 52.7 MB/s


postfix logs: SMTP sessions stopping after RCPT TO


I took a look at my postfix logs and I've noticed an odd occurrence lately: SMTP sessions that seem to end right after the RCPT TO, as such:



postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 220 [mydomain.com] ESMTP (Ubuntu)
postfix/smtpd[11333]: < unknown[XXX.XXX.238.86]: EHLO LMSPC.[otherdomain.com]
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-[mydomain.com]
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-PIPELINING
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-SIZE 10240000
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-ETRN
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-STARTTLS
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-ENHANCEDSTATUSCODES
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250-8BITMIME
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250 DSN
postfix/smtpd[11333]: < unknown[XXX.XXX.238.86]: MAIL From:<tobyami@LMSPC.[otherdomain.com]>
postfix/smtpd[11333]: > unknown[XXX.XXX.238.86]: 250 2.1.0 Ok
postfix/smtpd[11333]: < unknown[XXX.XXX.238.86]: RCPT To:<[myusername]@[mydomain.com]>


For comparison, this is what a "normal" session looks like in my logs:



postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 220 [mydomain.com] ESMTP (Ubuntu)
postfix/smtpd[31674]: < mail-wg0-f52.google.com[74.125.82.52]: EHLO mail-wg0-f52.google.com
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-[mydomain.com]
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-PIPELINING
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-SIZE 10240000
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-ETRN
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-ENHANCEDSTATUSCODES
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250-8BITMIME
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250 DSN
postfix/smtpd[31674]: < mail-wg0-f52.google.com[74.125.82.52]: MAIL FROM:<[whatever]@gmail.com> SIZE=1774
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250 2.1.0 Ok
postfix/smtpd[31674]: < mail-wg0-f52.google.com[74.125.82.52]: RCPT TO:<[my username]@[mydomain.com]>
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250 2.1.5 Ok
postfix/smtpd[31674]: < mail-wg0-f52.google.com[74.125.82.52]: DATA
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 354 End data with <CR><LF>.<CR><LF>
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 250 2.0.0 Ok: queued as 6346912215C
postfix/smtpd[31674]: < mail-wg0-f52.google.com[74.125.82.52]: QUIT
postfix/smtpd[31674]: > mail-wg0-f52.google.com[74.125.82.52]: 221 2.0.0 Bye


It seems my server doesn't answer with an "Ok" once it gets a RCPT TO in the first case. Things just seem to...stop.


It doesn't bother me too much since I still get mails, and occurrences like the former example seem to all come from IPs either without a reverse DNS or from "weird" domains; as such, I'm assuming they must be spam attempts.


Still, I'm wondering what's happening here. I can't tell who's dropping the connection first, my server or the remote, nor can I tell why the connection would be dropped. If it's on my end, why is it dropped at this point, after the RCPT TO, and not before? If it's on the remote end, why drop it before sending anything, or even before letting my server respond?



How can I define and keep that resolution with a virtual machine?


I'm using VMware on windows to run Knoppix but the default resolution is too small and changing the resolution each time I load it with su xrandr is annoying.


Is there a way to change the default resolution permanently?



can't install curl


I am writing:



sudo apt-get install curl --fix-missing



This is the output:



Reading package lists... Done Building dependency tree

Reading state information... Done The following NEW packages will be installed: curl 0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded. Need to get 179 kB of archives. After this operation, 373 kB of additional disk space will be used. WARNING: The following packages cannot be authenticated! curl Install these packages without verification [y/N]? y Err http://ift.tt/u86xTH natty-updates/main curl i386 7.21.3-1ubuntu1.2 404 Not Found [IP: 91.189.88.149 80] Err http://ift.tt/unqOyP natty-security/main curl i386 7.21.3-1ubuntu1.2 404 Not Found [IP: 91.189.92.201 80] Failed to fetch http://ift.tt/1LX88s7 404 Not Found [IP: 91.189.92.201 80] E: Internal Error, ordering was unable to handle the media swap



Linux mint 11 Rosinka



Kali linux black screen after booting


I've managed to install kali linux from USB but after I try to boot it I get only black screen (after GRUB). It works great when I run only live sesion from USB. I am using MSI GS70 2PE notebook which uses nvidia optimus technology so I think that this may be a problem.


I've tried solutions from this site but they doesnt work.


My BIOS is setup to UEFI with CSM, fast boot disabled, secure boot disabled and my primary display device is set to integrated graphics (intel). But I still can't see anything only black screen (without any cursor)


Any ideas?



dnsmasq causes inability to resolve DNS queries made by host


On a headless Ubuntu 14.04 vanilla machine I setup dnsmasq as a DNS proxy with the following configuration in /etc/dnsmasq.conf



no-resolv
nameserver=<some working custom dns ip>
port=5555 #to circumvent my ISP's DNS hijacking


Whenever the dnsmasq service is started, the host machine lose ability to resolve any hostnames, however the dnsmasq resolves external queries just fine. A check into /etc/resolv.conf shows only one line of



nameserver 127.0.0.1


So I added a few nameservers to /etc/resolvconf/resolv.conf.d/base and rebooted the machine. The problem still persists even though the added nameservers appears in /etc/resolv.conf


May any Linux guru shine some light on why this is happening? Thank you very much.



How to extract only a part of one line?


I want to extract the essid in a dump file from airodump-ng using grep. The part where I want to extract looks like this:



<SSID first-time="Wed Feb 25 07:06:57 2015" last-time="Wed Feb 25 07:14:23 2015">
<type>Beacon</type>
<max-rate>54.000000</max-rate>
<packets>3371</packets>
<beaconrate>10</beaconrate>
<encryption>WPA2 AES-CCM </encryption>
<essid cloaked="false">WLAN-123651234</essid>
</SSID>
<BSSID>24:65:11:3A:68:02</BSSID>
<manuf>Unknown</manuf>
<channel>1</channel>
<freqmhz>2412 23193</freqmhz>
<maxseenrate>54000</maxseenrate>
<packets>


So I want to extract the essid "WLAN-123651234" in line 7. How do I do this ? And it shouldn't matter how long the essid is because i want to use that way not only for that essid, so it needs to be extracted like this:



grep >....< dumpfile.netxml
Output: WLAN-1234651234


How to change account who


I need to create ftp account who can do anythink, like root. I'm created one account, but he is "trapted" in his home dir. I'm using proftpd OS: debian



Can't install curl linux mint


I am new to linux.And I am trying to install curl to instal ruby version manager. I write this:



sudo apt-get update && apt-get install curl


And get this output:



E: Some index files failed to download. They have been ignored, or old ones used instead.
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?


Then I write this:



sudo rm /var/lib/apt/lists/lock


sudo rm /var/cache/apt/archives/lock



And then I repeat installing curl and get this:



E: Some index files failed to download. They have been ignored, or old ones used instead.
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?


how to know vendor id, device id, serial number of internal CD/DVD writer?


we have the usb-devices command to know the external CD/DVD writer details like serial number, vendor id, device id. But i want to know the same for internal CD/DVD writer.



Colorize line number in grep


Is there a way to colorize line numbers when using grep with the -n option?


For example, echo "hello" | grep -n lo outputs


1:hello


where lo is colorized in red (being the match). Can I configure grep to colorize the line number, i.e. the 1: portion? Are there specific shells/terminals that allow that?



spawn - command not found!


I am using Mac OS X 10.9.4, following is my script to copy files from local machine to different host



#!/bin/bash
#!/usr/bin/expect

echo "I will fail if you give junk values!!"
echo " "
echo "Enter file name: "
read filePath
echo " "
echo "Where you want to copy?"
echo "Enter"
echo "1. if Host1"
echo "2. if Host2"
echo "3. if Host3"
read choice
echo " "
if [ $choice -eq "1" ]
then
spawn scp filePath uname@host1:/usr/tmp
expect "password"
send "MyPassword\r"
interact
elif [ $choice -eq "2" ]
then
spawn scp filePath uname@host2:/usr/tmp
expect "password"
send "MyPassword\r"
interact
elif [ $choice -eq "3" ]
then
spawn scp filePath uname@host3:/usr/tmp
expect "password"
send "MyPassword\r"
interact
else
echo "Wrong input"
fi


when running this script i am getting following



./rcopy.sh: line 21: spawn: command not found
couldn't read file "password": no such file or directory
./rcopy.sh: line 23: send: command not found
./rcopy.sh: line 24: interact: command not found


Question marks instead of national letters in console


I have Netgear Stora MS2000 (which uses a modified version of Red Hat) and have strange font issues while connecting by SSH. Note that this occurs both when connecting by PuTTY from Windows and by performing ssh from Mac console.


When I use some Polish letter and type ls it is displayed as two question marks. However, when I try to autocomplete the file name it displays correctly. This is illustrated in the following picture:


console example


Tried to change TERM and LANG variables to different values but without any luck.


I also noticed wrong display of mc, this may (or may not) be related to the same issue:


mc


Any ideas what should I change?


The screens where made from PuTTY but it looks the same from Mac terminal.



How to change configuration of eth0 without restarting other interface (CentOS, Redhat)


I need to setup a static IP for eth0, my server has multiple network interfaces and I don't want to bring any of them, except for eth0 down.


I found lot of guides like http://ift.tt/1G3IEsw but all of them ends with "now restart networking" or "now reboot"


I can't reboot this server, nor I can bring down eth1 even if it was for a microsecond. How would I change eth0 config without touching other interfaces?



How can this pdf file be created from this website?


This pdf file seems created from this site.


I check the information of the pdf file by pdfinfo the pdf file:



Creator: pdftk 1.12 - www.pdftk.com
Producer: itext-paulo (lowagie.com)[JDK1.1] - build 132
CreationDate: Mon Mar 20 14:07:22 2006
ModDate: Mon Mar 20 14:07:22 2006
Tagged: no
Form: none
Pages: 565
Encrypted: no
Page size: 612 x 792 pts (letter)
Page rot: 0
File size: 6657623 bytes
Optimized: no
PDF version: 1.5


I don't know pdftk can create pdf files from webpages. I guess it was created by some other way (which can add number to left bottom of each page), and then processed by pdftk. But I am happy to be wrong.


I like to know how that can be created (so long ago), because I would like to have a pdf file from the newer version of the book.



Relay access denied when using SMTP to external recipients POSTFIX FREEBSD


i am trying to send an email with my freebsd server using postfix and dbmail to an external adress.


I have noticed the following things:


MYSERVER -> MYSERVER = OKAY


EXTERNALSERVER -> MYSERVER = OKAY


MYSERVER -> EXTERNALSERVER = ERROR(454 4.7.1 Relay access denied)


Why do i get this error? i think it has something to do with my main.cf


MAIN.CF

queue_directory = /var/spool/postfix


command_directory = /usr/local/sbin


daemon_directory = /usr/local/libexec/postfix


data_directory = /var/db/postfix


mail_owner = postfix


default_privs = nobody


myhostname = server.domain.nl


mydomain = domain.nl


myorigin = $mydomain


inet_interfaces = all


virtual_transport = dbmail-lmtp:localhost:24


virtual_mailbox_domains = domain.nl


unknown_local_recipient_reject_code = 550


mynetworks = 127.0.0.0/8 [::1]/128


smtpd_helo_required = yes


strict_rfc821_envelopes = yes


debug_peer_level = 2


debugger_command =

PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5


sendmail_path = /usr/local/sbin/sendmail


mailq_path = /usr/local/bin/mailq


setgid_group = maildrop


html_directory = /usr/local/share/doc/postfix


manpage_directory = /usr/local/man


sample_directory = /usr/local/etc/postfix


readme_directory = /usr/local/share/doc/postfix


inet_protocols = ipv4


smtpd_recipient_restrictions = permit_sasl_authenticated permit_mynetworks reject_unauth_destination



Thanks in advance



jq parse json log file


I have json log file like {"type":"1","fname":"AAA","lname":"bbb" } {"type":"2","state":"gujarat" } {"type":"3","city":"ahmedabad" } {"type":"3","city":"rajkot" } {"type":"1","fname":"ccc","lname":"ddd" }


I run following command jq -c "select(.type==\"1\")|{fname:.fname}" > type_1.txt jq -c "select(.type==\"2\")|{city:.city}" > type_3.txt


Is anyway to run jq command only one time and generate 2 output files?



SSH with RSA keys under Raspbian keeps requesting password


Background information


I am trying to connect a Raspberry Pi (Raspbian) to another via SSH. Therefore, I have generated a pair of RSA keys in my "client" Pi and saved its public key in my "server" Pi.



cat ~/.ssh/id_rsa.pub | ssh pi@piserver 'cat >> .ssh/authorized_keys'


Issue


Whenever I try to access my sever via the command below, I am requested to provide a password.



ssh pi@piserver
Enter passphrase for key '/home/pi/.ssh/id_rsa':


Further information


Client ./ssh folder details:



ls -l
total 16
-rw-r--r-- 1 pi pi 396 Feb 28 18:07 authorized_keys
-rw------- 1 pi pi 1766 Feb 28 18:09 id_rsa
-rw-r--r-- 1 pi pi 396 Feb 28 18:09 id_rsa.pub
-rw-r--r-- 1 pi pi 222 Feb 28 13:11 known_hosts


Server ./ssh folder details:



ls -l
total 4
-rw-r--r-- 1 pi pi 1188 Feb 28 18:27 authorized_keys


Question


How can I avoid being asked for the password all the time?



vendredi 27 février 2015

Can't install new linux kernel even after squeeze-backports


I'm trying to upgrade my kernel version from 2.6.32 to 3.2.0.0. When I try:



sudo apt-get install linux-image-3.16.0-4-amd64


I get the following error message:



linux-image-3.16.0-4-amd64 : Depends: linux-base (>= 3~) but 2.6.32-48squeeze6 is to be installed
Recommends: firmware-linux-free (>= 3~) but it is not going to be installed
Recommends: irqbalance but it is not going to be installed
Breaks: initramfs-tools (< 0.110~) but 0.98.8 is to be installed


I read that the problem has to do with having two kernel versions at once, so I tried the squeeze backports option. After adding the line:



deb http://ift.tt/1khhgJC squeeze-backports main contrib non-free


to my /etc/apt/sources.list, and running the following command:



sudo apt-get install -t squeeze-backports linux-image-3.16.0-4-amd64


I get the same error message as above. Can someone explain to me what the problem is, and how I would proceed to install the new kernel?



Generating a .img from tarball: The /dev/loop devices


I'm trying to make a .img from a tarball using the following script I found:



#!/bin/bash

# Packages required
# dosfstools parted
# Can be run on any Linux system
# loop.max_part=15 must be in kernel cmdline (cmdline.txt for rpi)
# then reboot

echo "creating image to fit on 2Gb card"
dd if=/dev/zero of=arch-rpi.img bs=1M count=1850

echo "Partitioning"
fdisk arch-rpi.img <<EOF
o
n
p
1

+100M

t
c
n
p
2


w
EOF

sleep 5

losetup -f arch-rpi.img
sleep 5

echo "Formatting vfat"
mkfs.vfat /dev/loop0p1
sleep 5
mkdir boot
echo "Mounting boot"
mount /dev/loop0p1 boot
echo "Installing"

echo "Formatting ext4"
mkfs.ext4 /dev/loop0p2
sleep 5
mkdir root
echo "Mounting root"
mount /dev/loop0p2 root

wget http://ift.tt/1BKipqa
echo "Installing"
bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sync
mv root/boot/* boot
sync
umount boot root
losetup -d /dev/loop0p1
losetup -d /dev/loop0p1
losetup -d /dev/loop0
echo "All complete, image arch-rpi.img created, compressing...."
zip -9 arch-rpi.img.zip arch-rpi.img


I'm doing this on my Raspberry Pi - Raspbian Wheezy. And when it gets to the line mkfs.vfat /dev/loop0p1 It says there's no such file / directory. I've read enough on Linux to know I'm trying to mount the .img as a loop device and then use mkfs to prepare the image for the tarball, but I don't quite know why loop0p# files are not there, they are listed by fdisk -l. What do I need to to in order to get this script I found working?


Thanks, Ben.



Windows don't show up in second monitor Debian ATI proprietary drivers


I've installed Debian 7.8 on my computer, then installed and attempted to configure the drivers. Everything went fine except for the fact that no windows show up on my second monitor at all. I enabled xinerama and enabled the displays on my display manager on Debian's side. The cursor and wallpaper is responsive but when I try to drag windows over they do not show up. Here is a picture of what I'm talking about;enter image description here


heres my xorg.conf;



#Section "ServerLayout"
# Option "Xinerama" "on"
# Option "Clone" "off"
#EndSection
#
#Section "ServerLayout"
# Screen 0 "first-screen"
# Screen 1 "second-screen RightOf "first-screen"
#EndSection

Section "ServerLayout"
Identifier "aticonfig Layout"
Screen 0 "aticonfig-Screen[0]-0" 0 0
Screen "amdcccle-Screen[1]-1" LeftOf "aticonfig-Screen[0]-0"
Option "Xinerama" "on"
EndSection

Section "Module"
EndSection

Section "ServerFlags"
Option "Xinerama" "on"
EndSection

Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection

Section "Monitor"
Identifier "0-DFP6"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
Option "PreferredMode" "1920x1080"
Option "TargetRefresh" "60"
Option "Position" "0 0"
Option "Rotate" "normal"
Option "Disable" "false"
EndSection

Section "Monitor"
Identifier "0-DFP7"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
Option "PreferredMode" "1920x1080"
Option "TargetRefresh" "60"
Option "Position" "1920 0"
Option "Rotate" "normal"
Option "Disable" "false"
EndSection

Section "Device"
Identifier "aticonfig-Device[0]-0"
Driver "fglrx"
Option "Monitor-DFP6" "0-DFP6"
Option "Monitor-DFP7" "0-DFP7"
BusID "PCI:1:0:0"
EndSection

Section "Device"
Identifier "amdcccle-Device[1]-1"
Driver "fglrx"
Option "Monitor-DFP6" "0-DFP6"
BusID "PCI:1:0:0"
Screen 1
EndSection

Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Virtual 3840 1920
Depth 24
EndSubSection
EndSection

Section "Screen"
Identifier "amdcccle-Screen[1]-1"
Device "amdcccle-Device[1]-1"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection


What, as examples, can produce a POLLNVAL?


The reference about poll() just says “The specified fd value is invalid. This flag is only valid in the revents member; it shall ignored in the events member.”.


That's not clear (at least to me): if the file descriptor is invalid, shouldn't poll return an error instead (negative return value)?


I had the same question about POLLERR and learned somewhere it may refers to, as an example, error in a device or network. This one, POLLNVAL, remains mysterious.


Do someone know example cases?



Final Term buffer always on top?


I'm not sure if this is a compositing issue, or what might be causing this. I'm running Arch Linux (64bit) and Final Term is the only app causing this peculiar issue.


Any ideas?


Example of the framebuffer overlapping another window



Sed regex printing into a file.txt


I'm connected to a MQTT stream, and I filter out the data by entering :


mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}"


into the Ubuntu terminal. This prints the only things that I am interested from the MQTT stream.


Now that I can do this I would like to dump this information into a qwerty.TXT file I've tried mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;w qwerty.txt}" and got the following error sed: -e expression #1, char 0: unmatched '{' I've looked into SED regex, and the examples are that w file.type writes into the file file.type -where type can be .txt for example.


I've also tried mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p >> qwerty.txt}" , mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;1a qwerty.txt}"


Q: How can I print my filtered MQTT stream into a file named "qwerty.txt"



How to get the real name of the controlling terminal?


How can one get the real name of the controlling terminal (if there is one, else an error) as a pathname?


By "real name", I mean not /dev/tty, which cannot be used by other arbitrary processes to refer to the same terminal. I prefer the answer as a simple shell code (like the example below) if possible, otherwise as a C function.


Note that this must work even if the standard input is redirected, so that the tty utility cannot be used: one would get a not a tty error in such a case, since tty just prints the file name of the terminal connected to standard input.


Under Linux, one can use:



echo "/dev/`ps -p $$ -o tty | tail -n 1`"


but this is not portable, as according to POSIX, the format of the terminal name is unspecified.


Concerning C functions, ctermid (NULL) returns /dev/tty, which is useless here.



Swap two files in bash


How do I swap two files in Linux console with minimum typing?


Boring approach:



$ mv file1.dat fileX.dat
$ mv file2.dat file1.dat
$ mv fileX.dat file2.dat


Libpcap share directory method missing


so im trying to run a c program but everytime i try to run it i get this message



error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory


I've re-installed libpcap I've install gcc and g++, ive updated it and im lost im not sure what else i can do... could anyone help out?



Enable debian VirtualBox brigde mode?


How can I Enable Debian 7 in VirtualBox in bridge mode?


I have to access external IP.


Thanks.



How do I edit text in Cyrillic / Russian on OpenBSD?


I'm trying to make it possible to easily edit text in Cyrillic / Russian on a remote OpenBSD 5.2 amd64.


I'm using emacs-21.4p18-no_x11 , which doesn't show any Cyrillic characters whatsoever when I try opening up a file with a windows-1251 encoding (instead showing question marks and sometimes even randomly mangling the file when a save is attempted), unless I start it as env LANG=bg_BG.CP1251 emacs (for some reason, there's no ru_RU.CP1251 in /usr/share/locale/ ) and PuTTY to Win1251 (Cyrillic); however, this only works in displaying the characters, not for typing any characters -- switching the local keyboard to Russian and typing into emacs causes various random internal commands to be executed, even though quitting emacs and using cat(1) works without any issues for Russian input (which could then be opened up in emacs and copy-pasted from the temp file to the real one, which is very cumbersome and unproductive).


I've also tried mg(1) , but it shows up Russian characters as \315 etc, and doesn't let you type in Russian, either.




  • If the files I'm editing are nginx.conf, is there a way to automatically specify the encoding for emacs? All the File Variables examples appear to start with a mode, but there's no mode for nginx.conf.




  • How do I make emacs / mg load files in either windows-1251 or koi8-r, and show them in UTF-8?




  • How do I make emacs / mg accept Cyrillic input?





Use lines in a file to produce string and file name


I have a file, foo.txt, that has a folder name on each line:



folder_1
folder_2
folder_3


And I'd like to do something like this:



cat foo.txt | xargs -I {} echo 'function {}() { return stuff; }' > {}/function.js


In other words, I'd like to read a file line by line, then use each line to both create a string and create the name of the file in which the string is stored.


How does one do something like this from the command line in bash?



Webmin - Edit User (emails)


I want to set an automatic email notification to go out when a user reaches a certain quota.


I installed Usermin to enable additional options but when I go to "Users and Groups" under the "System" section in Webmin and click on a user's name, I don't get to see the option to change the user's email address anywhere.



httpd memory usage


Having some problems with httpd (Apache/2.2.29) memory usage.


Over time, memory usage in the httpd processes creep up until it's eventually at 100%.


Last time I restarted httpd was about 24 hours ago. Output from free -m is:



[ec2-user@www ~]$ free -m
total used free shared buffers cached
Mem: 1655 1415 239 0 202 424
-/+ buffers/cache: 788 866
Swap: 1023 4 1019


To prove that it's definitely httpd, I restarted httpd and ran free -m again:



[ec2-user@www ~]$ sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[ec2-user@www ~]$ free -m
total used free shared buffers cached
Mem: 1655 760 894 0 202 360
-/+ buffers/cache: 197 1457
Swap: 1023 4 1019


So, restarting Apache takes free memory from 239 Mb to 894 Mb - which seems like a big leap.


I've been going through the list of currently enabled Apache modules (there's quite a lot) and disabled/removed mod_wsgi and mod_perl (neither of which are required for this server, which is running a PHP-based web application - Magento, specifically).


Based on http://ift.tt/1nJDy6G, I've run ps aux | grep 'httpd' | awk '{print $6/1024 " MB";}' and get the following output:


[root@www ~]# ps aux | grep 'httpd' | awk '{print $6/1024 " MB";}' 15.1328 MB 118.09 MB 127.449 MB 129.059 MB 117.734 MB 113.824 MB 125.062 MB 123.922 MB 119.855 MB 108.066 MB 136.23 MB 114.031 MB 113.27 MB 110.695 MB 102.113 MB 113.234 MB 186.816 MB 118.602 MB 0.835938 MB


Running the other suggested diagnosis tool for MaxClients which is ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}' returns the following:



[root@www ~]# ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'
110.212 MB


This server (Amazon AWS m1.small instance) has 1.7 Gb of RAM. So, therefore:


Any further pointers/suggestions on how best to tweak the httpd settings or how to diagnose what exactly might be causing this?



How can this pdf file be created from this website?


This pdf file seems created from this site.


I check the information of the pdf file by pdfinfo the pdf file:



Creator: pdftk 1.12 - www.pdftk.com
Producer: itext-paulo (lowagie.com)[JDK1.1] - build 132
CreationDate: Mon Mar 20 14:07:22 2006
ModDate: Mon Mar 20 14:07:22 2006
Tagged: no
Form: none
Pages: 565
Encrypted: no
Page size: 612 x 792 pts (letter)
Page rot: 0
File size: 6657623 bytes
Optimized: no
PDF version: 1.5


I don't know pdftk can create pdf files from webpages. I guess it was created by some other way (which can add number to left bottom of each page), and then processed by pdftk. But I am happy to be wrong.


I like to know how that can be created (so long ago), because I would like to have a pdf file from the newer version of the book.



postfix smtp connection timed out, why?


A CentOS 7 web server has postfix, dovecot, and mailx installed. I have been able to make an IMAP connection to the server in order to read inbox mail using a remote Thunderbird client, but I am not able to make an SMTP connection to send email from Thunderbird. When I do forensics, I discover that the attempted SMTP connection times out. How can I resolve this problem of the connection timing out, so that I can send email from Thunderbird through the server?


My forensics so far have resulted in:


Typing hostname in the terminal at the server returns mydomain.com.


nano /usr/lib/firewalld/services/smtp.xml indicates the smtp port is 25


The smtp service is activated in the public zone because firewall-cmd --list-all results in:



public (default, active)
interfaces: enp3s0
sources:
services: dhcpv6-client imaps openvpn smtp
ports:
masquerade: yes
forward-ports:
icmp-blocks:
rich rules:


But when I try to telnet from my devbox to the remote CentOS 7 server, I get the following results. Typing telnet mydomain.com 25 resulted in:



Trying my.SERVER.ip.addr...
telnet: connect to address my.SERVER.ip.addr: Connection timed out


Then typing telnet smtp.mydomain.com 25 resulted in:



Trying my.SERVER.ip.addr...
telnet: connect to address my.SERVER.ip.addr: Connection timed out


Also, typing openssl s_client -CApath /etc/ssl/certs -starttls smtp -port 25 -host smtp.mydomain.com results in:



socket: Connection timed out
connect:errno=110


Similarly, typing openssl s_client -CApath /etc/ssl/certs -starttls smtp -port 25 -host mydomain.com also resulted in:



socket: Connection timed out
connect:errno=110


I typed nano /etc/postfix/main.cf to start to examine the config, but did not find anything related to ports.



How does Linux prevent applications from sending more packets than the link can handle without dropping packets?


I couldn't make the question any clearer so here's an example scenario:


Given a Linux machine connected to an IP network through a physical interface of bandwidth 10Mbps (or a higher speed interface with a tc token bucket filter to limit the rate to 10Mbps).


On a remote machine (with an equal speed or faster link) start an iperf UDP server:


iperf -s -u -i 1


On the local machine start an iperf client with bw=20Mbps:


iperf -c <server ip> -u -i 1 -b 20M


Observation: The sender never exceeds the 10Mbps rate (defined in the link layer either in hardware or a tc qdisc).


I expected to see the sender push out 20Mbits worth of packets a second causing the local tx queue of the interface to build up and packet losses start to happen. But this is not the case. Why?


I have tried to look into the net/sched folder to the Linux kernel but I can't seem to find the source of this behavior.


Appreciate you help. Also feel free to suggest changes to the title to make it more relevant.



how to save the contents of a webpage in a file using shell script


how to save the contents of a webpage in a file using shell script. Web page is using URL, username and password to open.



curl -O odcview:password http://stomv11204:8080/SIM/realGraph.do?componentId=76&filterString=MCRC_STR&tabname=Durables&componentId=75&filterFlag=0&reqtype=de&filterTitle=dname


Transpose a file, and replace missing values by


Please guide with the following data formatting.


I have Readings for Names, from Machines and sometimes these readings are replicated. Where a reading was not found, it is left as blank.



Name Instrument Rep R1 R2 R3
N1 I1 1 1 2 3
N2 I1 1 1 3 4
N1 I1 2 2 3 4
N3 I1 2 3 4 5
N1 I2 1 1 2 3
N2 I2 1 1 3 4
N2 I2 2 2 3 4
N3 I2 1 3 4 5
N1 I3 1 1 4
N2 I3 1 2 5
N3 I3 1 6
N3 I3 2 1


First, I want to consolidate the replicates by using their mean (per name per location). Then, I want to transpose this data and replace the missing values by dot (.) .


What I want in my output is



Reading Instrument N1 N2 N3
R1 I1 1.5 1 3
R2 I1 2.5 3 4
R3 I1 3.5 4 5
R1 I2 1 1.5 3
R2 I2 2 3 4
R3 I2 3 4 5
R1 I3 1 2 .
R2 I3 . 5 6
R3 I3 4 . 1


Please note that the number of Names and Readings are quite variable, in some files I have 134 readings, some others have 28 etc. but the readings always start from col3.


This is what I tried unsuccessfully for a test run for only one column



awk '
NR>1{
arr[$1" "$2" "$3] += $4
count[$1" "$2" "$3] += 1
}
END{
for (a in arr) {
print a, arr[a] / count[a]
}
}
' file | awk '
NR == 1 {
n = NF
for (i = 1; i <= NF; i++)
row[i] = $i
next
}
{
if (NF > n)
n = NF
for (i = 1; i <= NF; i++)
row[i] = row[i] " " $i
}
END {
for (i = 1; i <= n; i++)
print row[i]
}'


What is the persistence of the handle of a broken FIFO?


Say an application opens for writing, a file, which is a FIFO to which something is “listening”, and later, this “listener” closes; if the application attempts to write to it, the application will get a broken pipe error. That's OK, but I wonder if there is a risk for the handle to be reused and therefore a risk for writing to an handle which is not anymore what's supposed to be. Thus the question: what's the persistence of the handle of a broken FIFO? How long can an application rely on the broken pipe error, to know the other end of the FIFO was closed? Or is it guaranteed the handle will never be reused for all the lifetime of the application unless it has explicitly closed it?



chromium browser (pepperflashplugin) opening listening ports on 0.0.0.0:5353


I am using chromium browser (chrome) with pepperflashplugin in Debian. I have noticed, chromium/pepperflashplugin opens a listening port on my public interface 0.0.0.0:5353 as seen with netstat:



netstat -lptun
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:5353 0.0.0.0:* 13971/libpepflashpl


I have been using Firefox (Iceweasel) before and I have never seen browser/flash-plugin to open ports. Indeed, I have never seen any client application opening listening ports on 0.0.0.0.


Why is chromium doing this?


Is this necessary ?


Can I disable this?


Can I start chromium with pepperflashplugin disabled ?



Apache modssl returning random unwanted 200's rather than 404's


I have a fairly simple apache 2.4.7 config on CentOS 6.5 Linux and an active web server. No PHP or CGI, just some static pages and a proxypass to a different server tier.


I'm doing some security probing and purposely sending invalid data in the form of URL's with ~usernames that don't exist. I expect to get a 405 error.



HTTP/1.1 405 Method Not Allowed
Date: Fri, 27 Feb 2015 21:28:51 GMT
Server: Apache-Coyote/1.1
X-Frame-Options: SAMEORIGIN
Allow: GET,DELETE,POST,PUT
X-Frame-Options: SAMEORIGIN

And that's what I get 90-95% of the time. But about 1 in 20-30 tries get a 200 return code with an otherwise blank page.



200 27/Feb/2015:21:02:50
HTTP/1.1 200 OK
Date: Fri, 27 Feb 2015 21:28:50 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Content-Length: 1

If it was a simple configuration issue, I would expect every call to either fail or work, not 3-5% failing.


I only see this on the SSL port, the http port is also configured (though not open to the public) and it does NOT show the same issue. I can send hundreds of calls though http with no errors, but get at least one or two every 50 calls are so on https.


Some of the tests I've already tried unsuccessfully, are:


Logs just report the fact that either a 405 or a 200 was sent but no apparent difference in the url. Or any errors.


Eliminate any inbound firewall issues, by trying call on local loopback, same issue.


Eliminate issue with outbound load balancer by calling proxy connection directly. My reasoning for this test, is there nothing in this tier layer to handle ~username calls and it likely being ignored and passed by the wildcard proxypass to the next layer. Next sever layer is responding perfectly. No errors even with hundreds of calls in test blast.


Ran same test on Development environment which is configured exactly the same (AWS image is the same so differences is only in IP addresses) No errors, so volume in production maybe issue, but not a very helpful one. Server is currently averaging around 5-10 hits/sec with short peeks up to 25. CPU load is 0.00 to 0.02 with over 2G of 7G free memory and no disk issues.


I don't want to post the full configuration file here, but it's pretty vanilla with the relevant parts of the VirtualHost reading. (URL's changed to protect the innocent and keep stackexchange from thinking they're links)




Listen 443
SSLCipherSuite ***REDACTED***
SSLHonorCipherOrder on
SSLSessionCache "shmcb:/opt/httpd/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
SSLProtocol ALL -SSLv2 -SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
SSLCompression Off




SSLEngine on
SSLCertificateFile ***REDACTED***
SSLCertificateKeyFile ***REDACTED***
SSLCertificateChainFile ***REDACTED***

BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "/opt/httpd/logs/ssl_request_log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Order deny,allow
Allow from all

SSLProxyEngine on


ProxyPass /terms !
ProxyPass /static !
ProxyPass /images !
ProxyPass /terms_ccm !
ProxyPass /pay/ https ://pay.ACME.COM/payment/
ProxyPassReverse /payment/ https ://pay.ACME.COM/payment/
ProxyPass / http: //mbg.ACME.COM/mobgate/
ProxyPassReverse http: //mbg.ACME.com/mobgate /


How does `ls` know whether it's piped or printed


ls normally prints like this:



1 1249 1653 23 33 4581 6202 6447 789 836 903 config.gz kpageflags sysrq-trigger
10 1253 1658 24 34 4582 6206 648 79 837 91 consoles loadavg thread-self
1003 1255 1662 251 347 4583 6207 649 791 84 923 cpuinfo locks timer_list
1004 1257 1667 252 35 4689 6209 6799 8 840 925 crypto meminfo timer_stats
1005 1261 167 26 357 48 6232 6986 80 841 998 devices misc uptime
1006 1263 1670 266 36 49 6242 6992 802 846 acpi diskstats modules version
1008 13 1677 27 37 5 6267 6993 803 848 asound dma mounts vmallocinfo


But when you pipe it eg to cat with ls /proc | cat, it prints it as if it got -1 (works the same also with grep and other commands):



1
10
1003
1004
1005
1006
1008
1010
1012
106
107
1073
108
109
1152
117
118
1247
1249
1253


My question is, how does it know it's being piped instead of printed? Or, how it happens?



Why does the input to xargs is 1 string but without is strings in separate line?


I am trying to pipe file to rm via xargs. I understand that what I am tryng to do could be done by git clean but I am practicing the cli.

I tried this:



for files in $(git status --porcelain| sed 's/^??//g'); do echo $files; done | xargs rm -rf


but it did not work. I figured it was because when running this:



for files in $(git status --porcelain| sed 's/^??//g'); do echo $files; done | xargs


The files seem to be in 1 string separated by a space.

But when I run for files in $(git status --porcelain| sed 's/^??//g'); do echo -n $files; done the files are displayed in the console in a separate line.


So (if I am right on this) what is the difference between:

for files in $(git status --porcelain| sed 's/^??//g'); do echo -n $files; done | xargs

and


for files in $(git status --porcelain| sed 's/^??//g'); do echo -n $files; done


and the files in the second case are displayed each in each own line and in the first case it is one string? And how would I fix this so that it works with rm -rf?



Colorize line number in grep


Is there a way to colorize line numbers when using grep with the -n option?


For example, echo "hello" | grep -n lo outputs


1:hello


where lo is colorized in red (being the match). Can I configure grep to colorize the line number, i.e. the 1: portion? Are there specific shells/terminals that allow that?



Combine the output of while loop into tar


I'm trying to create a script that mysqldumps all my databases, creating an individual .sql file for each database and combines the output into backup-DATE.tar.gz.


I've gotten as far as being able to create the .sql backups, but the last hump I can't overcome due to my limited knowledge is how to combine all the .sql files into backup-DATE.tar.gz.


This is what I have so far:



mysql -N -u user -p'password' -e 'show databases' | while read dbname; do mysqldump --add-drop-table -u user -p'password' "$dbname" > /backuplocation/"$dbname".sql; done


This outputs all my databases into my backup location individually ie:



/backuplocation/db1.sql
/backuplocation/db2.sql
/backuplocation/db3.sql


Is it possible to combine this output into backup-DATE.tar.gz with this strategy?



Disconnect of primary OpenLDAP freezes network


I am running two Ubuntu 12.04 LTS systems, one physical one virtual, configured as primary/secondary.



Physical - Primary LDAP, Secondary DNS/DHCP


Virtual - Secondary LDAP, Primary DNS/DHCP



I've noticed that if the physical server loses it's network connection clients on the network freeze (majority linux). The clients ARE ssh'd in to network servers and mounting NFS exports but shouldn't the secondary system take over or have I missed something.


Any ideas on what items I should look at or which configuration information would be helpful in diagnosing this?



hard drive formatted while Linux setup, lost partitions


I have installed Ubunto 14.04 on sda1. but after the installation finished, all the partitions are gone . I have important data on sda5 , and when I run the following command : sudo fdisk -l in the terminal the following appears :



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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000cf11e

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 976771071 488134657 5 Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5 501760 976771071 488134656 8e Linux LVM

Disk /dev/mapper/ubuntu--vg-root: 495.6 GB, 495594766336 bytes 255
heads, 63 sectors/track, 60252 cylinders, total 967958528 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical):
512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096
bytes Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition
table

Disk /dev/mapper/ubuntu--vg-swap_1: 4202 MB, 4202692608 bytes 255
heads, 63 sectors/track, 510 cylinders, total 8208384 sectors Units =
sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512
bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition
table


The total size of the hard drive is 5oo GB



Get information on tools/packages that are not installed


How can I get information about packages I have not installed (other than a web search)?


For example, imagine I am interested in iftop. If I do a web search I can find a wikipedia article and the man page, but how can I find information like that from the terminal without using a browser?



Saving from arecord on a raspberry pi across a network to a mac


I've currently got a usb mic plugged into a Raspberry Pi B+ and am using the following code to record data:



arecord --buffer-time=5000000 -D plughw:1,0 -f cd -t raw | lame -r - stream.mp3


I then serve the resulting stream.mp3 file on the pi using Python simplehttp and listen to the recorded data using mplayer on the command line.


I'd really like to skip the step of saving audio data on the pi if it can be helped. I've tried various attempts at piping the audio data using ssh and netcat to mplayer on my mac but have not figured how to do this. It's not important to me to encode the audio using lame; I'm simply doing that to save space and bandwidth.



CentOS install spanning 2 or more CDs


I have a custom CentOS install which used to fit on 1 CD. With recent additions, it takes up more space than can fit on 1 CD. Some of our customers have old systems that aren't DVD compatible so we have to distribute our product on an install CD which now needs to be 2 CDs. What is the easiest way to setup our install to span 2 CDs?? So far, I've discovered the .discinfo file which specifies how many install discs there are. For Example, CentOS 5.5:



1272587247.016243
Final
i386
1,2,3,4,5,6
CentOS/base
/home/buildcentos/CENTOS/5.5/en/i386/CentOS
CentOS/pixmaps


After the i386 line, the number of installation CDs is displayed. In this example, '1,2,3,4,5,6'. How does one decide what RPMs and such to put on other CDs when the install grows past 1 CD??



Values from two lists are not processing correctly within two nested loops


I am trying to pass some values contained in two lists to a simple echo within two nested for loops (the echo is used to look at what is generated inside the inner loop). But the results are not expected. I sure could use some guidance!


Using the bash shell. Here is the snippet:





a_list="0.05 0.10"
b_list="120.0 130.0"
c=44
x=555.0
for a in $a_list
do
for b in $b_list
do
echo $x $a $b $c
done
done




I expect this:



555.0 0.05 120.0 44
555.0 0.05 130.0 44
555.0 0.10 120.0 44
555.0 0.10 130.0 44


but I get this:



555.0 0.05 120.0 44
44.0 0.05 130.0
555.0 0.10 120.0 44
44.0 0.10 130.0


The 2nd and 4th lines are wrong. The 44 appears to echo first and overwrite the 555.0 . If I load the values of the lists directly into the for loop, it works OK. Like this:





c=44
x=555.0
for a in 0.05 0.10
do
for b in 120.0 130.0
do
echo $x $a $b $c
done
done


Thanks for any help and insights!