sexta-feira, agosto 27, 2004

LX Debug de programas linux

strace

outros exemplos:

strace PROGRAMA > LOG
strace PROGRAMA | tee LOG

LX Busca arquivo por nome e conteúdo

encontrar todas os arquivos na árvore de diretórios que não contêm uma determinada string. Por exemplo, todos os arquivos exceto aqueles com extensão .o e .c . Aqui estão algumas das possibilidades para fazê-lo:

find . -print | fgrep -v '.o' | fgrep -v '.c' ou
find | fgrep -v '.o' | fgrep -v '.c'


Para procurar por uma expressão em todas os arquivos no diretório atual, apenas digite:

egrep -i "expressao de busca" *

Para procurar por strings em todas os arquivos dentro da árvore de diretórios, você pode combinar o find ou outros comandos da busca de nome de arquivos com, por exemplo, o egrep. Isto pode ser feito de diversas maneiras:


find . -type f -print | xargs egrep -i "expressao"

egrep -i "expressao" `find . -type f -print`

LX Mount do Samba

mount -t smbfs -o username = trideg, password = foobar //fjall/test /data/test

NC grant no Mysql

grant all privileges on *.* to test@localhost (banco test)

NC Recuperação de senha do Mysql para Windows

copiar os bancos de dados e reinstalar
após isto sobrescrever somente os bancos de usuário

NC Servidor gratuito

Servidor gratuito com suporte a PHP e mysql

Link

NC Advanced Event Listeners

import java.awt.*;

import java.awt.event.*;
import javax.swing.*;

public class SomeGUI extends JFrame
{
JButton run = new JButton("Run the Utility");
JButton exit = new JButton("Exit After Save");
JPanel buttons = new JPanel(new GridLayout(4,1,2,2));

protected void buildGUI()
{
buttons.add(run); buttons.add(exit);
this.getContentPane().add("Center",buttons);
exit.addActionListener(new ExitHandler());
}

// add inner class event handler for each button here
class ExitHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}

public static void main(String[] args)
{
SomeGUI app = new SomeGUI();
app.setTitle("Layered GUI Demo");
app.setBounds(100,100,250,150);
app.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
app.buildGUI();
app.show();
}
}


Anonymous inner classes have no name (hence no name conflict) and are used
when only one instance of the class is required. They also do not have
constructors. Anonymous inner classes are most often found in event
listeners. A simple example for the exit button is:

exit.addActionListener(new ActionListener()

{
public void ActionPerformed(ActionEvent e)
{
System.exit(0);
}
});


As event classes are interfaces, all methods within that event must be
implemented.
Adapter classes provide default do-nothing methods which you can chose
to override.
Here is a short example using the WindowAdapter class to avoid coding
all seven window events.

import java.awt.*;

import java.awt.event.*;

class Listener2 extends Frame
{
Listener2()
{
addWindowListener(new WindowAdapter()
{
public void windowclosing (WindowEvent e)
{ System.exit(0); }
});
setSize (200,200);
setVisible(true);
}
public static void main (String [] args)
{
new Listener2();
}
}

NC Basic Event Listeners


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Frame3 extends JFrame implements ActionListener
{
JPanel panel = new JPanel(); // create panel object
JLabel prompt = new JLabel(" Enter a number: ");
JTextField answer = new JTextField ("", 5); // constrain length
JButton pressme = new JButton("Press Me");
// first comes the constructor
Frame3()
{
Container con = this.getContentPane(); // inherit main frame
con.add(panel);
pressme.setMnemonic('P'); // associate hotkey
pressme.addActionListener(this); // register button
panel.add(prompt);
panel.add(answer);
panel.add(pressme);
answer.requestFocus();
}
// now the event handler
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if (source == pressme)
{
JOptionPane.showMessageDialog(null,"I hear you!","Message Dialog",
JOptionPane.PLAIN_MESSAGE); // show something
}
}
// and finally the main method
public static void main(String[] Args)
{
Frame3 app = new Frame3();
app.setTitle("Event Handler Demo");
app.setBounds(100,100,300,200); // position frame
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.setVisible(true);
}
}

NC static Java (continuação)

Inicialização de bloco estático:

import java.util.ResourceBundle;

class Errors {
static ResourceBundle errorStrings;
static {
try {
errorStrings = ResourceBundler.getBundle("ErrorStrings");
} catch (java.util.MissingResourceException e) {
//error recovery code here
}
}
}

NC static Java

Método estático só acessa campo estático, em outras palavras método de classe só acessa atributos de classe. Por exemplo:

class AnIntegerNamedX {
static int x;
static public int x() {
return x;
}
static public void setX(int newX) {
x = newX;
}
}

NC Interfaces Java

Idéia de contrato...

