Wednesday, March 28, 2012

Scrambling/Unsorting a file in Linux

Hi guys,

No doubt, linux terminal is a important tool for programmers. Its simply beautiful. We always sometimes need to sort a file (linux sort is here) and sometimes we need to find the number of lines in a file whereby we uses the wc command. However, today my task was a bit different.

We had a a file containg a list of numbers and we had to scramble the file random such that all the lines gets to new location with the file randomly. To do this, there is two commads

1. unsort
2. shuf

I don't know if the unsort commad is install on your pc. If not then simply do and "apt-get intall unsort" or "yum install sort".

1. unsort
To be frank, I'm not a great fan of the commands of unsort even if i used shuf command only few times. i may be wrong, but what I notices with unsort is that it breaks the list into portions and then try to perforn a shuffle within that portion. Even though, to unsort a file, simply

unsort <inputfile>



2. shuf

if you want to fully understand how to use shuf, do a "man shuf" to see the manual for shuf. I'll simply demonstrate a simply example

shuf <inputfile> -o <outputfile>, here shuf will take the input file, shuffle it using the default random and output the file
 
 shuf  --random-source=/dev/urandom  <inputfile> -o <outputfile>, here the same operation will be performed except that the random numbers are from /dev/urandom from linux

Monday, March 26, 2012

Merging Folders in Linux For backup Purposes

Hi guys,

So, I am in serious need to completely destroy my current linux OS :(, but fooooo, I've loads of files that I need. What i did in the past was to set up a server at home and synchronize my files there. The folder where my backup are kept are always ordered in sub directories.

for e.g. in the back, u have the following folders:

  1. Books 
  2. Videos
  3. Programs
When you will synchronize from your newly OS with that file from the server, the content of your files will be in the same style as the server and will also contain all the files. Now, on your new linux, make sure that you are well organized so that the next time, you can push these changes to your server and have a up-to-date copy of your backup. Always try to categorize files well, else u'll suffer ;)

so, lets say we have a file backup on the server, and you want to have the content of backup from the server on your files, so simply use scp

scp -rv /home/<username>/file <username>@<host>:/home/<username>/backup

Now you'll have the files on your new linux

Now, lets say that in the future, you have to merge the files on your linux with that of the server to get an updated one, simply use rsync

rsync -avPr /home/<username>/file/  <username>@<host>:/home/<username>/backup

hey, I'm newbie so if ever there are errors, then do inform me, thanks!!

Saturday, February 18, 2012

logging into another linux

Hi guys,

I'm sure many of you sometimes really want to login into another laptop via yours, I recently learn it and thus hopes sharing it with you,

Its really simple,

1. First, ensure u have ssh on both linux OS

2. Then simply do type that on terminal

              ssh <username>@<domainName|ipAddress>

then simply enter u're password and everything is alright!!

Connecting to another PC without having to enter password everytime

Hi guys, 

I'm sure that like several times you have to connect to server and its really very boring to everytime having to enter the password. So the basic concept is to use a to generate a pair of public and private keys and then push your public key to the server and have your private key on your pc!!

This technique the Public/Private Key Cryptography System and send request to and back. So here how we do it:

On Your Pc
=========
1. cd to your home directory

2. ls .ssh/

3. Generate the key pairs
   ssh-keygen 

4. Copy the public key to the server
    scp .ssh/id_rsa.pub youUsername@server.com:
 

on server
========
Login on your server and do the following

1. ls .ssh/

2. cat id_rsa.pub >> .ssh/authorized_keys 

3. rm id_rsa.pub 

Hope it works, if it doesn't do leave a comment and explain the problem, remember i'm still a linux newbie 

Installing VLC on Cent OS 6.2



Hi guys,

believe me Cent OS 6.2 is really one among the best distro on the market on don't lose time and rush to it. But lol, I've got a crazy time to install VLC on it. Herez how I did it:

1. Lauch terminal and become Root,

2. rpm –rebuilddb

3. yum clean all

4. yum install vlc

Hopefully, this will install VLC on your Cent OS 6.2 

Sunday, November 6, 2011

I'm fighting to install drop box on my Ubuntu 10.04. Finally I successfully installed it :-) using the following guidelines

1. First, download and install it

Ubuntu x86 (8.04-10.04): https://www.dropbox.com/download?dl=packages/nautilus-dropbox_0.6.2_i386.deb
Ubuntu x86_64 (8.04-10.04): https://www.dropbox.com/download?dl=packages/nautilus-dropbox_0.6.2_amd64.deb
Fedora x86 (9-12): https://www.dropbox.com/download?dl=packages/nautilus-dropbox-0.6.2-1.fedora.i386.rpm
Fedora x86_64 (9-12): https://www.dropbox.com/download?dl=packages/nautilus-dropbox-0.6.2-1.fedora.x86_64.rpm
Source: https://www.dropbox.com/download?dl=packages/nautilus-dropbox-0.6.2.tar.bz2

2. Then,

if you are using Ubuntu, we'll update u're repos

2.1 apt-get update;
2.2 apt-get upgrade nautilus-dropbox.
2.3 Get the public key: sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E

if you are usinf redora
1. Create a file in /etc/yum.repos.d called dropbox.repo with this text:
[Dropbox]
name=Dropbox Repository
baseurl=http://linux.dropbox.com/fedora/$releasever/
gpgkey=http://linux.dropbox.com/fedora/rpm-public-key.asc
2. run yum install nautilus-dropbox (as root) It may ask you to confirm a gpg key, say yes and you'll be good to go.