zaterdag 5 november 2011

Changing permissions for your files.

I'm messing around with my Ubuntu server once again. I'm trying to get Wakaba running. Wakaba has a lot of Perl scripts that need to the permissions to be set at 755. Here's how you do that.
$ ls |grep .pl > setpermis.txt
$ sudo chmod 755 $(>setpermis.txt)
First we put all the filenames of the files that we'd like to set their permissions into a file named 'setpermis.txt'. And after that we ask chmod to use that file to set all the permissions.

donderdag 9 juni 2011

LowerCase your links with JQuery

A friend recently asked me and some other friends in a chatroom to come up with a way to set href attribute values of all the links to lower-case. Don't really know why he needed it exactly but anyway, here is the solution I came up with.

Put a JavaScript on the webpage with this code
$(document).ready(function(){
//read in the document, this is important

$("a").each(function(index){
//now for each link, take the href make it //lowercase and put it back
$(this).attr('href', ($(this).attr('href').toLowerCase()));


});

});
The big downside here is that it depends on JQuery, you'll have to import a JQuery on that page to. So while this is a really quick fix, this took me like 5 minutes to come up with type in and put on-line, importing the whole JQuery library for this lousy toLowerCase() function isn't really that elegant.

In the end, it'll probably all be done by some Perl script that goes through all the pages and fixes all the html all at once.

donderdag 12 mei 2011

Shows the cpu type:
$ uname -m
Show cpu information:
$ cat /proc/cpuinfo

zondag 6 maart 2011

sFTP and some usefull commands regarding navigation

sFTP stands for secure file transfer protocol. If you are using openSSH you already have sFTP and you can use it in the same port as you are using SSH.

the command:$ ls is handy to determine what is in your current directory. To make it human readable however you might want to use $ ls -h. Lets add a little more detail $ ls -lh and to spice it up even a little more we would like to see our 'hidden' files $ ls -lha. Hidden files are file names that start with '.' (example '.bash_history').

And as we remember from the first lesson, directories are files to[1]. You can also hide directories with this.

something else I used a lot before but I just now fully realised how it actually worked it cat. cat is used to print a text to the prompt this is very useful if you'd like to see some info file like $ cat /proc/cpuinfo

[1]Directories are basically lists of files subdirectories and their location on the hard drive.

zaterdag 5 maart 2011

Working with Byobu

Byobu lets you have multiple virtual terminals which you can switch between. It also gives you some information about your pc like the current load, updates waiting to be installed, ram ect.
Byobu from Putty requires to have Terminal >Change sequence send by: >function keys: Set To VT100+. This will enable you to use F1, F2, F3 and F4. F5 to F6 won't work.
F2 to Create a new window
F3 got to prev window
F4 go to next window
'screen -r' reattach
<ctrl-A> then K → to kill a window

F5 Reload profile
F6 Detach from session
F7 Scrollbakc and search
F8 Rename a window
F9 Configuration
F12 Lock this terminal

Installing openSSH

Install openssh-server
sudo aptitude openssh-server
Okay installation was easy, now the configuration.
nano /etc/ssh/sshd_config
But before we do that we might want to take a backup of that.
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
After editing the /etc/ssh/sshd_config file you'll have to restart the server to let the changes have an effect. sudo /etc/init.d/ssh restart

Our ISP blocks port 22 so we'll set that to port 5022 in the /etc/ssh/sshd_config. We forward router port 5022 TCP and setup a free dns from dyndns.org. We use the
sudo /etc/init.d/ssh restart
and there we go. SSH is set-up.

maandag 14 februari 2011

C++ on Ubuntu server

How to compile C++ code on Ubuntu.[1] First, let's start a new text file.

name@computer:~$ nano
#include <iostream>
using namespace std;
int main()
{
cout << "hello world!\n"; return 0; }

I won't go into detail what the commands exactly stand for. You can read them in a tutorial that I linked to before.

Now and save your file as HelloWorld.cpp, and exit. In nano this is ctrl+x. Now we are going to do the compiling.(Finally, the very essence of this post.)

name@computer:~$ g++ HelloWorld.cpp -o HelloWorld

Let's run it to see if it works.

