Monthly Archive for January, 2006

ODOC: cut

cut — CUT a specified part form the file and Print it on stdout.

Summary :

Print selected parts of lines from each file(s) to standard output. This command is mostly used in shell scripts(think I should write a tut?)

Examples :

Create file1 with 10 columns (separated by TAB) of data for 10 lines and file2 with 10 columns (separated by space) of data for 10 lines.

$ cut -b2 file1 — Print only the byte in 2 position. Tab & Backspace are treated like a 1 byte char.

$ cut -b1,3,5 file1 — Print only the bytes in 1,3 & 5 positions.

$ cut -c2 file1 — Print only character in 2nd position. Normally same as -b option. But you can feel the difference only with multi-byte encodings (Unicode).

$ cut -f5 file1 — Print only the 6th field. TAB is default separator.

$ cut -f4- file1 — Print from 4th field to last field.

$ cut -f-5 file1 — Print from 1st field to 4th field.

$ cut -d’ ‘ -f3-5 file2 — Print only the fields from 3 to 5, which is separated by spaces.

$ cut -s -d’ ‘ -f2 file2 — Don’t print lines that don’t contain the delimiter,space (line without a delimiter is printed verbatim).

$ cut -f2-5,7-9 –output-delimiter=’,’ file1 — In the output, field will be separated by “,” (Not by the default one).

Note:

  1. Use one, and only one of -b, -c or -f.
  2. Range or many ranges can be separated by commas.
  3. Range of Bytes/Chars/Fields can specified like this:

N == Only Nth byte, character or field.
N- == From Nth byte, character or field, to End of line.
N-M == From Nth to Mth (included) byte, character or field.
-M == From 1st to Mth (included) byte, character or field.

Read : man cut

odoc, cut, linux,gnu/linux, shell+scripts

One Day One Site series in New Linux User

Jon from New Linux User has started a new blog series called One Day One Site. He would be writing about the various sites/forums where one frequents if they face some problem while on their GNU/Linux box. So, he is going to visit such sites and forums and make a small review of that site. It sure helps to get to know more sites other than to just depend on out LUG’s mailing list.

linux, tux

AVG free anti-virus for Linux

Grisoft, the makers of award-winning product AVG Free Antivirus has released it for GNU/Linux. I used to use AVG antivirus for windows and found it to be effective against numerous viruses. It was also providing maximum protection with little resources.

AVG for Linux is going to be the first commercial-grade antivirus product developed for home linux users.

AVG for linux has the following features:

  • Rapid virus database updates for the lifetime of the product
  • Small update files that do not drain system resources
  • Automatic update functionality
  • AVG On-Demand Scanner, which allows users to perform scheduled and manual tests
  • AVG

ODOC: chgrp

chgrp — Change the group ownership.

Summary :

chgrp changes the group ownership of each given file(s) to the specified group (group name or a numeric group id).

Examples :

$ chgrp grp1 file1 — Change the group ownership to grp1. No change in the user ownership.

$ chgrp grp1 f1 f2 f3 — Same as above, but for files f1, f2 and f3.
$ chgrp 400 file1 — Change the group ownership to a group, GID:400.

$ chgrp -R grp1 dir1 — Recursively change group ownership of Dir and their contents.

$ chgrp -c grp1 f1 f2 f3 — Show verbose output only when a change is made.

$ chgrp -v grp1 f1 f2 f3 — Show verbose output for every file processed.

$ chgrp -f grp1 f1 f2 f3 — Force/Silent/Quiet. Do not print error messages.

$ chgrp –reference=that this — Set the ‘that’ file’s group to ‘this’.

Note: Instead of Group name, Group ID can be used.

$ echo $GROUPS — Show Group ID.

Read : man chgrp

odoc, chgrp, linux, gnu/linux

ODOC: chown

chown — Change file Owner and Group.

Summary :

