Freitag, 28. August 2015

Running tasks in command background

When you're connected to a server via. ssh, you might have trouble running processes asynchronous. Following i wan't to show a few commands, which allow you to pause a process, move it to background, continue the process in back or foreground and let it even continue, when the shell closes.

All commands listed below:
  • jobs - shows all current processes.
  • bg %jobid - continue job in background.
  • fg %jobid - bring background process into foreground.
  • ctrl+z - in terminal shown as ^Z; pauses current process and moves it to background.
  • disown %jobid - removes the process from table of active processes. 
First of all i show you how to start a process in background. It runs until it needs input from command line. To do so, you might type cp extremelargefile ../ &.

[1]  + suspended (tty input)  cp extremelargefile ../ &.

When the process suspended and you wan't to continue it in foreground, on terminal, you might type fg %jobid. To figure out the jobid you might type jobs. All current gets listed then.

A process is running, e.g. cp. There might be a situation that you copy a large file and forgot to add & to the command. So you're running the process in foreground. To suspend the process and bring it to background you might press ctrl+z. When you wan't the process to ran further, type bg %jobid. As already told, you can bring this process back to the front by typing fg %jobid.

For example:
> cp extremelargefile ../
^Z
zsh: suspended  cp extermelargefile ../
> jobs
[1]  - suspended (tty output)  cp extremelargefile ../
> bg %1
[1]  - continued (tty output)  cp extremelargefile ../
> fg %1
[1]  + continued (tty output)  cp extremelargefile ../

Donnerstag, 27. August 2015

Block websites with /etc/hosts

What's /etc/hosts for?
Every UNIX-like OS has a file for resolving hostnames to IP. You can block specific hostnames by directing them to your localhost IP, which is 127.0.0.1. Usually i block a few sites i visit regulary, which are distracting me to study. In following an example is listed.

# Address       Hostname
127.0.0.1       localhost
127.0.0.1       localhost.localdomain
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1       local

127.0.0.1       9gag.com
127.0.0.1       facebook.com
127.0.0.1       facebook.de
The first line, beginning with the hashtag is a comment.

What about windows?
In windows 7 there was a similar file under C:\\system32\drivers\etc\hosts. There should be a similar file, in newer Microsoft operating systems. http://bfy.tw/1Vce

HAW Hamburg VPN under Linux

Since CISCOs AnyConnect VPN doesn't support Linux, we need to use an open source implementation. I suggest to use openconnect.

Under Arch Linux you might download it via. pacman -S openconnect. After you downloaded it, you might connect with sudo openconnect <address>;. The programm will ask you for your A-Label and your password. These are the same credentials you use for your helios and e-mail access on haw-mailer.haw-hamburg.de/owa.

Here is an example how it looks like:
sudo openconnect connect.haw-hamburg.de
[sudo] password for user: 
POST https://connect.haw-hamburg.de/
Attempting to connect to server 141.22.5.20:443
SSL negotiation with connect.haw-hamburg.de
Connected to HTTPS on connect.haw-hamburg.de
XML POST enabled
Please enter your username and password.
Username:a-label
Password:
POST https://connect.haw-hamburg.de/
Got CONNECT response: HTTP:/1.1 200 OK
CSTP connected. DPD 30, Keepalive 20
Connected tun0 as 141.22.197.180, using SSL
Established DTLS connection (using GnuTLS).

Useful Links: