Saturday, June 16, 2018

Using a 19V (3.42A) power adapter instead of a 20V (2.0A) for my Lenovo laptop. Is this safe?? (Laptop battery is non functional)

Im ready to accept "long term" degradation to my laptop if i can remain lazy and not go having to find a perfect replacement adapter. Third world electronics scares me (Im in the third).
As long as i can run my laptop without my files being wiped out.


Thanks

Move Windows 8.1 installation to another PC - is it possible to avoid a re-install & just move the hard drive?

Last year I've installed a clean copy of Windows 8 (later upgraded to 8.1) on a new laptop. This process was challenging because the laptop included Windows 8 pre-installed (plus bloatware), and my Windows 8 ISO (which I bought before from a Windows 7 upgrade) rejected the serial key that came with the laptop. I had to find the official ISO compatible with my keys and OEM installation.


Now I need to migrate this Windows installation to another laptop. Basically moving the hard disk. Long time ago, I recall that there was a command I could run on Windows to set in a special way such that—upon the next boot—it will scan the hardware and re-configure drivers as needed.


Can I do the same with Windows 8.1? I can imagine that today it's a little more complicated (UEFI, signed Bios, etc). I'd like to avoid re-installing everything one more time.

power supply - UPS suddenly restarting, what might be the cause?

Background


My UPS has a backup of about 10 mins, thus, it's battery life is good. No problems detectable.


My CPU, on the other hand, is also fine with no major hardware problems (as it looks so) except that I suspect that it's CMOS battery is weak. I can say so because once in every 4-5 days or so, my computer time resets.


I run windows 7 (I don't think computer specs matter as it's a hardware, more specifically, UPS problem)


Problem


Now on to the problem, from a few days I've been experiencing weird issues. Once in every few days (a week usually) the UPS suddenly restarts (I can confirm it restarts because it gives that long distinctive beep, which it gives when I start it), thus, computer experiences an unexpected shutdown. The issue looks very new to me, Googling hasn't helped. As far as the cause is concerned, I am completely blank. As I said, my UPS' battery life is good and as far as I can tell, there are no power fluctuations at the time this happens.


Secondary Problem


This is yet another problem, which I think is related. I've noticed that whenever I leave my UPS open after shutting down the computer, the next time I open computer, it doesn't. I mean CPU throws green light, fan runs, but the computer doesn't boot. To fix it, I usually reset the motherboard by long pressing the power button and the computer boots as normal.
Any ideas why it's happening?

How to avoid terminal to scroll down to last message in bash?


I write a bash script that run some other commands in new terminal:


#!/bin/bash
# Sample script
gnome-terminal --title="blah blah" -x bash -c ffmpeg -i udp://239.1.2.1:60001?fifo_size=50000000 -acodec copy -vcodec copy -preset ultrafast \
-flags -global_header -f hls -hls_time 20 -hls_wrap 5 /var/www/html/ts/1.m3u8 &
sleep 1
gnome-terminal --title="blah blah" -x bash -c ffmpeg -i udp://239.1.2.2:60002?fifo_size=50000000 -acodec copy -vcodec copy -preset ultrafast \
-flags -global_header -f hls -hls_time 20 -hls_wrap 5 /var/www/html/ts/2.m3u8

The output of each ffmpeg line is more than one page and it is similar to:


libavutil      54.  7.100 / 54.  7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
... many pages after ....
[h264 @ 0xc04c60] decode_slice_header error
[h264 @ 0xc04c60] no frame!
[h264 @ 0xc04c60] non-existing PPS 0 referenced
.... many pages after ....
Program 105
Metadata:
service_name : IRIB-TV5
service_provider: IRIB
[adts @ 0xf943e0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Output #0, hls, to '/home/stream/Desktop/tst/1.m3u8':
Metadata:
encoder : Lavf56.4.101
Stream #0:0: Video: h264 (libx264), yuv420p, 720x576 [SAR 12:11 DAR 15:11], q=-1--1, 25 fps, 90k tbn, 25 tbc
Metadata:
encoder : Lavc56.1.100 libx264
Stream #0:1(per): Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc56.1.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac_latm (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 @ 0xf42120] reference picture missing during reorder
[h264 @ 0xf42120] Missing reference picture, default is 65716
[h264 @ 0xf42120] reference picture missing during reorder
[h264 @ 0xf42120] Missing reference picture, default is 65717

When I run this script in a new terminal and I launch the command (in this case ffmpeg), it immediately shows many output lines, many pages sometimes, and goes to last message automatically...


How can I scroll up and down to first message in the terminal, or stop it at the first page?


Answer



Update after that the question was completely reformulated:


You can use | more or | less to stop the output after the first page.


 gnome-terminal --title="blah blah" -x bash -c  ' find  ~  | less'

Note: you need to use '' to say where it finishes the bash commands.
Within less you can move:



  • Home and End To the beginning and the end of the page.

  • PgUp and PgUp One page down or up.

  • Up and Dn One line up or down.




One of the line of your script can be similar to


gnome-terminal --title="blah blah" -x bash -c                                 \
'ffmpeg -i udp://239.1.2.1:60001?fifo_size=50000000 -acodec copy -vcodec copy \
-preset ultrafast -flags -global_header -f hls -hls_time 20 -hls_wrap 5 \
/var/www/html/ts/1.m3u8 | less ' &



There are some shortcuts:



  • Ctrl+ Shift+Up or Dn To scroll up or down of a line

  • Shift+PgUpor PgDn To scroll up or down of a page

  • Shift+Home or End To scroll up to the beginning or down to the end


You can read about other shortcuts directly on the gnome help page.


Friday, June 15, 2018

security - Is an antispyware really necessary?


I've been always running frequent antivirus scans on my computers, more because I am a security freak than because I really need them (I'm not one of those users that, after a browsing session, manage to fill their PCs with unknown stuff from unknown websites).


