Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, November 16, 2020

moving lots of files with BOX

I had to move like 300K files in BOX, so just sharing a bit of how I did it and how to check the progress.

Basically, get:

1. BOX drive (no gnu/linux version available, so mounting the "folder" on a gnu/linux VM as a shared dir, and working from there)

2. A gnu/linux VM (I use virtualbox) with the necessary kernel stuff to mount shared dirs (thing to mount vboxfs)


I guess you could have done something similar in windows or mac too just writing a program directly in those platforms. But I hate both OSs, so, no.


You just write the program to rename/move the files however you want, and run it as with any other dir.


The catchy part is that box is super slow (for me at least), so even when in your disk all files would have been updated fairly fast, in the background, the thing takes forever to finish the sync... so if you check in the web version, many of the files would still be in the old location/will have their old filenames.

There should be a file called Box-{version?}.log in:

c:/Users/$USER/AppData/Local/Box/Box/logs/


There you should be able to see logs in the format:

DATE TIME ID? INFO    LocalExecutor-2      box_fs_sync_api       Move item on box.  XXXX

Telling you what it's doing.
I also mounted this in my VM and checked the logs with tail -f.


As of the time of this post, there is apparently no way to tell the sync progress besides this... And you basically will have to grep the log and compare with the list of files done with whatever you have in order to have an idea of the total percentage.

Not the coolest system.

Until the sync is complete, your box drive icon will show "Box Drive is updating your files" on mouse over. And it takes really super long... But maybe it's because of the many requests I sent, so my account was limited or something. It's like 1~3 requests a second based on the logs above.

If you're luckier than me, it should take under 3 days. If not, I hope you have a quiet computer.

Monday, April 13, 2020

rsyslog change output log file based on hostname

I want to put all the logs for hostnames starting with XXX in
/var/log/XXX.log.

And I'd also like to be able to read the file without having to do sudo
everytime...

Here is how:

in /etc/rsyslog.conf:

# remember to open your udp port to receive logs from other servers

$ModLoad imudp
$UDPServerRun 514
#### GLOBAL DIRECTIVES ####

# change umask so the default one doesn't mess with your filecreatemode permissions
$umask 0000

then create a file in /etc/rsyslog.d/50-my-XX-logs.conf:

#(any number is fine)

# this makes the file readable by anyone
$FileCreateMode 0644
:HOSTNAME, startswith, "XXX" /var/log/UHN2.log
# and stop any further filtering with the next line
& stop

This made it work for me. You can check more on the filters and
conditionals with rsyslog.conf(5) manual page.

Thursday, April 2, 2020

playing dvds in debian10

Steps
1. add the contrib (and probably non-free) repo to your sources list
2. install the libdvd-pkg package, and a player
3. run the libdvdcss library installer
4. (might be necessary to) set the region for your dvd device
5. try playing it

From top to bottom
if necessary, change your sources list

$ cat /etc/apt/sources.list
deb http://debian-mirror.sakura.ne.jp/debian/ buster main non-free contrib
deb-src http://debian-mirror.sakura.ne.jp/debian/ buster main non-free contrib
...


(you need to have the contrib repo as above)
if you did any changes, do "sudo apt-get update" to fetch the new repo data.

install the libdvd-pkg

$ sudo apt-get install libdvd-pkg
or better
$ sudo apt-get install libdvd-pkg libdvdcss-dev libdvdcss2 libdvdcss2-dbgsym libdvdnav4 libdvdread4 lsdvd regionset mpv lsdvd

then run the configure script, to compile the libdvdcss library
$ sudo dpkg-reconfigure libdvd-pkg

I don't remember if you needed to do this the first time, or just if your dvd wouldn't play... but try inserting a dvd, and do
$ sudo regionset
Some commercial DVDs won't play unless you have the "correct" dvd region for the region they were supposed to be sold to. Capitalism can be scary.
So, you can select a region, or just leave it as it is.
More info at /usr/share/doc/regionset/README

Finally, let's try playing something
$ mpv dvd://1

And you can check your dvd contents with
$ lsdvd

I'm sure you can also click around with your favorite desktop environment and find a way to play your dvd as well.

Wednesday, March 25, 2020

using synergy to share your keyboard and mouse with another computer

What's Synergy?

An awesome program that allows you to share your mouse/keyboard over the network with another computer.
You basically need to have the "server" installed on the computer your keyboard/mouse are connected to, and a "client" to the other one.


I use this at the office, where I'm sadly forced to use ms windows, and connect it to my GNU/Linux box.
I also use it at home when I bring my office laptop sometimes, and just do all the input with my home keyboard/mouse, as I'm a happyhacking keyboard fan.

How to install

On Windows: google for "windows synergyc 1.8.8", for the windows one, and install that
On GNU/Linux Debian-family: sudo apt-get install synergy

in Debian 10

As of debian 10, synergy is an outdated package apparently. I guess it wasn't very popular...

But you can install it from the stretch's repo directly, like this:


sudo apt-get install libcrypto++6 libqt4-network libqtcore4 libqtgui4
wget http://ftp.jp.debian.org/debian/pool/main/s/synergy/synergy_1.4.16-2_amd64.deb #just find this deb file in whatever mirror you prefer
sudo dpkg -i synergy_1.4.16-2_amd64.deb 


How to setup

in ms windows (client)

Just make a "shortcut" with something like "C:\Synergy\synergyc.exe XX.XX.XX.XX"  (your server's IP)

in GNU/Linux

create a file /etc/synergy.conf with these contents:


section: screens
random_name_for_your_server_box:
random_name_for_your_client_box:
end
 
section: links
random_name_for_your_client_box:
        left = random_name_for_your_server_box
random_name_for_your_server_box:
        right  = random_name_for_your_client_box
end


You'll also need to put your "random_name_for_your_server_box" name in /etc/hosts.

How to use

1. in windows: double click the "shortcut" thing
2. in GNU/Linux, open a terminal, and type "synergys"

The client terminal should show some debug messages, like "server connected!" and stuff like that.
Just move your mouse pointer and see it go from your server screen to your client's.

I'm surprised really so few people know about this and end up buying more keyboards, or worst, using a bluetooth one just to be able to switch the input (facepalm). sshing is also super useful and all, but sometimes you use a crappy OS like ms windows in which that's just not possible, or just want to use it on its same screen.

You can also use this in a better environment, GNU/Linux with GNU/Linux.
Don't get me started about macs.

Thursday, December 5, 2019

connecting to wifi in a self created certificate enterprise environment

Basically, my office environment needs me to connect with a self signed certificate for our wifi, and in GNU/Linux, this was a lot harder than I expected.

In short, you can't use the default/easy to use nmcli. But you have to set your username/password directly in the wpa_supplicant conf, and just connect directly with the wpa_supplicant program.


This is what works

you can get the list of SSIDs available by

nmcli device wifi list

# 1 make this file
################################################################################
# /etc/wpa_supplicant.conf
network={
ssid="XXX"
key_mgmt=WPA-EAP
identity="your_username"
password="your_password"
}

################################################################################

# enable wpa_supplicant (connect to wifi)
wpa_supplicant -Dnl80211 -iwlx00018e8e09f2 -c /etc/wpa_supplicant.conf


#then you have to do dhclient to get an IP
sudo dhclient wlx00018e8e09f2



This is what I also needed to do for my crappy wifi usb card


ended up creating a script to enable my crappy usb wifi
################################################################################
modprobe rt2800usb


echo "0789 0168" > /sys/bus/usb/drivers/rt2800usb/new_id

# wpa_supplicant -B -Dnl80211 -iwlx00018e8e09f2 -c /etc/wpa_supplicant.conf &
wpa_supplicant -Dnl80211 -iwlx00018e8e09f2 -c /etc/wpa_supplicant.conf &

sleep 3
echo killing initial wpa_supplicant
killall wpa_supplicant

sleep 3
echo starting final wpa_supplicant

Some of the things I tried and didn't work


nmcli doesn't work as it NEEDS to do cacert validation, apparently that
can't be disabled on the program...

this also didn't work
dconf write /org/gnome-nm-applet/eap/70b2f88f-1c43-45e0-acd5-276f66bd0b98/ignore-phase2-ca-cert false

dconf write /org/gnome-nm-applet/eap/70b2f88f-1c43-45e0-acd5-276f66bd0b98/ignore-ca-cert true

this works for non enterprise wifi devices I guess
nmcli device wifi connect XXX username XXX password XXX

cross cable connection

How to connect two GNU/Linux computers with a cross cable


on box1
sudo ifconfig enp1s0 192.168.0.1 netmask 255.255.255.0 up


on box2
sudo ifconfig enp1s0 192.168.0.2 netmask 255.255.255.0 up

here I'm using enp1s0 as my eth0 interface name, it might just be eth0 on yours. You can check with whatever you get as LAN by the "ip a show" command

This is the cable I got, but any cross cable should do


Saturday, August 19, 2017

downloading torrents in GNU/linux (magnet URIs)

Torrents have changed so much...

Nowadays they're greatly distributed in magnet:XXX-looking URIs.
Check more about that in http://www.vuze.com/about-torrents/magnet-links.
I guess it's better than getting lots of torrent files.

Anyway, to be able to open and use these files, here's my favorite torrent client and how to use it.
It's utorrent!

http://www.utorrent.com/downloads/linux

1. Get the utorrent server (it's a server because you can actually access it from the internet too, or your LAN, but you can just use it on localhost as a normal client).
2. cd to wherever the file "utserver" is, and run "./utserver -settingspath &"
3. login to http://localhost:8080/ (user = admin, blank password by default)
4. click the chain looking icon to add a random torrent URL and you're done.

For non GUI related stuffs I liked aria2c, but it stopped working... lots of data are now being encrypted and everything, kinda going out of the original scope of a bittorrent client, which has some good and bad sides.

Anyway, have fun with utorrent.

Monday, February 11, 2013

Running quakelive on GNU/Linux

After getting a decent video card, the next obvious thing to do is to at least try it with a game...

quakelive.com is a nice one! (lots of actual free games out there to try to though)

I'm using debian, so I'll use iceweasel instead of firefox.

1. run iceweasel
2. go to quakelive.com and register + get the plugin file (QuakeLivePlugin_520.xpi)
3. mkdir -p ~/temp/quakelive; cd ~/temp/quakelive; unzip QuakeLivePlugin_520.xpi; cd ./plugins
4. depeneding on your architecture, copy the file npquakelive.i386.so or npquakelive.x64.so to ~/.mozilla/plugins
5. restart iceweasel
6. go to quakelive.com again, and it'll say plugin OK and start downloading the rest of the game! After that you'll be able to play.


GEFORCE GT610 video card in dell poweredge 840 server

And, trying to ignore reality, the only thing sane to do is to try to think something else real hard. Luckily I have lots of tasks like that.

I installed a GEFORCE GT610 in my new dell poweredge 840 server (I use my server as a desktop computer).
Model name GF-GT610-LP1GH, with 1 GB of video memory, pretty fast, and the best, works with a 32 bit PCI bus! (not pci-express!)
My computer has 1 32bit PCI bus, and two PCI-X (not express, eXtended! which is like a 64 bit PCI bus), so the card fits in any of these (you can put a 32 bit PCI card into a PCI-X one).

Maker page: http://kuroutoshikou.com/modules/display/?iid=1720

Official drivers for GNU/Linux (32 and 64 architecture available): http://www.nvidia.com/Download/index.aspx?lang=en-us

I'd prefer to use free software or at least open source for this kind of thing... apparently there are some options in the repositories (sudo apt-cache search nvidia). Please check those out too, I know I will...

How it goes:
1- Install the card in the server
2- Boot. You'll hear some beeps, and it'll take a lot longer than usual depending on your kernel
3- Depending on your X settings, you'll get no output to the monitor after the POST and maybe the init scripts have run.
4- If you get no output from your monitor (I didn't!), use ssh to login to your computer, run the file you get from the official drivers download page (chmod +x NVIDIA-Linux-x86-310.32.run; ./NVIDIA-Linux-x86-310.32.run)
5- You'll get compiled the kernel modules for the video card and your /etc/X11/xorg.conf settings will be changed ( notes on that below)
6- reboot
7- Cross your fingers and after probably a lot longer than you're used to, you'll see how the init scripts run, and you get your X session looking quite pretty!

Problems:
- the grub menu screen won't show... so right now I can't choose anything but my current default kernel/initrd on startup. This probably won't be so hard to fix
- the server won't halt! (it takes a lot to shutdown!)... yes, I guess the modules aren't working perfectly or something. I guess re-compiling your kernel for multiple displays support would fix it. Or at least trying a new kernel...
- it takes so long to boot! There's a pause between the grub start menu thing, and the actual initrd scripts running. I guess this is due to the kernel as well.

But besides that, it works perfectly!! I can finally see high-resolution videos without having to scale them smaller or dropping frames, and even better, I can finally play on my computer decently! I just tried quakelive without any trouble!


Random information:
computer: dell poweredge 840
OS: Debian GNU/Linux 6.0, kernel: 2.6.26-2
added lines on /etc/X11/xorg.conf:

$ bzr diff xorg.conf|grep +
--- xorg.conf 2013-02-11 07:06:13 +0000
+++ xorg.conf 2013-02-11 07:24:07 +0000
@@ -1,57 +1,54 @@
+# nvidia-xconfig: X configuration file generated by nvidia-xconfig
+# nvidia-xconfig:  version 310.32  (buildmeister@swio-display-x86-rhel47-09)  Mon Jan 14 15:46:49 PST 2013
+
+Section "ServerLayout"
+    Identifier     "Layout0"
+    Screen      0  "Screen0"
+    InputDevice    "Keyboard0" "CoreKeyboard"
+    InputDevice    "Mouse0" "CorePointer"
+EndSection
+
+Section "Files"
+EndSection
+
+Section "InputDevice"
+    # generated from default
+    Identifier     "Mouse0"
+    Driver         "mouse"
+    Option         "Protocol" "auto"
+    Option         "Device" "/dev/psaux"
+    Option         "Emulate3Buttons" "no"
+    Option         "ZAxisMapping" "4 5"
+EndSection
+
+Section "InputDevice"
+    # generated from default
+    Identifier     "Keyboard0"
+    Driver         "kbd"
+EndSection
+
+Section "Monitor"
+    Identifier     "Monitor0"
+    VendorName     "Unknown"
+    ModelName      "Unknown"
+    HorizSync       28.0 - 33.0
+    VertRefresh     43.0 - 72.0
+    Option         "DPMS"
+    Identifier     "Device0"
+    Driver         "nvidia"
+    VendorName     "NVIDIA Corporation"
+    Identifier     "Screen0"
+    Device         "Device0"
+    Monitor        "Monitor0"
+    DefaultDepth    24
+    SubSection     "Display"
+        Depth       24
+    EndSubSection
+


Just a quick update

It stopped working in the upgrade to debian 9. It works perfectly on debian 8. I tried an ubuntu live DVD without success too.
I think X is the reason so maybe you could make it work by keeping the X server in the same version as debian 8. But it was too much of a trouble for me so I just kept it on debian 8.

Pics?

I inserted the card it in the slot_5 (the bottom one)



Tuesday, August 16, 2011

Find files ignoring a directory with the find command

I always forget this usage.
The "prune" option will ignore directories before it, so:

find .   -name dir_to_ignore -prune  -o  -name "*flv" -o -name "*avi"

Will find for every file ending with flv or avi, that is not in the dir_to_ignore directory.

Sunday, August 7, 2011

get/backup a user's tweets by bash

A shell script to download all the tweets of some user to a text file.

Put the contents of this file to a file called get_tweets.sh for example.
Then do "chmod +x get_tweets.sh"
And follow the usage instructions.
#!/bin/bash
#written by rikijpn
#use me like this:
#get_tweets.sh $SOME_USER
#or replace the USERNAME variable for the name of the wanted user
#get_tweets.sh

if [ ! -z $1 ] ;then
    USERNAME=$1
else
    USERNAME=linuxquestions #any default user name you want
fi
URL="http://twitter.com/$USERNAME?page="
FILE_TO_SAVE="tweets.txt"
TEMP_PAGE=`date +%d%m%H%M%S`.txt

printf "\n" > $FILE_TO_SAVE

for PAGE_NUMBER in {1..1000}; do 
    echo "getting page number $PAGE_NUMBER..."
    wget -O $TEMP_PAGE "$URL""$PAGE_NUMBER" 2>/dev/null;
    RELEVANT_LINES_NUMBER=`grep -e 'entry-content' -e 'timestamp' $TEMP_PAGE|wc -l`
    if [ $RELEVANT_LINES_NUMBER -lt 1 ] ; then  break; fi
    grep -e 'entry-content' -e 'timestamp' $TEMP_PAGE |
    sed \
 -e 's,.*<span class="entry-content">,,g' \
 -e 's,</span>,,g' \
 -e 's,.*<span class="published timestamp" data="{time:,,g' \
 -e "s/'//g" \
 -e 's/}">/ --> /g' \
 -e 's/<a.[^>]*>\(.[^<]*\)<\/a>/\1/g' \
 -e 's/^.*<span class="shared-content">/<RETWEET>/g' \
 -e 's/<\/a>/ in local time\n/g' >>$FILE_TO_SAVE
    sleep 5
done

rm $TEMP_PAGE
echo "all pages fetched"
exit 0

It differences "retweets", and outputs the date so you can tell when was it posted.

You can read it at my personal webpage as well.

Sunday, October 3, 2010

installing apk files to your android phone from linux

This was done in the IS01 (a Japanese android). And my debian GNU/Linux machine.



Obviously the first step is to get the application (apk) file.
In this example I'm using "Piano_Play_7.0.apk", a crappy piano application.

In your android:
Go to Settings -> Application Settings, and "check" Unknown Sources.
Then, in Settings -> Applications Settings -> Development, check USB debug.

With this done, all you need to is get the android's SDK (linux doesn't need any extra divers). It's very small, and brings mostly binary (doesn't need to install!!) so it's pretty straight forward.
You'll get a file like: android-sdk_r07-linux_x86.tgz.tar
So put that in some rational directory, untar it
tar xvf android-sdk_r07-linux_x86.tgz.tar
and
cd android-sdk-linux_x86/tools

From this point you'll have to become root
su
adb kill-server #in case you tried without being root
sudo adb start-server
adb install /home/myusername/Piano_Play_7.0.apk
# to install all the apk Apps in /home/myusername for example
#(using bash) for FILE in /home/myusername/*apk ; do ./adb install $FILE ; done
If you mounted your device remember to unmount it first.
And then remove the usb cable, and give your new application a try!