Wednesday, July 22, 2015

How to reset root user's password in RHEL7

Problem working with VM's is that you might not use one for a long time and when you had to use it again, you probably won't remember the root user's password! Yeah, ran into that situation myself again today and here are the steps to reset root user's password in RHEL 7. This is a bit different to how we used to do in RHEL 6.x.

1. On the grub menu, press 'e' to enter edit mode.
2. Once in edit mode, look for the line starting with 'linux16', and replace 'rhgb quiet' with 'init=/bin/sh'
3. Press ctrl+x to start booting with the modified grub entries
4. The file system will be mounted in read-only mode. Remount it in rw mode using the below command -  
mount -o remount, rw /
5. Use passwd command to reset the password for root user
6. Execute below command to ensure the selinux contents of modified files are restored properly after reboot -
touch /.autorelabel
7. Execute exec /sbin/init to continue normal boot process or exec /sbin/reboot to reboot the system

Thanks to original poster.

Network unavailability in RHEL7 (VMware) & how did I fixed it.

I was playing around with RHEL 7 evaluation version by firing up a VM lately. One of the issues that I faced was there was no network available other than lo. I ran out of my tricks after almost an hour and finally found the solution in here. Below is what I did to fix the issue -

1. Edited 'Red Hat 7 Eval.vmx'
2. Changed the value of guestOS from "other26xlinux" to "rhel6-64"
3. Added below entry -
ethernet0.virtualDev = "e1000"

Fired up the VM after those changes and voila, it picked the network now. All good!

Saturday, June 27, 2015

Simple shell script to change the extension of multiple files

Below is a simple script that I came up with today since I had to change the extension for a bunch of files. Thanks to original author for the script, I just added interactive touch to it.

for f in *.$1; do
mv -- "$f" "${f%.$1}.$2"
done

The script can be run as below -

./script old_extn new_extn

Thursday, July 17, 2014

Road to RHCE - Day 8

Day 8

Network Configuration

IP classes

Class          Range           Default subnet mask        Prefix

Class A  -> 1 to 126     -> 255.0.0.0                      -> 8
Class B  -> 128 to 191 -> 255.255.0.0                  -> 16
Class C  -> 192 to 223 -> 255.255.255.0              -> 24
Class D  -> 224 to 235
Class E  -> 236 to 254

255 -> broadcast address

127 -> loopback address


Subnetting -> dividing a large network into small networks
Subnet Mask -> unique id for such small networks


To configure network using TUI client

system-config-network

[! there are 2 options available - device & dns configuration]

Device configuration


Name                             : eth0
Device                            : eth0
Use DHCP                      : None
Static IP                         : 192.168.0.109
Netmask                        : 255.255.255.0
Default gateway IP         : 192.168.0.254
Primary DNS server        : 192.168.0.254
Secondary DNS server    : 192.168.0.254

[! this is a sample setup that uses static IP]


To update the changes

service network restart


To check the IP of the system

ifconfig
ip addr show


Associated config files

1. /etc/sysconfig/network-scripts/ifcfg-eth0
[! to configure the ip]

2. /etc/sysconfig/network
[! contains the hostname of the system]

3. /etc/resolv.conf
[! contains the DNS info]



To get the current hostname of the system

hostname


To know the status of all configured devices

service network status



-- End of Day 8 --

-- End of SA1 --

Wednesday, July 16, 2014

Road to RHCE - Day 7

Day 7



Backup and Compression


To check the directory size

du -sh /etc/


To create an archive

tar -cvf [archive_name] [list_of_files]


To know the type of a file

file [filename]


To extract the contents of a tar file to a different path

tar -xvf [archive_name] -C [destination_path]


To compress an archive (or file)

zip [zip_filename] [source_filename]


To decompress a compressed file

unzip [zip_filename]


Using gzip (only for archives)

gzip [archive_filename]

[! gunzip [filename] to decompress]


Using bzip2 (more compression than gzip)

bzip2 [archive_filename]

[! bunzip2 [filename] to decompress]


To compress while archiving

tar -cvfz [archive.tar.gz] [list_of_files]

[! z -> gzip; j -> bzip2]


Process Management

To monitor the processes via gui