However, I almost never run antispyware scans, especially because they tend to consider too many things as malicious even if they are not. Is it really necessary to have an antispyware program beside an antivirus program, or is an antivirus enough?


Answer



Well, your question isn't very objective, but I'll answer it anyway.


It really depends. If you are a person that downloads things quite frequently, even from a secure source, then you might still want anti-spyware. Anti-Spyware has different uses than Anti-Virus. Spyware is much harder to detect, as it doesn't really behave like a normal virus. Spyware is meant to hide behind an actual application usually, that is why programs tend to detect it even if it is legitimate.


Also, if you use your computer for storing important documents, then it might be worth the hassle.


However, I would say for average use, it is quite unnecessary. Most anti-virus has some anti-spyware anyway. I will recommend AVG Free, probably the best Security program I have found for that price.


Iptables, allow common ports, block the rest


I want to allow people to connect to ports 22, 80, and 443. Also I want to be able to do DNS lookups from my server.


Here's what I'm trying:


iptables -A INPUT -m tcp -p tcp --dport 1 -j ACCEPT
iptables -A INPUT -m udp -p udp --dport 1 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -m udp -p udp --dport 53 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -m udp -p udp --dport 80 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -m udp -p udp --dport 443 -j ACCEPT
iptables -A INPUT -m tcp -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -m udp -p udp --dport 22 -j ACCEPT
iptables -A INPUT -m tcp -p tcp -j REJECT
iptables -A INPUT -m udp -p udp -j REJECT
iptables -A OUTPUT -m tcp -p tcp -j ACCEPT
iptables -A OUTPUT -m udp -p udp -j ACCEPT

iptables -L


Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:tcpmux
ACCEPT udp -- anywhere anywhere udp dpt:1
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT udp -- anywhere anywhere udp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT udp -- anywhere anywhere udp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT udp -- anywhere anywhere udp dpt:ssh
REJECT tcp -- anywhere anywhere tcp reject-with icmp-port-unreachable
REJECT udp -- anywhere anywhere udp reject-with icmp-port-unreachable
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp
ACCEPT udp -- anywhere anywhere udp

If I omit these lines:


iptables -A INPUT -m tcp -p tcp -j REJECT
iptables -A INPUT -m udp -p udp -j REJECT

I can ping out, but then I'm not closing all ports by default, which is the goal. Why is an INPUT rule affecting my ability to do hostname lookups (ex "ping google.com" from my server?)


Answer



You need to allow related traffic back in again (i.e: the replies to your outgoing DNS traffic). Also, you may want to use a default drop rather than a specific deny-all rule to save some space.


iptables -A INPUT -p tcp -m multiport --dports 22,80,443 -j ACCEPT


iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT


iptables -P INPUT DROP


Your OUTPUT chain rules aren't needed as the chain has a default ACCEPT on it currently, and the port 53 rules aren't needed because you aren't hosting a DNS server, merely using one, so the traffic leaves via the OUTPUT chain, not the INPUT one.


windows 7 - Remote Desktop not loading Video Card Driver



I sometimes use my Windows 7 server box (running Windows 7 Enterprise, 64-bit) for development. Space on my desk is limited however so I like to use Remote Desktop to remote into it from my main machine (Windows XP 32-bit).




I have an ATI Radeon HD 5450 video card with drivers correctly installed. When doing anything that requires proper video card drivers (such as initializing OpenGL or DirectX) it all works fine when logged in directly on the Windows 7 machine.



When I remote into the Windows 7 machine from my XP machine however, Windows 7 uses "RDPDD Chained DD" as its video card display driver and the ATI Drivers fail to load (or if they were loaded, crash). This means all applications that need to initialize OpenGL or DirectX fail to do so.



Is there a way around this?



Note: My XP machine has an ATI Radeon HD 4800 video card, if that makes a difference.


Answer



Remote Desktop will not allow this. In Server 2008 R2 SP1, there is a new feature called RemoteFX which can allow some rendering through a remote desktop connection, but the server is required for this feature to work.
I would recommend that you keep the server's monitor where you can see it well and use 'Mouse without Borders' to access the server machine from the same keyboard and mouse that you use on your main workstation. You can even drag and drop files between computers. Best of all, it's free!



hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...