Interfaces are similar to abstract classes but all methods are abstract and all properties are static final.

When a class implements an interface, the class agrees to implement all the methods defined in the interface.

You use an interface to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. Interfaces are useful for the following:

* Capturing similarities among unrelated classes without artificially forcing a class relationship.
* Declaring methods that one or more classes are expected to implement.
* Revealing an object's programming interface without revealing its class.

If an object wants to be notified of mouse clicks, the Java platform event system requires that the object implement the MouseListener interface.

The Implements statement is used as part of a technique that separates the interface of an object from its implementation, so that multiple implementations of the interface can be developed.

Just as classes extend other classes, interfaces can extend other interfaces (but not classes).



NC Tutorial Java

Tutorial Java muito bom !!!

Link

E conceitos adicionais de OOP

Link

Universidade de Liverpool


LX Mais Comandos

last (lista dos últimos acessos)
lastlog - Mostra o último login dos usuários cadastrados no sistema.

LX Comandos

tree -d (somente diretórios)
find -type [f,d,l] (somente arquivo diretório ou link)
grep -r TEXTO ARQUIVO
date MMDDHHmm
uname -a
dpkg -i PACOTE (debian)
installpkg (slackware)
history

LX Procura Texto no Arquivo

cat ARQUIVO |grep --text "TEXTO"

LX Guia Foca Manual

http://www.guiafoca.org/gol.html

e Dicas L (Unicamp)

http://www.dicas-l.unicamp.br/

e OpenOffice Brasil

http://www.openoffice.org.br



LX Processo no Linux

top (processo com maior cosumo de memória)
free -s tempo (memória utlizada)
vmstat (memória virtual)
bg pid (background)
fg pid (foreground)

LX Árvore de processos

pstree |more

LX Dois Terminais X

Para chamar dois terminais X basta

startx -- :0 (display)
startx -- :1

se quiser chamar apenas o xterm

xinit -- :0
xinit -- :1

LX Starting many X sessions

Link

outro link ótimo é

Link


LX Running X11 Applications Remotely

NOTE: We do not support the software required to do this. This is simply a guide to help get you started on your way. If there is some application that you can not run remotely, you need to use one of the UNIX labs on site at PSU.


The easiest way to run X11 applications at home, and the method we recommend, is to use SSH forwarding to forward X11 applications to your local X server. To do this, you will need two applications -- an X server, and an SSH terminal application.

X11 Servers

Windows

X-Win32 - Most commonly used X server for windows, fairly priced with an educational discount.
Exceed - Another popular X server, stable, full featured, and equipped with many extra tools.
Cygwin/XFree86 - Free, though the Windows port of XFree86 is still very much in development, and does not run properly on many configurations. Also required is a decent understanding of UNIX and setting up XFree86. Still, for free you can always give it a try.
Linux/*BSD

XFree86 - Probably came with your distribution. XFree86 is the most common implementation of X found on Linux and the various BSD distributions. It is fast, stable, and free.
Mac OSX

X11 for Mac OS X is available from apple for versions of OSX earlier than 10.3
For OS X version 3 (panther) and up X11 is included on the os cds
Mac OS Classic

eXodus - Same as above, however the SSH tool does not function.
SSH Software

Linux, Mac OSX, and other *NIX variations typically come with variations of SSH. If not, you may need to install a version such as OpenSSH.

See our Shell/SSH Access page for more information on SSH clients for other operating systems.

Setting up X11 Forwarding

Many, but not all SSH clients currently available support X11 Forwarding, and general port forwarding. This allows network traffic to be forwarded from the remote machine to your local box through SSH. The result is that with very little configuration, this traffic is forwarded to you machine, encrypted in an SSH "tunnel".

There are several reasons this is a preferred method to run X11 applications remotely:

Most importantly, the transmission is secure. Any data, passwords, etc. is encrypted within the SSH tunnel.
Setup is easy. In most situations, all you need to do is have your X server running. There is no need to modify permissions for foreign hosts, and no need to set your DISPLAY variable. SSH does it all for you.
With SSH compression turned on, it can actually be faster to use SSH than not on low bandwidth connections.
To set up SSH port forwarding, you simply need to enable that option in your client. We outline a few examples below for common clients:

NOTE: We recommend against using any SSH program that does not support SSH version 2. We will be switching to version 2 exclusively in the future due to security flaws in version 1. Recent versions of PuTTY, MacSSH, and OpenSSH support both SSH2 and port forwarding.

PuTTY

Set up a new session or load an existing one, and set all the appropriate settings you desire.
Go to Connection -> SSH -> Tunnels.
Make sure the checkbox "Enable X11 Forwarding" is checked. The box below it should read "localhost:0". If you are forwarding to your local machine (most likely) this is fine.
Return to Session, the opening settings window.
Type in the name of your session, and click "Save".
MacSSH

Go to the menu item Favorites -> Edit Favorites.
Either create a "New" entry, or select an existing one and click "Edit".
Enter the hostname and any other desired information.
Go to the "SSH2" tab.
Make sure the checkbox "Forward X11" is checked.
Save your favorite by clicking "OK".
OpenSSH or the commercial SSH Client

X11 forwarding is typically turned on by default in most *NIX distributions of SSH. If it is not, you can enable it by calling SSH with the "-X" option. For example:

% ssh -X username@unix.ece.pdx.edu

You can also change this option in the SSH configuration files. Please refer to the SSH documentation for more.

Running your Application

This is the best part! First, start your X Server if it isn't running already. To run the X application you want, simply SSH in to the machine you desire, and run the program. The program should display on your screen, probably after some delay as it loads.

Speed

Note that X11 requires a lot of network traffic. You can not realistically run large, graphics intensive applications over a 56K modem. Netscape, for example, can take up to 10 minutes simply to start and display your home page. No exaggeration. But some applications are fairly reasonable, especially on a broadband connection such as DSL or Cable. Feel free to experiment with various settings. Many X servers support options that will speed up performance over low bandwidth connections such as caching data, or not refreshing windows that aren't in focus. Turning on compression in your SSH client can also help in some situations.

Fonts

You may run into some applications that require additional fonts to run properly. The Mentor Tools are a common example. Even though it is possible to get dmgr to run with font substitution, it's not very useful when you can't tell what button goes where.

StarNet, the makers of X-Win32, provide some extra fonts for tools including Mentor on their site:

http://www.starnet.com/support/extrafonts.htm

These fonts are intended for X-Win32, but many have used them with other OSes and X servers as well. If you run into problems, you may need to search the web for other options. If you find something useful, feel free to e-mail us at support@cat.pdx.edu, and we will be glad to add it here.


Link

LX Perguntas e Respostas XFree86

Link

Link

LX sites

linuxgazette.com

freshmeat.net


LX XFree86

Aplicativos simples X Consorsium

xlogo
X11perf

LX Site LinuxJournal

Ótimo site de pesquisas e notícias Linux

Link

LX Xinerama

Why do you need Xinerama ? And what is it ? The Xinerama extensions were introduced to the XFree86 system in version 4.0. Xinerama is an extension to XFree86 Release 6 Version 4.0 (X4.0) which allows applications and window managers to use the two (or more) physical displays as one large virtual display.

The beauty of the Xinerama extensions is that they are totally transparent to user space. Previously, applications could only reside on one of the displays and could not be moved between the two. Window managers had to be specially written to support the two displays. With Xinerama, window managers and applications don't have to be specially written to support the larger "Virtual Desktop" which Xinerama creates.


Link

LX Documentação XFree86

Link para documentação do XFree86

LX /proc/net explicado

/proc/net/

This directory provides a comprehensive look at various networking parameters and statistics. Each of the files covers a specific range of information related to networking on the system. Below is a partial listing of these virtual files:


LX Proc detalhado

dentro de cada diretório de processo temos:


link de informações :
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/s1-proc-directories.html


LX visualizar processos (serviços) de quaisquer programas

dentro de /proc, cada pid de processo visto por ps ax tem-se
um diretório que contém seus respectivos arquivos

um bom exemplo é pegar o do servidor X

ps ax |grep X

ir no /proc no seu pid e visualizar o consumo de memória
less status

LX visualizar todos dispositivos

less /proc/devices

LX informações processador

cat /proc/cpuinfo

LX OpenOffice

substitui o =SE do excel

formatar célula e código do formato

[>=7]"aprovado";[RED]"reprovado"

LX ls de diretórios

ls -laF -S |grep dr| less

find -type d (é uma outra solução)


LX descompactar TAR.GZ

tar -xvfz arquivo.tar.gz

LX instalar RPM

rpm -ivh pacote.rpm

LX dd

dd if=/dev/...(origem) of=/dev/...(destino)

LX autofs

o autofs faz a montagem automática de um device

para configurar temos o arquivo /etc/auto.master e /etc/auto.misc

auto.misc

ponto de montagem tipo de fs e permissões device
cd -fstype=iso9660,ro,sync,nodev,nosuid :/dev/cdrom

auto.master

raiz de montagem arquivo de configuração tempo de desconecção
/mnt /etc/auto.misc --timeout 1

startar o serviço

/etc/init.d/autofs start

NC Nat modem SpeedTouch

após =>

bind
application ftp (exemplo no caso ftp)
port ftp (exemplo ftp)
save

This page is powered by Blogger. Isn't yours?