gnome-system-monitor


To list the processes running in current session

ps

[! ps -a for all active processes across sessions; ps a for all processes (including inactive ones) across sessions]


To list the parent proces id and the owner info

ps -f


To list the processes in a tree format

ps af


To list all processes including system ones

ps x


To know the session detail

w


To know users login info

lastlog


To run a process in background

[process/service_name] &


To list the background processes started by users

jobs


kill

To list all the available options with kill command

kill -l


Below are few of the important options

9   -> kill
15 -> terminate
18 -> continue
19 -> stop (temporarily)


To stop a job/process temporarily

kill -19 %[job_id | proces_id]



To resume the stopped job/process

kill -18 %[job_id | process_id]


To make a background process run in the foreground

fg %[job_id]

[! Ctrl+z -> to stop temporarily; bg %[job_id] to take that to background]


To terminate a process

kill %[job_id]
kill [process_id]

[! kill command defaults to option 15, if nothing else is specified]


To force kill a process

kill -9 [process_id]


To kill using the process name

pkill -9 [process_name]


top

To list the running processes

top

[! the display gets refreshed every 3 sec; top -d 1 to refresh the display every 1 sec]


To kill the process based on id

k


To sort top output based on memory utilised

Shift+M


To sort based on CPU usage

Shift+C


To sort based on user

U



-- End of Day 7 --

Tuesday, July 15, 2014

Road to RHCE - Day 6

Day 6


bash configuration

bash is one of the login shells available for users in linux & the most commonly used shell as well.

Below are the important configuration files for bash. These files are present under every user's home directory -

.bashrc                           - contains the session configuration of the user
.bash_profile                  - contains the profile info of the user
.bash_logout                  - contains the commands/actions to be executed at end of the session (logout)
.bash_history                 - history of commands used by the user (this file will be populated only during the first successful logout)


There are also global shell configuration that can be set for all users via below file -

/etc/bashrc
/etc/profile


inode

inode -> index node


To check the inode of a file or directory

ls -i [filename]


Links

There are two types of links -

hard link
soft link

hard link

  • points directly the memory location of the file
  • same inode as that of the physical file
  • can be accessible even if the actual file is deleted
  • not possible to create hard links for directories
  • like a backup for the physical file
  • occupies the same space as that of the file


soft link

  • points to the file
  • different inode than the physical file
  • can not be accessible if the physical file is deleted
  • it is possible to create soft link for directories
  • does not occupy additional disk space


To create a hard link

ln [filename] [link_name]


To create a soft link

ln -s [filename] [link_name]


Special Permissions

There are three special permissions that can be set for files & directories -

Special userid (suid)    -> owner
Special groupid (sgid) -> group
Sticky bit                     -> others


Special userid

If set, the file will get executed based on the owner's permission and not based on the executor's permission.


To set special user id

Symbolic Method -> chmod u+s [filename]
Numeric Method  -> chmod 4755 [filename]

[! the first digit (4 for owner, 2 for group, 1 for others) denotes the special permission]


Special groupid

If set for a directory, all the future files/directories that gets created under that directory will have the group owner same as that of the parent directory.


To set special groupid

Symbolic Method -> chmod g+s [directory]
Numeric Method  -> chmod 2755 [directory]


Sticky bit

If set for a directory whose content have permission set as 777, other users can edit the contents of that directory but cannot remove or rename or move them.


To set sticky bit

Symbolic Method -> chmod o+t [directory]
Numeric Method  -> chmod 1777 [directory]


To flush the history of the current logged in user

history -c



-- End of Day 6 --

Monday, July 14, 2014

Road to RHCE - Day 5

Day 5

I/O redirection

To redirect  the output of a command to a file

hwclock > [filename]


To redirect the error from a command to a file

hwclok 2> [filename]


To redirect the standard input to a file

cat > [filename] << [eof_string]
blah blah
blah blah
[eof_string]


A sample shell script to create a text file with contents

#!/bin/bash
cat > test1 << END
This is the first line
This is the second line
END


Use of pipe ( | ) symbol

The pipe ( | ) symbol is used to redirect the output of first command as the input of the second.

date | cat > date.out

