Sponsored Content
Operating Systems Linux Gentoo how to edit linux system files? Post 302273954 by pludi on Tuesday 6th of January 2009 09:45:07 AM
Old 01-06-2009
If you already know C then you'll probably understand that it's pretty much impossible to have an OS running on human readable code (except if someone invents a microchip that can do that)
"Open Source" does not mean every kernel/library/program is human readable, but that it is possible for you to obtain the source code (for free) for you to read and modify (for free).
If you really, really, really want to learn how Linux works, I suggest downloading the LFS LiveCD. Quote from their Website
Quote:
LFS teaches people how a Linux system works internally
Building LFS teaches you about all that makes Linux tick, how things work together and depend on each other. And most importantly, how to customize it to your own tastes and needs.
Which seems to be exactly what you want to do.
This User Gave Thanks to pludi For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help to access/mount so to access folder/files on a Remote System using Linux OS

Hi I need to access files from a specific folder of a Linux system from an another Linux System Remotely. I know how to, Export a folder on One SCO System & can access the same by using Import via., NFS in the Sco Unix SVR4 System using the scoadmin utility. Also, I know to use mount -t ... (2 Replies)
Discussion started by: S.Vishwanath
2 Replies

2. UNIX for Dummies Questions & Answers

Edit Multiple Files in VI

Here's what I have... $ vi foo1 - open foo1 and work around for a while. I yank a few lines into a buffer and then :w to save. Next I :e foo2 to open foo2 and paste my buffer. I :w to save, but I would like to then be able to go directly back into foo1 where I was before I opened foo2. ... (4 Replies)
Discussion started by: djschmitt
4 Replies

3. Windows & DOS: Issues & Discussions

RTF files can they be converted once they are on linux system

:D mount -t vfat /dev/hda1 /mnt my dillemma is simple i have psion 5 mx wich is an epoc type machine not only does it only work on windows as far as I know but I have to convert the files (the usual stuff!) sometimes a humen error happens and the files that I want to transfer to the linux drive... (7 Replies)
Discussion started by: moxxx68
7 Replies

4. UNIX for Dummies Questions & Answers

edit _config files

Hi, I am trying to edit sshd_config file through the vi editor. logged on as a root. when I try to write the file I get: Read-only file, not written; use ! to override when i type :w!, I get: Error: etc/ssh/sshd_config Permission denied. I want to change: #PermitRootLogin no to yes freeBDS... (6 Replies)
Discussion started by: emosms
6 Replies

5. UNIX for Dummies Questions & Answers

How files can be transferred from one system to another securely using Linux?

i need to know how files can be transfered from one system to another securely in linux. (9 Replies)
Discussion started by: bibing
9 Replies

6. Shell Programming and Scripting

Edit .profile to connect to Oracle- Linux 2.6.9-89

Hi, I want to connect to sqlplus through unix. I got the command to do it. But I was getting error: ./executeSQL.ksh: sqlplus: not found Then when I googled I found that we have to include Oracle Client path in .profile file. I don't know how to do it. Also I don't have permissions to... (2 Replies)
Discussion started by: dips_ag
2 Replies

7. UNIX for Dummies Questions & Answers

Edit files with cat

Hi, sometimes one wants to edit files while still seeing output of earlier commands in terminal. I've found out that cat test && cat - >> test does the trick for displaying file content and adding lines but I believe I saw a much cooler command that was also able to erase lines from files. I cannot... (6 Replies)
Discussion started by: scarleo
6 Replies

8. AIX

Accessing files on AIX system from Linux system

I have a following requirement in production system 1 : LINUX User: abcd system 2: AIX (it is hosting a production DB) Requirement user abcd from system 1 should have read access on archive log files created by DB on system 2. The log files are created with permissions 540 by user ora ,... (2 Replies)
Discussion started by: amitnm1106
2 Replies

9. Shell Programming and Scripting

Gunzip and edit many files

Experts - I have an requirement to gunzip and edit many files in a pair of directories. I have two scripts that work great when run separately, but I'm having problems combining the two. The goal is to gunzip the files found in the first script and pipe them to the bash/sed script and... (9 Replies)
Discussion started by: timj123
9 Replies
Moose::Cookbook::Meta::Recipe2(3)			User Contributed Perl Documentation			 Moose::Cookbook::Meta::Recipe2(3)

NAME
Moose::Cookbook::Meta::Recipe2 - A meta-attribute, attributes with labels VERSION
version 2.0205 SYNOPSIS
package MyApp::Meta::Attribute::Labeled; use Moose; extends 'Moose::Meta::Attribute'; has label => ( is => 'rw', isa => 'Str', predicate => 'has_label', ); package Moose::Meta::Attribute::Custom::Labeled; sub register_implementation {'MyApp::Meta::Attribute::Labeled'} package MyApp::Website; use Moose; has url => ( metaclass => 'Labeled', is => 'rw', isa => 'Str', label => "The site's URL", ); has name => ( is => 'rw', isa => 'Str', ); sub dump { my $self = shift; my $meta = $self->meta; my $dump = ''; for my $attribute ( map { $meta->get_attribute($_) } sort $meta->get_attribute_list ) { if ( $attribute->isa('MyApp::Meta::Attribute::Labeled') && $attribute->has_label ) { $dump .= $attribute->label; } else { $dump .= $attribute->name; } my $reader = $attribute->get_read_method; $dump .= ": " . $self->$reader . " "; } return $dump; } package main; my $app = MyApp::Website->new( url => "http://google.com", name => "Google" ); SUMMARY
In this recipe, we begin to delve into the wonder of meta-programming. Some readers may scoff and claim that this is the arena of only the most twisted Moose developers. Absolutely not! Any sufficiently twisted developer can benefit greatly from going more meta. Our goal is to allow each attribute to have a human-readable "label" attached to it. Such labels would be used when showing data to an end user. In this recipe we label the "url" attribute with "The site's URL" and create a simple method showing how to use that label. The proper, modern way to extend attributes (using a role instead of a subclass) is described in Moose::Cookbook::Meta::Recipe3, but that recipe assumes you've read and at least tried to understand this one. META-ATTRIBUTE OBJECTS All the attributes of a Moose-based object are actually objects themselves. These objects have methods and attributes. Let's look at a concrete example. has 'x' => ( isa => 'Int', is => 'ro' ); has 'y' => ( isa => 'Int', is => 'rw' ); Internally, the metaclass for "Point" has two Moose::Meta::Attribute. There are several methods for getting meta-attributes out of a metaclass, one of which is "get_attribute_list". This method is called on the metaclass object. The "get_attribute_list" method returns a list of attribute names. You can then use "get_attribute" to get the Moose::Meta::Attribute object itself. Once you have this meta-attribute object, you can call methods on it like this: print $point->meta->get_attribute('x')->type_constraint; => Int To add a label to our attributes there are two steps. First, we need a new attribute metaclass that can store a label for an attribute. Second, we need to create attributes that use that attribute metaclass. RECIPE REVIEW
We start by creating a new attribute metaclass. package MyApp::Meta::Attribute::Labeled; use Moose; extends 'Moose::Meta::Attribute'; We can subclass a Moose metaclass in the same way that we subclass anything else. has label => ( is => 'rw', isa => 'Str', predicate => 'has_label', ); Again, this is standard Moose code. Then we need to register our metaclass with Moose: package Moose::Meta::Attribute::Custom::Labeled; sub register_implementation { 'MyApp::Meta::Attribute::Labeled' } This is a bit of magic that lets us use a short name, "Labeled", when referring to our new metaclass. That was the whole attribute metaclass. Now we start using it. package MyApp::Website; use Moose; use MyApp::Meta::Attribute::Labeled; We have to load the metaclass to use it, just like any Perl class. Finally, we use it for an attribute: has url => ( metaclass => 'Labeled', is => 'rw', isa => 'Str', label => "The site's URL", ); This looks like a normal attribute declaration, except for two things, the "metaclass" and "label" parameters. The "metaclass" parameter tells Moose we want to use a custom metaclass for this (one) attribute. The "label" parameter will be stored in the meta-attribute object. The reason that we can pass the name "Labeled", instead of "MyApp::Meta::Attribute::Labeled", is because of the "register_implementation" code we touched on previously. When you pass a metaclass to "has", it will take the name you provide and prefix it with "Moose::Meta::Attribute::Custom::". Then it calls "register_implementation" in the package. In this case, that means Moose ends up calling "Moose::Meta::Attribute::Custom::Labeled::register_implementation". If this function exists, it should return the real metaclass package name. This is exactly what our code does, returning "MyApp::Meta::Attribute::Labeled". This is a little convoluted, and if you don't like it, you can always use the fully-qualified name. We can access this meta-attribute and its label like this: $website->meta->get_attribute('url')->label() MyApp::Website->meta->get_attribute('url')->label() We also have a regular attribute, "name": has name => ( is => 'rw', isa => 'Str', ); This is a regular Moose attribute, because we have not specified a new metaclass. Finally, we have a "dump" method, which creates a human-readable representation of a "MyApp::Website" object. It will use an attribute's label if it has one. sub dump { my $self = shift; my $meta = $self->meta; my $dump = ''; for my $attribute ( map { $meta->get_attribute($_) } sort $meta->get_attribute_list ) { if ( $attribute->isa('MyApp::Meta::Attribute::Labeled') && $attribute->has_label ) { $dump .= $attribute->label; } This is a bit of defensive code. We cannot depend on every meta-attribute having a label. Even if we define one for every attribute in our class, a subclass may neglect to do so. Or a superclass could add an attribute without a label. We also check that the attribute has a label using the predicate we defined. We could instead make the label "required". If we have a label, we use it, otherwise we use the attribute name: else { $dump .= $attribute->name; } my $reader = $attribute->get_read_method; $dump .= ": " . $self->$reader . " "; } return $dump; } The "get_read_method" is part of the Moose::Meta::Attribute API. It returns the name of a method that can read the attribute's value, when called on the real object (don't call this on the meta-attribute). CONCLUSION
You might wonder why you'd bother with all this. You could just hardcode "The Site's URL" in the "dump" method. But we want to avoid repetition. If you need the label once, you may need it elsewhere, maybe in the "as_form" method you write next. Associating a label with an attribute just makes sense! The label is a piece of information about the attribute. It's also important to realize that this was a trivial example. You can make much more powerful metaclasses that do things, as opposed to just storing some more information. For example, you could implement a metaclass that expires attributes after a certain amount of time: has site_cache => ( metaclass => 'TimedExpiry', expires_after => { hours => 1 }, refresh_with => sub { get( $_[0]->url ) }, isa => 'Str', is => 'ro', ); The sky's the limit! AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.5 2011-09-06 Moose::Cookbook::Meta::Recipe2(3)
All times are GMT -4. The time now is 05:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy