jueves, 29 de enero de 2015

connect to an Access Point from command line

I am setting up a laptop with Debian with no-gui just for lab purposes that's why I need to connect it to the AP I have, from command line you may accomplish this task through these ones:

1.  sudo iwlist scan  //you will AP available, event the hidden ones

2. sudo iwconfig essid "AP name" // in my case:
   sudo iwconfig wlan0 essid "atenas"

3. sudo iwconfig wlan0 key s: 

4. get a IP from the dhcp:
  sudo dhclient wlan0

those steps worked for me, I read in several sites whether the AP has WPA2 passphare you should use the wpa_supplicant method, it may be true, but in my case it was not necessary, just check it in case some of the above steps do not work

Best

monitoring your physical resources on Ubuntu

Since I am working with a really heavy DBMS and IDE for a project, I start to ask me about my physical resources, RAM and Processor specifically, once I got a message from that DBMS that I had only 200 MB of RAM available and that was because that monster load a lot of subprocess -It's a Windows based DBMS, there are a lot of options better, but you know, the client always is right.

So, to monitor the resources you may use:

1. from command line: egrep --color 'Mem|Cache|Swap' /proc/meminfo

2. Use a really cool tool: gnome-system-monitor, you get a great graphs about used/free resources, really useful


jailing users with our FTP Server


I know FTP Server is still insecure for several reasons, I know there are better alternatives such as sftp, ssh or at least use ftp with SSL support, but we all know many users come from the dark side (win$$$... ) so maybe this post may be useful specially to them, in case you are running a FTP Server, it would be great restrict access just to the /home directory, in order to accomplish it these steps should be enough:

0. Create a directory for the "alienuser", it would be great in www directory in case you're at work and some consultant needs to upload something:
    sudo mkdir /var/www/alienuserdir

1. change owner group to that directory:
    sudo chown root.ftp /var/www/alienuserdir

2. addjust permission to the directory:
    sudo chmod 770 -R /var/www/alienuserdir

3. it would be great to do a ls -l to alienuserdir so you may check your changes
 
4. Create user's account from terminal:
   sudo adduser alienuser   //I like to user perl script adduser, save us a lot of time unlike useradd

5. Change the alienuser's home directory:
   sudo usermod --home /var/www/alienuserdir alienuser

6. Add alienuser to ftp group:
    sudo usermod -G ftp alienuser

7.  open the conf file of vsftpd:
     sudo nano /etc/vsftpd.conf

8. uncomment/add/change the next lines:
   anonymous_enable=NO
  local_enable=YES
  write_enable=YES
  chroot_local_user=YES
  local_root=/var/www/alienuserdir

9. save it and restart the service:
    sudo service vsftpd restart

10. that's all, now you may try using your favorite ftp client such as filezilla entering the host name, user(alienuser) and the password, it would be great whether you try to upload/download something as well

All the best



jueves, 22 de enero de 2015

set environment variables in Ubuntu

This trick is useful, specially if you're using software outside of the repos, some of them need to set custom environment variables, in order to accomplish that you may follow these steps:

1. open a terminal
2. type: sudo nano /etc/profile.d/newvars.sh
3. adjust your vars like this: export MYVAR=/target/directory ; save it
4. give execute permissions like: sudo chmod 755 /etc/profile.d/newvars.sh
5. logout and login again

cool

so check it like this:
1. printev | grep MYVAR
 you should see an output with the MYVAR's value

that's all

jueves, 15 de enero de 2015

disable media scanner service in ubuntu

Since I upgraded to Ubuntu 14.10 everytime I plug an USB device I got a message "device is busy" specially whether the devices has a lot of media files and must of the times this is annoying. So, in order to disable this just do these steps:

1. open a terminal
2. from your /home directory just type: echo manual >> ~/.config/upstart/mediascanner-2.0.override
3. login again in order to update your profile

Whether you have several user accounts you should use this line instead:
sudo sh -c "echo manual >> /usr/share/upstart/sessions/mediascanner-2.0.conf"

that's it, try this time to plug/unplug your usb device and you'll see the difference.

Another approach would be to purge mediascanner but I read ubuntu-sdk uses mediascanner in several operations, in case you're developing for ubuntu touch for example, purge it would not be a good idea.

All the best

martes, 13 de enero de 2015

export a VirtualBox appliance from command line

This trick might be useful, I did an Ubuntu update and it did not works for my system, so I'm rescuing many things, one of them are Virtual Machines from VirtualBox, so from command line the steps are:

1. vboxmanage list vms
  You will get the list of all your Vm's

2.  vboxmanage export -o .ova
Export the appliance to a single file, I tried this directly to an removable USB Hard Drive and it worked

3. Go to the target system and use this command:
    vboxmanage import .ova  or use the VirtualBox's graphical interface to import it

and that's it, the import process may delay, it depends of the size of the appliance.

Cheers

viernes, 9 de enero de 2015

random password commands in Linux

This is an alternative to generate random password, in general you may use this whether:

1. you use the same password for all your accounts (that's not a good idea)
2. you are a programmer and in you need a random password generator for sign-up process

in those cases, you may use this commands:

1. makepasswd, it uses /dev/urandom to generate them, here the first steps to use it:

  -sudo apt-get install makepasswd
  -makepasswd --chars 16  -> generate password with a length of 16 characters, you may change it.
   -makepasswrd --chars 16 --count 5 -> it will generate a list of five different passwords


2. pwgen: generate readable passwords ( use your imagination, many of them seems unreadable for me)

  -sudo apt-get install pwgen
  -pwgen 16 2  -> it will generate 2 passwords with 16 chars of length.

That's all, whether you're interest to explore more parameters for these commands, please use man

Cheers