[! the above command will create the date.out file with the current date as it's content]


Text processing tools

There are many text processing tools in linux, like -

less
head
tail
more
cat
grep
sed
awk
cut
diff
tailf
wc
sort


To display top 'n' number of lines in a file

head -n [filename]


To display bottom 'n' number of lines in a file

tail -n [filename]


To search a string in a file

grep [string] [filename]


sed

The definition of sed is System Editor. It is used to find and replace a string in a file.


To search and replace only the first occurrence of the string of every line temporarily

sed 's/old_value/new_value' [filename]


To search and replace all occurrences of the string temporarily

sed 's/old_value/new_value/g' [filename]


To search and replace all occurrences of the string permanently

sed -i 's/old_value/new_value/g' [filename]


To delete a line (say, 3rd line) using sed

sed -i '3d' [filename]


To extract specific field from a text file

cut -d: -f6 [filename]

[! where : is the delimiter and 6 denotes sixth field to extract]



To find the difference between two files

diff [file1] [file2]


To get the statistics of a text file

wc [filename]

[! this will provide the number lines, characters, words that are present in that file]


To sort the contents of a file

sort [filename]


To find a file

find -name "*.txt"

find /home/ -user testuser

[! this command searches all files owned by testuser under /home]


Executing commands with 'find'

  • Commands must be preceded with either -exec or -ok (-ok prompts before acting on each file).
  • Command must end with ' \;' (a space, a backslash and a semicolon)
  • Can use {} as filename placeholder

find -size +100M -exec mv {} /tmp/ \;

[! the above command will search for any file that is >100MB in the current directory and move all those files to /tmp/]


To create a dummy file of size 1GB

dd if = /dev/null of = [target_filename] bs = 100M count = 10



-- End of Day 5 --

Friday, July 11, 2014

Road to RHCE - Day 4

Day 4


File Management

There are different ways to create a file -

vim [filename]
touch [filename]
cat > [filename]
[! when using 'cat' command, press Ctrl+D to save. '>>' to append to an existing file]


To create a directory

mkdir [directory_name]


To create multiple files using touch

touch filename{1..10}
[! this option will work with mkdir command as well]


To copy a file

cp [source_file] [target]


To copy a directory

cp -r [source_directory] [target]


To move/rename a file or directory

mv [source] [target]
mv [old_name] [new_name]


To delete a file

rm [filename]


To delete a directory

rmdir [directory_name]

 [! this works only on empty directory]

rm -rf [directory_name]

[! this works even on directory with contents]


--End of Day 4--

Thursday, July 10, 2014

Road to RHCE - Day 2 & Day 3

Day 2

I had to skip the second day due to unavoidable reason. Got to know from batch mates that below topics were covered on day 2 -

init levels
editors (gedit, vi, vim)
vim commands
basic file management (ls, cp, cd)
absolute path and relative path


--End of Day 2--


Day 3

Users & Group Management

Every user has an id called user id (same goes for 'group id' for each group)

uid of root user -> 0
uid of system (default) users -> 1 to 499
uid of normal users -> 500 and above

Files and directories that gets created/changed upon every user creation:

/etc/passwd                           (contains profile info of the users)
/etc/shadow                           (contains password info of the users)
/home/${USER}                     (home directory of the user)
/var/spool/mail/${USER}         (email inbox of the user)

Few config files that controls the user creation:

/etc/default/useradd             (base config file)
/etc/skel                             (base structure for every user's home directory)
/etc/login.defs                    (advance config file that contains password expiry period, home directory creation etc)

Understanding /etc/passwd file content

Normally the contents of /etc/passwd file will look like below -

root:x:0:0:root:/root:/bin/bash
   1  |2|3|4|  5  |    6  |      7

1 -> username
2 -> password protection symbol
3 -> userid
4 -> groupid
5 -> description about the user
6 -> home directory of the user
7 -> shell used by the user


To create a user

useradd [username]


To add a description (comment) for already created user

usermod -c "[description]" [username]


To set password for a user

passwd [username]


To create a user with a different shell (other than the default /bin/bash)

useradd -s /sbin/nologin [username]
 
[! the user can not login if his shell is /sbin/nologin]


To assign a new home directory for an existing user and to move his current home content to new location

usermod -md [newhome] [username]


To lock the password of a user

passwd -l [username]


To delete a user along with all his data (home & mail directories)

userdel -r [username]


Groups

There are two type of groups - Primary and Secondary (or Supplementary)

Similar to the user id (uid), there is also an id for each group (gid) and the id range is same as that of uid's.

Files that get changed or created when a group is created

/etc/group                    (contain group info)
/etc/gshadow               (contain group password)


Understanding the contents of /etc/group file

Normally the contents of /etc/group file will look like below -

root:x:0:root,user1
  1   |2|3|     4

1 -> group name
2 -> password protection symbol
3 -> group id
4 -> group members (users) list


To add a group

groupadd [groupname]


To assign a password for group

gpasswd [groupname]


To list the groups in which the currently logged in user is part of

groups


To assign a new group for currently logged in user temporarily

newgrp [groupname]


To assign user to a secondary group permanently

usermod -G [groupname] [username]

[! this will remove the user from his previous group(s) and assign him to the new group]


To assign a user to another secondary group permanently without removing his previous subscriptions

usermod -aG [groupname] [username]


To change the primary group of a user permanently

usermod -g [groupname] [username]


To change the group id of an existing group

groupmod -g [new id] [groupname]


To delete a group

groupdel [groupname]


Permissions
A normal ls -l command will output like below -

drwxr-xr-x. 2 root root  4096 Jul  1 21:59 Documents

In the above output, the first 11 characters define the permissions for the corresponding file.

d  r  w  x  r   -   x  r  -    x    .
1  2  3  4  5  6  7  8  9  10  11

1 -> File type
        -   -> ASCII file
        d  -> directory
        c  -> character device
        b  -> block device
        l   -> symbolic link
        s  -> socket

2,3,4  -> Owner's permission
5,6,7  -> Group owner's permission
8,9,10 -> Other's permission
11  -> selinux context


To change the owner of a directory (or file)

chown [username] [directory/file]


To change the group owner of a directory (or file)

chgrp [groupname] [directory/file]


There are two ways in which the permissions can be set for directories/files - one is Symbolic method and the other one is Numeric method.


Symbolic method glossary

Who
u  -> owner
g  -> group owner
o  -> others
a  -> all



What
r  -> read
w -> write
x  -> execute/accessible
-  -> null

Action
+ -> append/add
-  -> revoke/remove
= -> assign


Example:

chmod o+w [directory/file]

the above command will append write permission to others for the [directory/file]


Numeric method glossary

4  -> read
2  -> write
1  -> execute
0  -> null

Example:

chmod 755 [directory/file]

the above command will set the permissions for [directory/file] as rwxrw-rw-


UMASK

UMASK defines the default permissions that has to be set for each file/directory as soon as it is created by a user.

The default permission for directories        -> 777
The default permission for files                   -> 666
Predefined UMASK value for root user       -> 022
Predefined UMASK value for normal user  -> 002

Which means, if a root user creates a directory, that directory's permission is set to 777-022 = 755. And if the root user creates a file, that file's permission is set to 666-022 = 644.

Similarly, if a normal user creates a directory, that directory's permission is set to 777-002 = 775. And if the normal user created a file, that file's permission is set to 666-002 = 664.

UMASK value for all users is defined in /etc/profile


To change the UMASK value for currently logged in user temporarily

umask [new_value]



Tidbits of the day
  • id command is used to get the id of
  • id command is used to get the id of currently logged in user
  • RedHat uses sha512 algorithm to encrypt the user password. The algorithm is configured in /etc/login.defs

--End of Day 3--

Wednesday, July 9, 2014

Road to RHCE - Day 1

The thought of getting myself RHCE certified started some five to six years back. That remained a thought for a long time before I finally made my mind to make it into a reality.

Picked up a training center at T.Nagar and got myself enrolled on May 1st 2014. It took about one and a half month for the center to form the batch for the timing that I opted for and the classes started on June 18th 2014.

My intention of this blog is just to keep a digital copy of whatever notes that I take in the class. I am planning to blog the topics that are covered everyday.

A big thanks to my friend Shrinivasan, who motivated me to start this series & eventually to return back to blogging.

This might also help someone who is looking for quick help in linux or it might also give a good idea for students about the topics covered in RHCE. Anyway with some hope that my blog would help myself/others as a quick reference, let me get this rolling...


Day 1

First day was slow, as normally it would be for any training course for that matter. Our faculty gave us ample time (really 'a lot of time') to get settled in the classroom and after the formal introduction, he threw an unexpected bomb to us.

"Since this is the first day, you may start now if you wish. Or if you want me to take class, I can do that as well."

We were like "what, are you kidding???"

We finally convinced our faculty to start with the class and so after the regular features of linux stuff, our day 1 started with the default filesystem hierarchy of linux. Here on, I am switching to a text book style to minimize my blabbering and just to focus on the subject rather.

Disclaimer: The information shared in this blog from this point on are direct from the classroom and I am blindly replicating those here. Constructive feedback is always welcome if any inappropriate or misleading information is found.


Linux Filesystem Hierarchy

Below are the default directories that get created when you install RedHat linux operating system -

/              - top level directory
/root       - root user's home directory
/home     - placeholder for normal user(s)'s home directories
/bin         - contains the commands that can be executed by normal users
/sbin       - contains the commands that can be executed by root user
/boot      - boot loader info
/etc         - system config files
/dev        - device(s) info
/usr        - documentation files
/var        - log files
/opt        - 3rd party app data
/proc      - process & system info
/sys        - process & system info
/mnt       - placeholder to mount external media
/media   - placeholder to mount external media
/lib         - library files and modules

Terminal

The default shell that will be used during the training is bash (bourne again shell)

Terminal is the command prompt window which we can invoke in 3 ways from the desktop -

1. Press Alt+F2 -> type gnome-terminal
2. Click Applications -> System Tools -> Terminal
3. Right-click on the desktop -> Open in Terminal

To zoom in when inside the terminal - press Ctrl+Shift+"+"
To zoom out when inside the terminal - press Ctrl+"-"
To open a new tab in the terminal - press Ctrl+Shit+T
To switch between open tabs in the terminal - press Alt+

Tidbits of the day

  • whoami command is used to know the user as whom we logged in currently
  • date command is used to view/set the system date/time
  • hwclock command is used to view the CMOS date/time
  
--End of Day 1--

Wednesday, October 12, 2011

MySQL - Quick Reference

Came across this very useful link on MySQL commands & thought of sharing here. Thanks to the original poster @ http://www.pantz.org/software/mysql/mysqlcommands.html

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

Saturday, July 16, 2011

How to download multiple songs (files) from a site via wget

This was my long time requirement, ie, whenever I wanted to download songs from any site. I finally found the solution for the same - Thanks to Google.

There is no direct way to do this however, a workaround does exist.

Step1: Using lynx extract all the outgoing links from the html page where the songs are listed.

#lynx -dump "http://www.example.com" | grep -o "http:.*" > file.txt

or if the songs are listed in the same directory and you can identify the path of the directory by hovering over the song links, below would help a lot -
#lynx -dump "http://www.example.com" | grep -o "http://parent/directory/of/song/files/.*" > file.txt

Step2: Cleanup the URLs in file.txt such that it contains only the song URLs

Step3: Use wget, TADA... there you go :-)
#wget -i file.txt


-Jeeva

Tuesday, June 1, 2010

Series60-Remote - Manage your Symbian mobile in Ubuntu

Goddddddddddd! Had I known this by afternoon, I'd have saved half a day.

Finally, I got a tool with which I can manage the messages, contacts & files in my N95 with Ubuntu.

This tool is simply awesome and available for Debian, Fedora, Windows & MacOS. It's based on Python and needs a client to be installed in your mobile. You need to install PyS60 as well on your mobile. I used PythonForS60_1_4_5_3rdEd.sis for my N95 8GB since that was the latest available release. It uses sqlite or MySql in the backend for storing messages/contacts etc.

Apart from these, I had to install obexftp & python-obexftp [both available in Synaptic] as well.

Once all the required software are installed in your PC & in your mobile, you should initiate a bluetooth pairing between PC and Mobile and then open S60-remote in your mobile. I guess only bluetooth connectivity works as of now and you can not use USB mode yet. The client needs to be running all the time so you can not close it in your mobile but minimize it by pressing Menu key.

Then, open up Applications -> Internet -> Series60-Remote in your Ubuntu.

The application will list all available bluetooth devices.

Select your mobile from the list and click Next.

Application will ask if you want to push the client and PyS60 to your mobile if not done already. Ignore that and click next since we have them installed already.

After couple of screenshots explaining how to use the mobile client, application will connect to the phone and Ta-Da!

You'll see the phone is connected to the PC and it shows the battery and signal level of your phone.

From the left panel you can create a new message, manage contacts & files, see device information etc.

To see existing messages, you need to select 'View history' from Messages menu.

Once a new message come in to your mobile, the Series60-Remote in your Ubuntu will show a popup, just like a gtalk or skype chat popup, and ask if you want to continue as chat.

The app seems pretty neat, simple, fast and does a wonderful job. Unfortunately, this is available only for Symbian60 mobiles though! But still, great work by the developer.

So, those who have Symbian & using Ubuntu/Fedora/Mac or those who are not happy with the super slow message management in Ovi Suite, this app is exactly for you guys - GO FOR IT.


-Jeeva

Thursday, May 27, 2010

Moved to Gnome for the very same reasons I loved KDE

I moved to gnome today for the same reasons I preferred KDE when I started to use Fedora during pre-[K]Ubuntu days - Graphics.

I personally didn't like the graphics in KDE with Kubuntu 10.04 and had very minimal [you can read it as NONE] success in making my favs like compiz, emerald & awn work in KDE. On the other hand, gnome was super duper with all these and it was pretty easy to configure them all.

I feel the Ubuntu guys dropped the ball [courtesy: Martin :-)] on KDE and are focusing more on gnome these days. Sigh...