`chown’ changes the user and/or group ownership of each given file to the specified user and/or group.

Examples :

$ chown usr1 file1 — Make usr1 as the owner of the file1. No change in the group.

$ chown usr1 f1 f2 f3 — Make usr1 as owner for f1, f2 and f3.

$ chown usr1.grp1 file1 — Change owner as usr1 and group ad grp1 of the file1.

$ chown usr1:grp1 file1 — Same as above. But `:’ in place of the `.’ separator.

$ chown 500:400 file1 — Set a user, Whos user id is 500, as the owner and a group, which id is 400, as the group.

$ chown usr1. file1 — No group is specified after DOT. So usr1’s login group taken as group.

$ chown .grp1 file1 — Only group will change

$ chown -R usr1:grp1 dir1 — Recursively change ownership of Dir and their contents.

$ chown -c usr1 f1 f2 f3 — Show verbose output only when a change is made.

$ chown -v usr1 f1 f2 f3 — Show verbose output for every file processed.

$ chown -f usr1 f1 f2 f3 — Force/Silent/Quiet. Do not print error messages.

$ chown –reference=that this — Set the ‘that’ file’s owner and group to ‘this’ file.

$ chown –from=usr1 usr2 * — Change a file’s ownership only if it’s owner is usr1

Note:

  1. Seperators ‘.’ and ‘:’ are interechangeable
  2. No embedded whitespace is allowed between user and group
  3. Instead of user/group name, User ID and Group ID can be used.

$ echo $UID — Show User ID.
$ echo $GROUP — Show Group ID.

Read : man chown

odoc, chown, linux, gnu/linux

Domain registered

Atlast I convinced my father to allow me to use his credit card to register a domain. I have atlast registered a domain name (http://www.fslog.com) with Yahoo. The domain is still pending and would be active later. I guess by 2 days I would have setup my nameservers and changed the hosting information with Zeeblo.
So fslog.com will become this blog’s new home.
Update: I have changed the domain name and the new and final home of this blog is http://www.fslog.com. Got a few problems in the start, but with a little help from tinster at #wordpress sorted it out.

Kill an application in KDE

New Linux User has a very useful article about how to kill an application that misbehaves in your KDE.

When in KDE, if an application stops responding, just press Ctrl-Esc and it brings up the KDE process table. This table lists all the running processes and you just have to select the application that is not responding and have to click the kill button.
Actually, people say that Linux doesn’t hang like Windows. Yes, that is absolutely true, but the Graphical User Interface (desktop environment) has its own bugs and it is still not so stable to run any kind of app without crashing. Whatever happens to the desktop environment , you could always use the command line interface (CLI). CLI users always boast of this power and uninterrupted usage. This is also an important thing why Linux has better uptimes than Windows machines.

Regular Expressions

Regular expressions play a major part of any programmer or a computer science student. I had Theory of Computation last semester and I still have no idea what I learnt or was supposed to learn. But there was one topic that I loved. It was regular expressions. Here is a nice tutorial which shows beginners what is regular expressions and shows the real power of it. It has easy to understand examples which highlights the matched text according to the pattern.

ODOC: chmod

chmod — CHange file access permission MODes

Summary :

chmod is used to change the permission of the file(s) or directories. It is an important command that every Unix user must know. It is responsible for the security and protection for the various files.But first we must know what is access permissions.

If you type ls -i, you would get a listing of the current directory along with the access permissions. That is who is the owner of the file, what kind of permissions the user, group, others have, etc.

Here is an example listing
-rwxr-xr-- 1 foobar bar 10 Feb 14 15:00 myfile

The first field denotes whether the entry is a directory or a file or a link, etc. If it is a - then it is a file. If it is a l then it is a link. If it is a d then it is a directory. There are more under these, but these are the important ones.
The access permissions can be divided for owner(u), group(g) and eveyone else(o).
Each has three fields and are

  • r - Permission to read the file. In case of a directory, it is the permission to list the directory
  • w - Permission to write to the file. For a directory, it is permissions to create/remove files in that directory
  • e - Executable permissions for the file. For a directory, it means permissions to access files in the directory.

Internally the permissions are stored a numbers. That is

  • 1 - x - Execute
  • 2 - w - Write
  • 4 - r - Read

You can combine these numbers to give multiple permissions using a single command.
Eg.

  • 3 (2+1) - wx - Write and execute
  • 5 (1+4) - rx - Read and Execute
  • 6 (4+2) - rw - Read and Write
  • 7 (1+2+4) - rwx - Read, Write and execute

You specify these numbers for all the three categories of users - Owner, group, others.

Examples

$ chmod 777 myfile — All permission to all. Here permissions are given in numerical format.

$ chmod 755 f1 f2 — setting all permissions to owner and read & Execute permissions to group and others.

$ chmod u=rwx,g=rx,o=rx myprg — Same as above. But here permissions are given in symbolic format.

$ chmod u+x,g+r,o-rwx myprg — Add Exec permission to owner, Add Read permission to group and Remove all permission for others.

$ chmod u-x,go-rx myfile — Remove Exec permission for owner and Remove Read & Exec permissions for group & others.

$ chmod -R 755 mydir — Set the permission for files & Dirs recursively.

$ chmod –reference=f1 f2 — Set f1’s mode to f2.

$ chmod -c 755 myfile — Verbose but report only when a change is made.

$ chmod -v 754 myfile — Verbose output for every file processed.

Note: `chmod’ never changes the permissions of symbolic links.

Read : man chmod / info chmod

odoc, chmod, directory, permission

Koobox - $300 Linux Desktops

KooboxKoobox is a sub $300 GNU/Linux desktop released by Mirus which runs on Linspire GNU/Linux. Though Ubuntu has an OEM installation, I still haven’t used Linspire GNU/Linux.

There are three models that are available with Koobox.

  1. Essential: $299
  2. Multimedia: $399
  3. Performance: $499

Currently it is available only in US and I wonder when it will be available in India. And how much successfull it could be here.