name@computer:~$ ./HelloWorld
hello world!
name@computer:~$

[1] g++ package needs to be installed. See a previous post.

vrijdag 11 februari 2011

Starting to learn C++

I decided to learn some C++, nothing advanced or anything just the basics. First I had to install a Compiler.

I choose Dev-C++.
Download Page
Actual download link

So now I have a compiler, what's next?
What about a good tutorial, preferably in pdf format.
aha, this looks like a good one.
That's that, I can start learning C++. If you happen to know some more advanced tutorials that can be useful when I'm done with this one, please let me know in the comments (you can post anonymously, so make use of that).

edit: If you are going to use the tutorial I linked to in this article you might want to put system("pause"); inside your code when copying the code examples from the tutorial. system("pause"); will make sure you'll be able to see the output of your code. Not using this line will just have the terminal give a quick flash. This is because as soon as the main() function has come to an end, the program will close itself (and a 4 line program comes to an end so fast it's practically invisible).

dinsdag 8 februari 2011

Installing ufw

Okay I have to install ufw. A friend advised me to do so so I could manage some network stuff in the future.

First lets see whether we don't have it already.
~$ dpkg -s ufw
Package: ufw
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 804
Maintainer: Jamie Strandboge
Architecture: all
Version: 0.30.0-1ubuntu2
Depends: debconf, python (<< 2.7), python (>= 2.6), python-central (>= 0.6.11), debconf (>= 0.5) | debconf-2.0, upstart-job, iptables, ucf
Suggests: rsyslog
Conffiles:
/etc/default/ufw a5a50fd948d40f328e8c1b66d09ca984
/etc/rsyslog.d/20-ufw.conf 322b0e04163744367d1cba9608891bfe
/etc/bash_completion.d/ufw 50de7ccdcddb779093156f133d9c0a5e
/etc/ufw/sysctl.conf 887c00ab9cf13f6944abe88d424c9d08
/etc/init/ufw.conf b85f80257c81675ef38e9db139fb0921
/etc/logrotate.d/ufw 8a9b5120d86b4e59d7e43adaa7b9501c
Description: program for managing a Netfilter firewall
The Uncomplicated FireWall is a front-end for iptables, to make managing a
Netfilter firewall easier. It provides a command line interface with syntax
similar to OpenBSD's Packet Filter. It is particularly well-suited as a
host-based firewall.
Homepage: https://launchpad.net/ufw
Python-Version: 2.6

oh, So apparently I already have it installed.
:-)
Here is a link with some more information about ufw:
UFW Ubuntu help

donderdag 3 februari 2011

Installing g++

G++ is a compiler for C++. I wanted to install this because I wanted to learn the basics of C++ and so I need a compiler to compile my "Hello World" program.

Installing G++ can be a pain in the ass though. I've found this out on several forum after failing to do it on my own. Several people advised to install the package 'build-essentials' because it included G++ and didn't give problems installing. I didn't want to install 'build-essentials' though so I kept on looking for a solution.

Eventually I found out that
$sudo aptitude update && sudo aptitude install g++
worked for me. So apparently I just had to update to make it work.

And another useful command is:
$dpkg -s
this will tell you whether your package is installed.

dinsdag 25 januari 2011

Installing The QuasselCore

First things first. On one hand I don't really have time to post stuff here but if I'm going to wait till my exams are over, I probably will have forgotten everything I learned and did on my Linux server. So here, just to keep this blog alive (, more like in a coma). A very short post on how I installed the Quasselcore on my server.


It was basically as simple as this.
$ sudo aptitude install quassel-core
After this I'd just have to connect with the Quassel client from my laptop. There I make my first account and configure everything with the GUI. I had a little trouble finding how to add a new user since:
$ sudo quasselcore --add-user 
Later I found out, that because I use a debian derived distro (Ubuntu) that I'd have to use:
$ sudo quasselcore --configdir=/var/cache/quassel --add-user 

update:
since ubuntu 11.04 and up you need to use (http://bugs.quassel-irc.org/projects/1/wiki/Manage_core_users)
$ sudo -u quasselcore quasselcore --configdir=/var/lib/quassel --add-user


Yes it's as easy as that.
Quassel.