Anyway, I'm happy that I got some good effects on my desktop now :D


-Jeeva

Thursday, May 20, 2010

How to tune Thunderbird to automatically check for new emails in remote IMAP folders [in Kubuntu]

I was breaking my head with why Thunderbird [in Kubuntu] is not showing up new emails that come into remote folders even after I told Thunderbird to check mail every minute.

Thanks to kb.mozillazine.org, my bad that I didn't search for it sooner, I found the reason and the fix.

All you have to do is

Step 1:

1. goto Edit -> Preferences -> Advanced -> General ->Config Editor
2. Search for "mail.check_all_imap_folders_for_new" and set that to "true"

Step 2 - this is a bit frustrating, actually:

1. Now right click on EACH, you read that right E-A-C-H, remote folder -> Properties -> General Information
2. Select the "Check this folder for new messages" option, click "OK".

Thunderbird now really checks for new emails in every folder :-)


-Jeeva

Tuesday, May 18, 2010

Youtube from within Amarok

Discovered a cool feature in Amarok today which allows users to watch the corresponding video [from youtube] of the currently playing song.

All you got to do is add Videoclip applet to your Amarok



Then add the song you want to listen [& view in youtube] to the playlist and play the song.


The videoclip applet will then pull the related videos, from youtube, for the song that is being played. You can either add the clip to the playlist or play the desired clip immediately by right clicking on the clip.


