Unfortunately, maintaining a multi-boot configuration like this can be a pain, especially if you later install an operating system which overwrites the GRUB boot loader you had in place (such as a version of Windows). If your boot loader is overwritten, you could be left with no choice but to boot the most recently installed OS.
In this tutorial, I will show you how to restore an overwritten copy of the GRUB boot loader by using a Linux live CD. In this example, my master GRUB installation is on a Fedora 15 installation, and I’m using a Fedora 15 Live CD to boot the system.
Start the Live CD up as normal. Don’t choose to install the OS if prompted, you want to come to a full live desktop to run the specific commands we need.
1. Identify your Partitions
Open a Terminal program and use the following command:
[alexm@localhost ~]$ su
[root@localhost /]# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b474b47
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 91394047 45593600 7 HPFS/NTFS/exFAT
/dev/sda3 91394048 402077695 155341824 83 Linux
/dev/sda4 402077696 976771071 287346688 f W95 Ext'd (LBA)
/dev/sda5 402079744 976771071 287345664 7 HPFS/NTFS/exFAT
[root@localhost /]#
If you can work out where your Linux is from this, note down the information under ‘Device’.
In this tutorial, Fedora 15 is installed in /dev/sda3
2. Run grub-install
[root@localhost ]# sudo -i
[root@localhost ~]# mount /dev/sda3 /mnt
[root@localhost ~]# grub-install --root-directory=/mnt/ /dev/sda
Installation finished. No error reported.
This is the contents of the device map /mnt//boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
# this device map was generated by anaconda
(hd0) /dev/sda
[root@localhost mnt]#
Tuesday, December 8, 2009
Monday, July 6, 2009
Installed PC Linux 2009.2
Today, I deleted the whole Fedora partitions and install PC Linux 2009. Works fine and can install the USB wifi
How to check kernel if 32 or 64 bit
[alex@localhost ~]$ uname -m
i686
[alex@localhost ~]$ file /usr/bin/file
/usr/bin/file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[alex@localhost ~]$
i686
[alex@localhost ~]$ file /usr/bin/file
/usr/bin/file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[alex@localhost ~]$
Friday, June 26, 2009
Wednesday, June 24, 2009
Wednesday, June 10, 2009
How to Bulk Download YouTube Videos on Linux and Convert to MPG and MP3
This tutorial shows how to bulk download YouTube videos on Linux and then convert the FLV files to MPG video and MP3 audio files.
Required Software
I am using Ubuntu Linux, but the concept should be the same for other distros. Make sure you already have all of the multimedia codecs including ffmpeg and mplayer. You will also need to install youtube-dl:
sudo apt-get install youtube-dl
Downloading YouTube Videos on Linux
To download YouTube videos on Linux, use youtube-dl in the terminal like this:
youtube-dl [options] video_url
To see available options type man youtube-dl in a terminal.
Converting YouTube Videos to MPG on Linux
To convert YouTube movies from FLV to MPG on Linux use ffmpeg like this in the terminal:
ffmpeg -i old-file.flv new-file.mpg
Ripping MP3s from YouTube Videos on Linux
It is easy to extract MP3 audio from a YouTube movie on Linux with mplayer.
The method to rip MP3 audio from FLV files with ffmpeg from this site doesn't work on my computer so I use mplayer to do it:
mplayer -dumpaudio old-file.flv -dumpfile new-file.mp3
Automating the Process with a Shell Script
If you want to download a set of YouTube movies and convert them to MP3 audio, or save them as MPG movies on your hard drive, you can automate the process with a shell script.
This is just a quick script showing how it might be done. Use the following code at your own risk, and make sure you understand what it does before doing it. It will delete all the FLV files in the current directory after it processes them.
#!/bin/sh
# This script downloads YouTube videos and converts them
# You will end up with an MPG video and MP3 audio of each YouTube movie
# You need to install the following three programs:
# youtube_dl, ffmpeg, and mplayer
# Use this script at your own risk!
# Make sure that you understand how it works before you use it!
# USAGE:
# Make a file called videos.txt with the URL of 1 YouTube video on each line.
# Don't leave any blank lines in the file
# Put the videos.txt file in an empty folder along with this script
# run this script with the following commands:
# $ ./youtube_downloader.sh
# It will take a long time to run, depending on
# how many videos you have in your videos.txt file.
while read inputline
do
youtube_url="$(echo $inputline)"
youtube-dl $youtube_url
done < videos.txt
# Convert the flv files to mpg and mp3 files
for i in *.flv
do
ffmpeg -i $i $i.mpg
# comment out the next line if you don't want MP3's extracted
mplayer -dumpaudio $i -dumpfile $i.mp3
# The next line deletes all FLV files in the current directory to cleanup
rm $i
done
See also pytube...
Thinking out of the BoX !! Download YouTube Videos : The Linux Way !
In this article I will outline a few methods to download YouTube Videos to your system and getting them to play in your favorite player. We will go in a step-wise way :
A. Getting the Video
1. Online Tools
There are some sites like KeepVid.com which allow users to input a YouTube link and they would give you the download link. So get the download link from this site and download the flv file.
2. Firefox Plugin
There is a firefox extension which allows you to download YouTube videos as you watch them. I haven’t tried this.
3. Command Line Tools
This is the safest and best way (for CLI junkies :-D ). Download the script YouTube-dl (thanks to Ricardo Garcia Gonzalez for this nice script). Just put that script in your ~/bin or /usr/bin directories or somewhere in the application path.
To download the flv video do this :
youtube-dl
e.g : youtube-dl http://www.youtube.com/watch?v=D1R-jKKp3NA
B. Playing the video
1. Use VLC Player or MPlayer or Kaffeine to play the flash video.
2. If the above method doesn’t work out (It din’t in my case)..Then go the difficult way :
* Get ffmpeg for your system. SuSE users can get it here.
* Convert the flv video to avi (or any other format) using ffmpeg :
ffmpeg -i my_flash_video.flv the_avi_file.avi
* Now drag and drop the avi file into your favorite video player n watch the video :-)
Still unsatisfied ?! “Dude I’m a *nix user. I can’t sit and do all these steps to get a simple video playing !!” No probs. We will write a shell script to do all this work for you.
Note : I found the downloader in youtube-dl quite slow. So I tweaked it a bit(I don’t know python :-D ) to use an external downloader (axel rocks!). Open the file youtube-dl in your favorite editor and change the following lines :
282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 sys.exit()
to the following :
282 # Abort here if in simulate mode
283 if cmdl_opts.simulate:
284 cond_print(video_data.geturl())
285 sys.exit()
That will make the script output the downloadable video link to the standard output (when run in simulate mode). Now write the shell script :
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage : $0"
echo "e.g : $0 http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs"
else
outputfile=".avi"
todnload=`youtube-dl -s $1 | tail -n 1 -`
echo "Got the file.."$todnload
axel -n 100 $todnload -o $2".flv" # wget -c $todnload -O $2".flv" .if you don't use axel
echo "Download Completed..."
ffmpeg -i $2".flv" $2$outputfile # get the avi file
fi
Done. Now paste that code into a file utube in your path. Then run utube as :
utube http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs
This will give 2 files steve_jobs.flv and steve_jobs.avi ;)
Just drag the *.avi to kaffeine and enjoy the speech by Steve Jobs !
Monday, June 8, 2009
Arrow keys not working in VMware Server 64bits, host=Fedora 11 64bits, Guest = XP pro 32bits
Ok, I got the solution:
Edit your "/etc/vmware/config" file, so type:
sudo gedit /etc/vmware/config
And add this to it:
xkeymap.nokeycodeMap = true
xkeymap.keycode.108 = 0x138 # Alt_R
xkeymap.keycode.106 = 0x135 # KP_Divide
xkeymap.keycode.104 = 0x11c # KP_Enter
xkeymap.keycode.111 = 0x148 # Up
xkeymap.keycode.116 = 0x150 # Down
xkeymap.keycode.113 = 0x14b # Left
xkeymap.keycode.114 = 0x14d # Right
xkeymap.keycode.105 = 0x11d # Control_R
xkeymap.keycode.118 = 0x152 # Insert
xkeymap.keycode.119 = 0x153 # Delete
xkeymap.keycode.110 = 0x147 # Home
xkeymap.keycode.115 = 0x14f # End
xkeymap.keycode.112 = 0x149 # Prior
xkeymap.keycode.117 = 0x151 # Next
xkeymap.keycode.78 = 0x46 # Scroll_Lock
xkeymap.keycode.127 = 0x100 # Pause
xkeymap.keycode.133 = 0x15b # Meta_L
xkeymap.keycode.134 = 0x15c # Meta_R
xkeymap.keycode.135 = 0x15d # Menu
Save it and be happy!
Thursday, June 4, 2009
The FAT16, FAT32 and NTFS file size limitation
The file size limitation appears to be the problem,
but the maximum size depends on the operating system.
What is the size of the file you're copying and where does it reside?
The maximum file size on a FAT32 formatted partition is
4 GB or 4,294,967,296 bytes minus 2 bytes ...
The maximum file size on a FAT16 partition
under Windows 9.x and ME is 2 GB minus 1 byte ...
But the size limit using the FAT16 file system
under Windows NT or 2K is 4 GB ...
And the NTFS file system has a (theoretical) maximum file size of
16 exabytes or 18,446,744,073,709,551,616 bytes (2^64 sectors) ...
Thursday, May 28, 2009
Setup Samba - Filesharing with Windows
Setup Samba - Filesharing with Windows
If you have other Windows computers on your LAN and want to share files from Linux with them, you must setup Samba.
To setup Samba you must (1) install samba, (2) add you 'shares', (3) add users, (4) start Samba service and (5) manage security options (Firewall and SELinux).
1. Install Samba
It is best to have Samba installed in the installation process. If not < users can install using the command line:
[alex@localhost ~]$ sudo yum install samba samba-client
2. Add Shares
You must edit /etc/samba/smb.conf as root: (use nano instead of gedit if you do not have a GUI)
[alex@localhost ~]$ sudo gedit /etc/samba/smb.conf
Set your Windows Workgroup name in [global] section.
Added shares at the end of the file. Example:
workgroup = WORKGROUP
server string = Samba Server Version %v
# A publicly accessible directory, but read only, except for people in
# the "staff" group
[public]
comment = Public Stuff
path = /home/samba
public = yes
writable = yes
printable = no
write list = +staff
[Share]
comment = Samba shares
path = /home/commons
read only = no
valid users = alex
create mask = 0775
directory mask = 0775
#
# New additional samba shares
#
[mnt_local]
comment = Local shares
path = /mnt/local
public = yes
writable = yes
browseable = yes
[mnt_resume]
comment = Resume partition
path = /mnt/resume
public = yes
writable = yes
browseable = yes
[mnt_account]
comment = Accounts partition
path = /mnt/account
public = yes
writable = yes
browseable = yes
If 'writable' the location must be writable in Linux first. Additionally permissions must match (for example: drw-rw-rw-).
If home data (all personal files under /home/username) is to be accessible, then set 'browseable = yes' under [homes] (~line 250). This configuration file is very descriptive, read through it to get more ideas or information.
3. Add Users
To access shares, you must be a valid user. Add valid users AND passwords using the smbpasswd command.
This login name WILL be the login name and password you use from Windows to access your Linux computer. The password does NOT need to match your Linux password.
[alex@localhost ~]$ sudo smbpasswd -a alex
New SMB password:
Retype new SMB password:
account_policy_get: (warnings ignored)
Added user username.
(Note: 'alex' MUST be a valid account on the Fedora machine)
4. Start Samba Service
Run samba and check for any errors:
[alex@localhost ~]$ sudo /etc/init.d/smb start
Starting SMB services: [ OK ]
Use chkconfig or serviceconf to enable samba (smb) in both runlevels 3 and 5. This will make sure to run Samba each time Fedora boots.
[alex@localhost ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[alex@localhost ~]$ sudo /sbin/chkconfig --level 35 smb on
[alex@localhost ~]$ /sbin/chkconfig --list smb
smb 0:off 1:off 2:off 3:on 4:off 5:on 6:off
Restart Samba for every change to users/passwords or 'smb.conf'
[alex@localhost ~]$ sudo /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
5. Managing Security for Samba
Firewall
The Firewall will by default block Samba, to allow access run:
[alex@localhost ~]$ system-config-firewall
To allow Samba access to work through the firewall you must set 'Samba' as a 'Trusted Service' and hit 'Apply'. Alternatively if you are only using the shell and do not have access to a graphical X-server, you can run:
[alex@localhost ~]$ sudo system-config-firewall-tui
To allow Samba access to work through the firewall, useto go to Customize. In the Trusted Services: scroll down to Samba, hit and use again to go to Close, then finally to OK.
SELinux
SELinux has significant control over restricting different parts of Samba. Run system-config-selinux. Please read lines #23 - #51 in /etc/samba/smb.conf for a better explanation. Alternatively, you can run:
[alex@localhost ~]$ system-config-selinux
Go to Boolean and type 'samba' in the Filter (without quotes).
The following is NOT complete and is NOT recommended but is a quick enable to allow Samba to work permissively through SELinux.
[alex@localhost ~]# sudo /usr/sbin/setsebool -P samba_export_all_rw on
Alternatively, you can ignore SELinux at this point and try to access your shares in Windows and SELinux TroubleShooter should give an automatic pop-up in GNOME explaining what is wrong. If you follow those recommendations you most likely will be more secure.
For any changes made above to the SELinux settings or smb.conf, it is recommended to restart Samba.
Top Resources
More Information
Fedora 10 - Services and Daemons in Fedora 10
Fedora 10 Blog Entries
Fedora Nvidia Driver Install Guide
Fedora 9 - Personal Installation Guide
Fedora 9 Update and Nvidia Update
Update to RPMFusion
Fedora Core 5 on Dell D810 Latitude Laptop
Managing Services in Fedora
Fedora Help Forum Posts and Threads
Top Resources
5. Managing Security for Samba
Firewall
The Firewall will by default block Samba, to allow access run:
[mirandam@charon ~]$ system-config-firewall
To allow Samba access to work through the firewall you must set 'Samba' as a 'Trusted Service' and hit 'Apply'. Alternatively if you are only using the shell and do not have access to a graphical X-server, you can run:
[mirandam@charon ~]$ sudo system-config-firewall-tui
To allow Samba access to work through the firewall, useto go to Customize. In the Trusted Services: scroll down to Samba, hit and use again to go to Close, then finally to
OK.
Thursday, May 7, 2009
UNIX network analysis
Finding open ports on your workstation
[root@localhost alex]# nmap -T Aggressive -O 192.168.0.106
Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:38 EDT
Interesting ports on 192.168.0.106:
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
902/tcp open iss-realsecure
1521/tcp open oracle
3306/tcp open mysql
6000/tcp open X11
8009/tcp open ajp13
8222/tcp open unknown
8333/tcp open unknown
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.15 - 2.6.25
Network Distance: 0 hops
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.49 seconds
Finding other services on your network
[root@localhost alex]# nmap -sT 192.168.0.106/22
Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:47 EDT
Stats: 0:00:08 elapsed; 104 hosts completed (2 up), 2 undergoing Connect Scan
Connect Scan Timing: About 84.28% done; ETC: 11:48 (0:00:00 remaining)
Interesting ports on 192.168.0.1:
Not shown: 998 closed ports
PORT STATE SERVICE
80/tcp open http
5678/tcp open unknown
MAC Address: 00:1C:F0:54:4C:67 (D-Link)
Interesting ports on 192.168.0.100:
Not shown: 999 filtered ports
PORT STATE SERVICE
10000/tcp open snet-sensor-mgmt
MAC Address: 00:11:A0:04:59:EA (Vtech Engineering Canada)
Interesting ports on 192.168.0.106:
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
902/tcp open iss-realsecure
1521/tcp open oracle
3306/tcp open mysql
6000/tcp open X11
8009/tcp open ajp13
8222/tcp open unknown
8333/tcp open unknown
Nmap done: 1024 IP addresses (3 hosts up) scanned in 98.37 seconds
[root@localhost alex]#
Discovering hosts on your network
[root@localhost alex]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.0.1 ether 00:1c:f0:54:4c:67 C wlan0
Finding other hosts on your network
[root@localhost alex]# nmap -sP 192.168.0.106/22
Starting Nmap 4.76 ( http://nmap.org ) at 2009-05-07 11:41 EDT
Host 192.168.0.1 appears to be up.
MAC Address: 00:1C:F0:54:4C:67 (D-Link)
Host 192.168.0.100 appears to be up.
MAC Address: 00:11:A0:04:59:EA (Vtech Engineering Canada)
Host 192.168.0.106 appears to be up.
Nmap done: 1024 IP addresses (3 hosts up) scanned in 81.99 seconds
[root@localhost alex]#
Subscribe to:
Posts (Atom)