Pages

Tuesday, August 30, 2011

Spliting 1 large MKV file into 2 smaller MKV files


Lets say you have a 6GB MKV file that you want to split into 2 X 3GB MKV files

mkvtoolnix to the rescue

install mkvtoolnix

yum install mkvtoolnix

once installed cd into the directory that has the file you want to split
lets say the file is called thor.mkv
to split it into 2 files of 3GB each simply type the following.

mkvmerge --split size 3g thor.mkv -o thor1.mkv
hit enter

you will land up with 2 extra files thor1.mkv and thor2.mkv, each 3gb in size (the original file will also still be in the directory


Tuesday, June 7, 2011

Rsync


Backing up data using rsync command

I have stopped using scp to copy files from computer to computer and far prefer to use rsync.
rsync command uses the same format as scp, (so there is no learning curve and if you are used to using scp, then switching to rsync is no trouble at all) rsync has the benefit of being able to continue from a failed copy, and also has a wealth of other advantages over scp.

rsync is a great tool for backing up and restoring files.

Example of the remote server and folder that needs to be backup or copied:
Remote host name: server.example.com
Remote folder: /home/serverfolder/
Remote user: user1


rsync -arv user1@serverexample.com:/home/serverfolder/ /home/cgerada

(/home/cgerada is the local folder path of the machine I am on and to were I want to copy to)
or to copy into the directory that I am currently in you could type
rsync -arv user1@serverexample.com:/home/serverfolder/ .

Here is what the "-arv" option does:
a = archive - means it preserves permissions (owners, groups), times, symbolic links, and devices.
r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied
add --progress at the end of the command to get a running tally of what's going on
eg
rsync -avr * /media/usb/ --progress

another good example

rsync -avr --progress --delete --log-file=/var/log/$(date +%Y%m%d)_rsync.log user1@serverexample.com:/home/folder/ /home/folder/

will create a log file and document the progress into the logfile
-- delete will delete on the destination server what ever files have been deleted from the source  (it wont delete files on your source server, only destination)


Excluding files


rsync -avr --exclude '*.iso' source/ destination/


Will Exclude all iso files


or you can write it like this , it doesn't matter, it still works
rsync -avr source/ destination/ --exclude '*.iso' --progress 




Thursday, December 2, 2010

Output your microphone to a remote computer’s speaker

dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

This will output the sound from your microphone port to the ssh target computer’s speaker port. The sound quality is bad, so you will hear a lot of hissing,
but it works.

Email alert on Root Login

This will allow you to be notified instantly via email whenever someone logs into your server as root.

ssh into your server

su to root

sudo -i

or su -

cd to /root

cd /root

edit your .bashrc file

vim .bashrc

add the following to the end of the file

echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

Replace YourServerName with the name of your server.

Replace you@yourdomain.com with the email address you want the alerts sent to.

:x to save and exit

logout from your server, close the connection and log back in.

You will receive an email alert of the root login after a few minutes.

Saturday, November 27, 2010

Mutt Tips

searching in mutt

* ~f brucewayne :From: matches "brucewayne"
* ~s party : messages with subject containing "party"
* ~d <2w : messages less than two weeks old. Also: year, month, week, day.
* ~t clarkk : To: matches clarkk (useful for sent-mail folders)
* ~O : old (i.e. unread but not new) messages.
~N is new unread.
~U is unread, i.e. both together.
* ~p : messages addressed to you (useful if your inbox is bombarded with mailing list or system report activity).
* ~p ~U : for messages to you you haven't read yet.
* . : matches everything. In effect, remove the limit.


l limit messages matching
l all show all messages
:set sort=from sort messages by "From"
:set sort=threads sort messages by "Thread"
:set sort=date sort messages by "Date"


mailbox "=cgerada" will show alerts in cgerada mailbox

Friday, November 26, 2010

Bash Cheat Sheet

 !! - Last command (usefull if you forget to run a command as sudo)
 sudo !!  (runs last command as sudo)
 !foo - Run most recent command starting with 'foo...' (ex. !ps, !mysqladmin)
 !foo:p - Print command that !foo would run, and add it as the latest to
 command history
 !$ - Last 'word' of last command ('/path/to/file' in the command 'ls -lAFh
 /path/to/file', '-uroot' in 'mysql -uroot')
 !$:p - Print word that !$ would substitute
 !* - All but first word of last command ('-lAFh /path/to/file' in the command
 'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
 !*:p - Print words that !* would substitute

 ^foo^bar - Replace 'foo' in last command with 'bar', print the result, then
 run. ('mysqladmni -uroot', run '^ni^in', results in 'mysqladmin -uroot')

 {a,b,c} passes words to the command, substituting a, b, and c sequentially
 (`cp file{,.bk}` runs `cp file file.bk`)

 Ctrl + a - Jump to the start of the line
 Ctrl + b - Move back a char
 Ctrl + c - Terminate the command
 Ctrl + d - Delete from under the cursor
 Ctrl + e - Jump to the end of the line
 Ctrl + f - Move forward a char
 Ctrl + k - Delete to EOL
 Ctrl + l - Clear the screen
 Ctrl + r - Search the history backwards
 Ctrl + R - Search the history backwards with multi occurrence
 Ctrl + t - Transpose the current char with the previous
 Ctrl + u - Delete backward from cursor
 Ctrl + w - Delete backward a word
 Ctrl + xx - Move between EOL and current cursor position
 Ctrl + x @ - Show possible hostname completions
 Ctrl + z - Suspend/ Stop the command
 Ctrl + x; Ctrl + e - Edit line into your favorite editor

 Alt + < - Move to the first line in the history  Alt + > - Move to the last line in the history
 Alt + ? - Show current completion list
 Alt + * - Insert all possible completions
 Alt + / - Attempt to complete filename
 Alt + . - Yank last argument to previous command
 Alt + b - Move backward
 Alt + c - Capitalize the word
 Alt + d - Delete word
 Alt + f - Move forward
 Alt + l - Make word lowercase
 Alt + n - Search the history forwards non-incremental
 Alt + p - Search the history backwards non-incremental
 Alt + r - Recall command
 Alt + t - Transpose the current word with the previous
 Alt + u - Make word uppercase
 Alt + back-space - Delete backward from cursor

 (Here "2T" means Press TAB twice)
 $ 2T - All available commands(common)
 $ (string)2T - All available commands starting with (string)
 $ /2T - Entire directory structure including Hidden one
 $ (dir)2T - Only Sub Dirs inside (dir) including Hidden one
 $ *2T - Only Sub Dirs inside without Hidden one
 $ ~2T - All Present Users on system from "/etc/passwd"
 $ $2T - All Sys variables
 $ @2T - Entries from "/etc/hosts"
 $ =2T - Output like ls or dir
 .bash_profile = sourced by login shell,
 .bashrc = sourced by all shells,
 .bash_aliases = should be sourced by .bashrc

Run something:
 for i in a b c; do $i 'hello'; done

Do something on a bunch of files:
 for i in *.rb; do echo $i; done

If syntax:
 if [ -e .ssh ]; then echo "hi"; fi

file check flags:
 -e:  file exists
 -f:  regular file (non directory)
 -d:  directory
 -s:  non-zero file
 -x:  execute permission

Avoid duplicates in your history:
 export HISTIGNORE="&:ls:ls *:[bf]g:exit"

Wednesday, November 10, 2010

SMBCLIENT

smbclient -L servername
will show you all available samba / windows shares

To connect to a windows or samba share type

smbclient \\\\servername\\share -U username

you will be asked for your windows password for the username specified

once connected smbclient works like an FTP client

type help for a list of commands.

Keep in mind, you'll need a leading "\" before spaces (ex: My\ Filename.txt).

or alternatively put your filenames in quotes eg "My Filename.txt"

once connected
to copy directories and subdirectories type
recurse

to not be asked (prompted)if you want to replace files. type
prompt

Example:
smbclient '\\server\share'
    mask ""
    recurse ON
    prompt OFF
    cd 'path\to\remote\dir'
    lcd '~/path/to/download/to/'

    mget *

or, all on one line,


smbclient '\\server\share' -N -c 'prompt OFF;recurse ON;cd 'path\to\directory\';lcd '~/path/to/download/to/';mget *'

Wednesday, November 3, 2010

Setting UP VNC server on a CentOs or Redhat server


To set up VNC properly, so that you have access to the local
default X console of your server as if you are sitting in front
of the physical server.
follow these steps.

On the server, type vncpasswd as root to set a VNC password.
You will use this password when connecting with vncviewer

Edit the file /etc/X11/xorg.conf

In the stanza called Screen, add this line:
Option "passwordFile" "/root/.vnc/passwd"

then
add in the following lines at the end of the file:

Section "Module"
Load "glx"
Load "dbe"

Load "extmod"

Load "freetype"

Load "type1"

Load "dri"
Load "vnc"
EndSection

save the file

Allow the ports in the iptables Firewall
by typing the following:

system-config-securitylevel

In the "Other ports", add the following range.

5900-5904

Save and close the tool then restart the firewall by typing the following:
service iptables restart or /etc/init.d/iptables restart

type

chkconfig vncserver on

to have vncserver automatically start when the server next boots up.

Then finally RESTART the server.




Friday, October 29, 2010

recovering from a read only / mount

When the boot process aborts upon failing to find a removed or failed hard disk due to the system not finding the device that your /etc/fstab file references , it asks for a password and gives you the option to drop into maintenance mode , however when in maintenance mode you are unable to edit your /etc/fstab file to fix the problem since your / partition is mounted Read only!

to fix the situation simply type

mount -n -o remount /
will remount the / partition in rw mode and you can now edit /etc/fstab and remove the
line with the faulty disk or wrong entry, and then reboot as normal.

Sunday, August 22, 2010

Encrypt a file whilst in Vim


Encrypt File in Vim
Save and encrypt the current file:
:X
Enter encryption key: ********
Enter same key again: ********
Once you’ve encrypted a file using :X, the next time you open that file, Vim
will prompt for the encryption key.

Tuesday, May 25, 2010

How to Upgrade from Fedora 12 to Fedora 13 (32 bit and 64 bit versions)


Do the following as root.

download latest fedora repos

For 32 bit version type:

wget ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/i386/os/Packages/fedora-release-13-1.noarch.rpm

or for 64 bit version type:

wget ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/x86_64/os/Packages/fedora-release-13-1.noarch.rpm

import gpg-key

rpm --import ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/i386/os/RPM-GPG-KEY-fedora-i386

or for 64 bit version type:

rpm --import ftp://download.fedora.redhat.com/pub/fedora/linux/releases/13/Everything/x86_64/os/RPM-GPG-KEY-fedora-i386

install rpmlibs dependency. Required to install fedora-release-13

yum install rpm-libs -y

upgrade fedora release

rpm -Uvh fedora-release-13-1.noarch.rpm

upgrade fedora distro

yum upgrade -y

Reboot and Enjoy

Tuesday, January 12, 2010

Compose Key


I often need to type characters that aren’t on the keyboard, like € ½ ÷ © ¥ or ¢.

compose key to the rescue.

pick a key on your keyboard you don’t use much, like [Insert], [CapsLock], or [menu], and make it the “compose key”.

Then to make any character, you just hit the compose key, then type the two obvious keys that, when combined, make up the character.

For example:

* To get €, just type e then =

* To get ©, just type o then c

* To get ® just type o then r

* To get £, just type L then -

* To get ¥, just type Y then =

* ¢ is c then |

* ÷ is - then :

* ½ is 1 then 2

* ¼ is 1 then 4

* ñ is n then ~

By default this function is not assigned to any key. You can tell the X server what key to use for this function with the following command
setxkbmap -option compose:keyname

for example

setxkbmap -option compose:caps

to assign it to the caps-lock key.

or setxkbmap -option compose:rwin

to assign your right "Windows" key
to make it persisistent after a reboot simply insert the command in your
/etc/rc.local file

Wednesday, December 30, 2009

Loads of Linux GAMES



djl is an open-source game manager for Linux, written in Python

download the installer script from http://en.djl-linux.org/?q=node/19
Once you download the file you will need to extract it.
tar -xzvf djl-1.2.20.tar.gz

The djl.sh contained inside the archive needs to be executable in order to run, so you may have to make it executable by typing the following.
chmod +x djl.sh

then to run the script, type ./djl.sh

When you run the script the first time, if you do not have the Python framework installed, you'll get an error. Fortunately The script will point out the missing python-qt4 libraries. Fire up your package manager and install it. Alternatively, use the command line to install the package.
yum install "package name" or apt-get install "package name"

Once you have everything in place, run the application. You will be asked to configure djl. This includes configuring the installation directory for your games, the Web browser of your choice, the default tab in the main menu, the font size, updates, dependencies, and more. Very convenient.

After you download the News items, you're ready to roll.


Go to Repository tab and start enjoying this powerful game manager. You can search the games by genre, or by additional categories, like license or price.

Games are just as easy to un-install as they are to install

Enjoy

Friday, November 6, 2009

Setting up a DHCP server

assuming the Network you want to add a DHCP server to is the

192.168.1.0/24 network

your router IP Address is 192.168.1.1

Your ISP's DNS servers IP Address is 194.158.2.2

the leases that you want to give out are 192.168.1.128 to 192.168.1.254

first install the DHCP server software.

yum install dhcp.i386

once installed

edit /etc/dhcpd.conf (if it doesn't exist create it)

vi /etc/dhcpd.conf

add in the following lines

ddns-update-style interim;
ignore client-updates;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.128 192.168.1.254;

default-lease-time 21600;
max-lease-time 43200;
option routers 192.168.1.1;
option ip-forwarding off;
option domain-name-servers 194.158.2.2;
option broadcast-address 192.168.1.255;
option subnet-mask 255.255.255.0;

save the file :wq

next, configure the dhcpd service to start at start up

chkconfig dhcpd on

to make sure it is running either reboot or type
/etc/init.d/dhcpd start

that's it , your done. Your DHCP server will give out IP addresses to any clients that connect to your network.
there are many other options that you can add to your DHCP server, like reserving an IP address for a specific mac-address etc

to see all of these option just check out the man pages of dhcpd
type
man dhcpd

Thursday, November 5, 2009

Source .bashrc when you connect over SSH

If your .bashrc file is not being sourced when you connect to your system over SSH and it only gets sourced when you open up a terminal locally on the system.

you may need to add the following to your etc/profile file

if [ -e ~/.bashrc ]; then
. ~/.bashrc
fi

Tuesday, November 3, 2009

VMWare boot from CD


VMWare can be very frustrating when you try and boot a VM from a CD .

The VM’s BIOS is set to boot from disk first, so you need to change the boot device order. The problem is that the boot process is so fast that you never have enough time to hit the F2 key and enter the bios setup to change the boot order of your VM.
A solution to the problem is to edit the .vmx file in your VM's directory and simply add the following line.

bios.bootDelay = “boot delay in milliseconds”

for example if you want to give yourself 20 seconds add the following line
bios.bootDelay = “20000”

save the file and then restart your Virtual machine.
You will now have enough time to enter into the VM's console and hit the F2 key so that you can edit the boot order in the Bios.

Wednesday, October 28, 2009

Right Click Open Terminal in current folder



nautilus-open-terminal runs on Gnome Windows manager and it allows you to right click in your file manager
and open up your terminal in the current folder. Clearly a very useful tool.

It used to be installed as a default application in many distributions but for some reason it was left out of Fedora 11




To add it back in simply type
sudo yum install nautilus-open-terminal

If it somehow got left out of your Ubuntu installation, then type
sudo apt-get install nautilus-open-terminal

You will need to restart your Gnome session to activate it.

Friday, October 23, 2009

How to Install Google Chrome on Ubuntu


edit the /etc/apt/sources.list file

sudo vim /etc/apt/sources.list

Add one of the following

For ubuntu 9.10 (armic) add the following two lines

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main

For ubuntu 9.04 (Jaunty) add the following two lines

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main

For ubuntu 8.10 (Intrepid) add the following two lines

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main

Save the file

Next add the GPG key by typing:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xfbef0d696de1c72ba5a835fe5a9bf3bb4e5e17b5

Update the source list. by typing

sudo apt-get update

Install chromium by typing

sudo apt-get install chromium-browser

Done



Monday, October 19, 2009

Clone a hard Drive


Good, easy way to clone a hard drive.



dd which is used for converting and copying files, can be used as a powerful and simple image cloning application.


dd if=/dev/hda of=/dev/hdb

done

if you want to see your progress

then type in another terminal
kill -SIGUSR1 xxxx
were xxxx is the process ID of the running dd process

and the progress will report on the original terminal that you started your cloning operation on.



Wednesday, October 14, 2009

share a single mouse and keyboard accross multiple computers

Here's the scenario.

you have 3 PC's on your Desk. One running Linux , One running MAC OS and the other running Windows XP.

all 3 with their own Monitor .


wouldn't it be cool, to be able to use the same Mouse and keyboard for all 3 PC's. and to be able to copy and paste, Text, Images and HTML content between the PC's.

No Problem, (drum roll...) ... in steps Synergy.

Synergy lets you share a single mouse and keyboard between multiple computers with different operating systems, each with its own display.

Redirecting the mouse and keyboard is as simple as moving the mouse off the edge of your screen. Synergy also merges the clipboards of all the systems into one, allowing you to cut-and-paste between systems. it also synchronizes screen savers so they all start and stop together.

Synergy uses TCPIP to communicate mouse position and keyboard keystrokes between the PC's. So all you need for Synergy to work is to have your PC's connected to the same network. (No additional hard ware is required)

you can download synergy from http://synergy2.sourceforge.net/

and read the user guide and installation instructions from http://synergy2.sourceforge.net/running.html