There you are, viewing the youtube video right in your Amarok :-)



-Jeeva

Thursday, May 13, 2010

Managed [some how] to sync my iPod with Kubuntu Lucid Lynx

After little struggle and lot of googling, which let me down this time though, I managed to sync my iPod nano 4G with Kubuntu 10.04.

All the articles I came across mentioned abt using Banshee, Amarok etc for syncing iPod. I was desperate that I installed almost all the packages related to 'ipod' in KPackageKit. I kept on looking in Amarok to see if it detects the iPod, it didn't.

Meanwhile, I was able to see my iPod as a data storage media in Dolphin & was able to mount the same and browse through the files as well. This made me to go back to Amarok and try File -> Play media... and then select the iPod which got displayed in the pop-up window. As soon as I selected the iPod, I can see it listed in the Media sources panel under Local Music section. Woohooo...

I am now able to transfer music from/to my iPod, edit the tags for songs in the iPod, delete songs from iPod.........

:-)


-Jeeva

Followup:

Okay, I've been so stupid that I didn't notice the support for iPod was present by default in Kubuntu. The only thing was I didn't know how to use it though.

Just connect the iPod, Open it via Dolphin once [to mount the device] and there you are... your iPod will be available under Local Music section in Amarok!!!

Wednesday, April 14, 2010

Angaadi Theru - Is survival that hard?




Some movies, I just cant get them out of my mind that quick & Angaadi Theru is one such movie.

I saw the movie on Sunday and few scenes & dialogs keep coming back in my memory even now. The movie deals with the poor youth of South Tamilnadu, who were forced [by situation] to bear their family responsibilities, move to Chennai to work in Multi-Storied stores as sales boys/girls ["offered" by the store owners] in Chennai and their misery livelihood
.

There are movies which made me feel in one or two scenes but this one, s#!t. I thought of running out of the movie because I cant stand the sadness [I kinda liked that as well]. One could imagine that life is not that easy, after seeing the movie. Rather I'd say director just focused on the darker side of life, which he's made as his style btw.

There were many scenes in the movie which shows the pathetic conditions of those sales boys/girls that you'll start feeling for them. I'm wondering if I can be cool the next time when I visit these kinda multi-storied stores. I might think about the characters of this movie when I walk through Ranganathan Street [T.Nagar] the next time. It has become a trend now in Tamil cinema for these kind of movies. The problem is that the directors have started exaggerating the reality [like the lunch scene where the boys/girls go mad for plates & food] just to make it "filmy".

I kept asking just one question in my mind while I watched the movie - Is survival that hard for people in this country? If yes, why is it so? I donno, somebody?


-Jeeva

PS: I donno if I liked the movie or not but this left a heavy impression in me. If that's what is meant by a movie's success then I'd say this movie is a blockbuster up to me.

Saturday, April 10, 2010

Jeeva - Powered by ICE 1000 VA now!!!

After almost an year since my old UPS [APC 500VA] started dying, I got a replacement for it. And now I can work continuously without worrying about fluctuation, hurray :-D

Though I felt a 1 KV UPS is a bit too much for me, I got convinced with my friend's argument when he referred to the load I put on to my UPS. I normally connect these to my UPS - CPU, Router, Modem, Creative 2.1 speaker, Printer, WD 1TB ext HDD & occasionally charging my mobile ;-)

So far its good with the new one, withstanding the loooooowwwww voltage last night, let me hope this stays healthier for long in spite of all my tortures :-)


-Jeeva

Friday, March 12, 2010

IPL is back & the drama too

Photo Courtesy - http://www.iplt20.com


March 12 2010. "And, I declare the games open", Lalit Modi announced for a third time in front of a huge and eager crowd.

I had a hunch that Kolkata Knight Riders might have something for their fans this season but when they lost 2 wickets for no score in their very first over followed by losing another two wickets, they appeared to have not moved on from last 2 seasons, struggling at a miserable 31/4 at the end of 6 overs.

Deccan Chargers, even in their wildest imagination, would have never thought they could lose the match from that point. But, oh boy, they had to be reminded that this is 'IPL - Manoranjan Ka Baap'. Owais Shah and Angelo Mathews did that reminding job in a slow, steady, silent & a stylish fashion. After 20 overs, KKR had something to fight for with 161/4 on the scoreboard. Still, with a batting line-up that had the big guns like Gillie, Gibbs, Symonds, Laxman, Rohit etc 162 appeared like a cakewalk for DC.

DC did start their innings in style and did well until Laxman slogged one of Murali Kartik to give KKR a ray of hope. Amazingly, KKR started to regroup and everything fell in place for them as DC batsmen gifted their wickets, one by one, with poor shots. With the fall of every wicket I could see an aggression, an attitude & confidence building up with KKR. There was loads of positive vibe for KKR in this match which saw them winning the match comfortably in the end.

As the saying goes like "everything that start well, ends well", I expect KKR to end up in top four, may be more than that, this season.

Let us sit tight & watch the play, after all no one knows what the script writer, Lalit Modi, has in store for making IPL-3 'Manoranjan ka Baap' se 'Manoranjan ka Bada Baap'!


-Jeeva