lunes, 17 de septiembre de 2012

Kernel Modules 3 commands.

How to list modules in the linux Kernel

lsmod 


More deep information on a specific on a particular modules

modinfo

Find out Linux kernel drivers/modules being used by hardware devices on your system

apt-get install pcutils 

lspci -k 

martes, 11 de septiembre de 2012

viernes, 10 de agosto de 2012

iptraf & tcpdump

The iptraf command is interactive colorful IP LAN monitor. It is an ncurses-based IP LAN monitor that generates various network statistics including TCP info, UDP counts, ICMP and OSPF information, Ethernet load info, node stats, IP checksum errors, and others. It can provide the following info in easy to read format:
  1. Network traffic statistics by TCP connection
  2. IP traffic statistics by network interface
  3. Network traffic statistics by protocol
  4. Network traffic statistics by TCP/UDP port and by packet size
  5. Network traffic statistics by Layer2 address
Exercise : Ip Traffic Monitor ---> eth1 [ethernet] network interface  
----------------------------------------------------------------------------------------------------------------------------------

The tcpdump is simple command that dump traffic on a network. However, you need good understanding of TCP/IP protocol to utilize this tool. For.e.g to display traffic info about DNS, enter:

# tcpdump -i eth1 'udp port 53'

Packages were kept back

Sometimes you'll run 'apt-get upgrade' in Debian or Ubuntu and you'll get a message stating that "the following packages have been kept back" which is annoying but here is a way to get around it.


The reason the packages were kept back is because they violate the below constraint. "dist-upgrade" is the correct method.

From the apt-get man page regarding: "`upgrade` under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version."

"dist-upgrade intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages."


Solution 1 : as root  apt-get dist-upgrade


Solution 2 : apt-get install [packages that are keep back]

miércoles, 8 de agosto de 2012

IPTABLES

nmap being used by Trinity in The Matrix to detect ssh running on a vulnerable node before launching an attack on the sshv1 CRC32 flaw and gaining root to shut down the power grid.



Rule1 : Target REJECT do with a TCP-RESET

-A INPUT -i eth0 -p tcp -m tcp --dport 443 -j REJECT --reject-with tcp-reset

result : 443/tcp closed https

martes, 7 de agosto de 2012

nmon performance: A free tool to analyze AIX and Linux performance

debian apt-get install nmon 
http://www.cyberciti.biz/faq/nmon-performance-analyzer-linux-server-tool/

Java Nmon Analyser

http://sourceforge.net/projects/jnmonanalyser/files/



 

jueves, 26 de julio de 2012

Fetch External Repositories on Ubuntu How to

DesdeUbuntu Karmic Koala disponemos de una nueva herramienta para añadir repositorios PPA de Launchpad de una forma mucho más sencilla, copiando una línea mucho más simple que además descarga y añade automáticamente su clave GPG. Puede hacerse desde el terminal, ejecutando el siguiente comando: 

sudo add-apt-repository ppa:nombre_del_ppa

Además, este nuevo sistema no añade la línea completa al fichero /etc/apt/sources.list sino que lo crea con su propio fichero en el directorio sources.list.d, lo cual suele ser mucho mejor para el mantenimiento del sistema, tener todos los repositorios en ficheros diferentes.

The program 'add-apt-repository' is currently not installed.  You can install it by typing:

apt-get install python-software-properties

----- /usr/bin/add-apt-repository

----- /usr/bin/apt-add-repository


Free open source project hosting. Repository based on the Bazaar VCS.

 https://launchpad.net/


https://help.launchpad.net/Packaging/PPA


How do I update Ubuntu Linux softwares.

Using apt-get command line tool

apt-get is the command-line tool for handling packages. You can use following command options:

=> apt-get update : Update is used to resynchronize the package index files from their sources via Internet.

=> apt-get upgrade : Upgrade is used to install the newest versions of all packages currently installed on the system.

=> apt-get install package-name : install is followed by one or more packages desired for installation. If package is already installed it will try to update to latest version.

=> To upgrade individual software called foo type command: apt-get install foo


More info @ https://help.ubuntu.com/11.04/serverguide/package-management.html 


More info @ http://www.guia-ubuntu.org/index.php?title=A%C3%B1adir_repositorios_externos 

jueves, 19 de julio de 2012

chattr - change file attributes on a Linux file system

This command can be helpful, when set to use Public Google DNS on your computer.

If your ISP assigned you DNS, it will request every time your computer boots.

chattr - change file attributes on a Linux file system

The  operator `+' causes the selected attributes to be added to the existing attributes of the files; `-' causes them to be removed; and `=' causes them to be the only attributes that the files have.

immutable (i)

A file with the `i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can  be  written to the file.  Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

So you can block your /etc/resolv.conf file as root user.

chattr +i /etc/resolv.conf  


unlock

chattr -i /etc/resolv.conf

More information on chattr man page.

miércoles, 18 de julio de 2012

Ubuntu 12.04 to feature extended support period for desktop users





http://www.canonical.com/content/ubuntu-1204-feature-extended-support-period-desktop-users

Understand command sudo su -

Why if I typed the three commands sudo su - with my user after a passwords is ask, I became root user ?

sudo onlfy work if the user is permit to use this app; from /etc/sudoers file.

su Invoked without a username, su defaults to becoming the superuser.
 
- The optional argument - may be used to provide an environment similar to what the user would expect had the user logged in directly.


man pages

sudo, sudoedit ---> execute a command as another user.

su ---> change user ID or become superuser

martes, 17 de julio de 2012

Talk over the console

First install talk & talkd
apt-get install talk talkd 


developer@ubuntu:~$ mesg 
mesg is n 
to change mesg
developer@ubuntu:~$ mesg y

mesg is y
Talk on a LAN network 



user bob wants to chatt with sawar 
talk sawar@172.16.1.108 

At host sawar the follow is prompt

Message from Talk_Daemon@server1 at 22:44 ...    
talk: connection requested by bob@172.16.1.101. 
talk: respond with:  talk bob@172.16.1.101  



Respond with talk bob@172.16.1.101   

Done. - 

Temporarily Changing User Identity with the su Command

A popular misconception is that the su command is short for super-user; it really just means substitute user. An important but often overlooked distinction is that between su and su -. In the former instance, you become that user but keep your own environmental variables (such as paths). In the latter, you inherit the environment of that user.

This is most noticeable when you use su to become the super-user, root. Without appending the -, you do not inherit the path variable that includes /bin or /sbin, so you must always enter the full path to those commands when you just su to root.



https://help.ubuntu.com/community/RootSudo

lunes, 16 de julio de 2012

Install JAVA by hand

1. Download jdk-6u33-linux-i586.bin

http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. mkdir opt {java/latest}


3. Unpack sh jdk-6u33-linux-i586.bin --> /opt/java/latest


4. Append Java bin to your PATH

   export PATH=/opt/java/latest/bin:$PATH


5. Set JAVA_HOME

   export JAVA_HOME=/opt/java/latest/

sábado, 7 de julio de 2012

Fibertel : entrie

addr: 190.18.173.8      201.231.68.245          201.231.69.249    190.18.171.241


http://dnsknowledge.com/tutorials/debian/bind9/linux-set-bind9-caching-dns-nameserver

iptables -I INPUT -p udp -m udp --dport 53 -j ACCEPT

iptables -I INPUT -p tcp -m tcp --dport 53 -j ACCEPT

install bind9 should I open port 53 on iptables ???? like this ????

##################################################################################

http://dnsknowledge.com/tutorials/debian/bind9/linux-set-bind9-caching-dns-nameserver

# iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 53 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 53 -j ACCEPT


tcpdump -n -s 1500 -i eth1 udp port 53


Erase from iptables *filter table

-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT

martes, 3 de julio de 2012

Using Google Public DNS


When you use Google Public DNS, you are changing your DNS "switchboard" operator from your ISP to Google Public DNS.
In most cases, the IP addresses used by your ISP's domain name servers are automatically set by your ISP via the Dynamic Host Configuration Protocol (DHCP). To use Google Public DNS, you need to explicitly change the DNS settings in your operating system or device to use the Google Public DNS IP addresses. The procedure for changing your DNS settings varies according to operating system and version (Windows, Mac or Linux) or the device (computer, phone, or router). We give general procedures here that might not apply for your OS or device; please consult your vendor documentation for authoritative information.
Note: We recommend that only users who are proficient with configuring operating system settings make these changes.


https://developers.google.com/speed/public-dns/docs/using

jueves, 28 de junio de 2012

linux users unknow

--- > rtkit:x:120:130:RealtimeKit,,,:/proc:/bin/false

As the package description says, "Realtime Kit enables realtime scheduling for the PulseAudio daemon". This is an entry for the user running the RealtimeKit daemon.


---- > usbmuxd


A socket daemon to multiplex connections from and to an iPhone or iPod Touch.


lunes, 25 de junio de 2012

HTTP Cloning : Github

You can now clone public repositories hosted on GitHub over HTTP. This is very slow and should only be used if the git port (9418) is blocked due to a firewall or other tomfoolery.


https://github.com/blog/92-http-cloning 


How to Setup behind a proxy

http.proxy=http://172.16.0.1:3128
https.proxy=https://172.16.0.1:3128
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.editor=vim
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/yours/yours.git
branch.master.remote=origin
branch.master.merge=refs/heads/master


domingo, 24 de junio de 2012

chmod - change file mode bits

If we do ls on a GNU/linux box we will obtain permission on files. 



u+g+o u = user g = group  o = others


The octal method for setting the permissions makes use of the octal value for each permission:

    r = 4 or 0
    w = 2 or 0
    x = 1 or 0
    s = 4 (for user) or 0 (or unspecified)
    s = 2 (for group) or 0 (or unspecified)
    t = 1 or 0 (or unspecified)

The summation of each permission, values 0-7, represent the permission for each of the “ugo.” The following examples show how to represent the permission values in octal format:

    rwx = 7 (r+w+x = 4+2+1)
    r-x = 5 (r+0+x = 4+0+1)
    rw- = 6 (r+w+0 = 4+2+)
    r– =  4 (r+0+0 = 4+0+0)

When specifying in octal you must explicitly set the values for all three otherwise you results apply to the right most group and work towards the left:

    chmod 7 file = ——rwx on file
    chmod 27 file = —-w-rwx on file


domingo, 13 de mayo de 2012

Make

Because compiling projects can be such a complicated and repetitive process, a good IDE provides a means to abstract, simplify, and even automate software builds. Unix and its descendents accomplish this process with a Makefile, a prescribed recipe in a standard format for generating executable files from source and object files, taking account of changes to only rebuild 
what’s necessary to prevent costly recompilation.

Anatomy of a Makefile

The general pattern of a Makefile is a list of variables and a list of targets, and the sources and/or objects used to provide them. Targets may not necessarily be linked binaries; they could also constitute actions to perform using the generated files, such as install to instate built files into the system, and clean to remove built files from the source tree.

It’s this flexibility of targets that enables make to automate any sort of task relevant to assembling a production build of software; not just the typical parsing, preprocessing, compiling proper and linking steps performed by the compiler, but also running tests (make test), compiling documentation source files into one or more appropriate formats, or automating deployment of code into production systems, for example, uploading to a website via a git push or similar content-tracking method.

An example Makefile for a simple software project might look something like the below:




CC=gcc

#The basic makefile is composed of:
#target: dependencies
#[tab] system command


hello.o: hello.c
        $(CC)  hello.c -o hello.o

install: hello.o
        cp hello.o /bin

If you run

make
 
this program will look for a file named makefile in your directory, and then execute it.

If you have several makefiles, then you can execute them with the command:

make -f MyMakefile


http://mrbook.org/tutorials/make/

 

 

 

 

sábado, 12 de mayo de 2012

GCC G++

GCC is a very mature GPL-licensed collection of compilers, perhaps best-known for working with C and C++ programs. Its free software license and near ubiquity on free Unix-like systems like Linux and BSD has made it enduringly popular for these purposes, though more modern alternatives are available in compilers using the LLVM infrastructure, such as Clang.




"The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, Ada, and Go, as well as libraries for these languages (libstdc++, libgcj,...). GCC was originally written as the compiler for the GNU operating system. The GNU system was developed to be 100% free software, free in the sense that it respects the user's freedom."


To install the gcc and g++ compilers, you will need the build-essential package. This will also install GNU make.


  • dpkg-dev (>= 1.13.5)
    Debian package development tools
  • g++ (>= 4:4.4.3)
    GNU C++ compiler
  • gcc (>= 4:4.4.3)
    GNU C compiler
  • libc6-dev
    Embedded GNU C Library: Development Libraries and Header Files
    or libc-dev
    virtual package provided by libc6-dev
  • make
    An utility for Directing compilation.

viernes, 11 de mayo de 2012

a.out

 Steps in Developing a Program in C

 $ touch       hello.c

#include <stdio.h>

main()
{
printf("Hello, world!\n");
return 0;
}


 $ gcc hello.c

  a.out -- > file create

--------------------------------------------
Steps in Developing a Program in C++


  $ touch       hello.cpp



#include<iostream>
 using namespace std;

int main()
{
    cout << "First c++ program!";
    return 0;
}


  $ g++ hello.cpp

  a.out -- > file create




a.out remains the default output file name for executables created by certain compilers/linkers when no output name is specified, even though these executables are no longer in the a.out format.


These files can be found here

https://www.dropbox.com/sh/5ubehsnaufd8d0w/mJsOKVg4Th/code%20files

http://en.wikipedia.org/wiki/A.out_%28file_format%29




jueves, 10 de mayo de 2012

kernel [vmlinuz] and initrd image [initrd.img]

  • vmlinuz- is the "linux kernel"

  • initrd is the "initial ramdisk"
It is enough files stored in a ramdisk to store needed drivers . You need the drivers so that the kernel can mount / and kick off init.


Remove old linux kernel entries from GRUB2 


 GRUB 2 has three main parts:
  •     /etc/default/grub - the file containing GRUB 2 menu settings.
  •     /etc/grub.d/ - the directory containing GRUB 2 menu creating scripts.
  •     /boot/grub/grub.cfg - the GRUB 2 configuration file, not editable.

Steps 


1. /etc/grub.d/10_linux Identifies kernels on the root device for the operating system in use and creates menu entries.


Note: All kernels residing in the boot folder are included in this section. If you don't want all your old kernels to appear in the menu, remove the kernels from the /boot folder. 


2. Run grub-mkconfig


3. update-grub

Shell scripts


What are they ?

Shell scripts, which are text files containing shell commands.


So-called scripting languages are usually interpreted. A regular compiled program, the interpreter, reads the program, translates it into an internal form, and then executes the program

Why use a shell script ?

The advantage to scripting languages is that they often work at a higher level than compiled languages, being able to deal more easily with objects such as files and directories. The disadvantage is that they are often less efficient than compiled languages. 

Usually the tradeoff is worthwhile; it can take an hour to write a simple script that would take two days to code in C or C++, and usually the script will run fast enough that performance won't be a problem. Examples of scripting languages include awk, Perl, Python, Ruby, and the shell.

Because the shell is universal among Unix systems, and because the language is standardized by POSIX, shell scripts can be written once and, if written carefully, used across a range of systems. Thus, the reasons to use a shell script are:
  
Simplicity
The shell is a high-level language; you can express complex operations clearly and simply using it.

Portability
By using just POSIX-specified features, you have a good chance of being able to move your script, unchanged, to different kinds of systems.

Ease of development
You can often write a powerful, useful script in little time.

Classic Shell Scripting By Nelson H.F. Beebe, Arnold Robbins


  • La primera linea de un script debe comenzar con los caracteres #!, seguidos del nombre del interprete de comandos.
  • Un script, como cualquier otro archivo que se puede ejecutar, necesita tener permiso de ejecucion.
                                         $ chmod 755 / chmod +x  file.sh
  • Cuando el Unix intenta ejecutar algun archivo, lee los primeros dos caracteres , que en el caso de los scripts son #!, y al saber que el archivo es un script,el Unix continuara leyendo la linea  para encontrar el programa que  servira de interprete del script.

DKMS

Source is a wonderful thing. Merged module source in the kernel tree is even better.

The dynamic kernel module support (DKMS) framework  . The DKMS framework is basically a duplicate tree outside of the kernel tree that holds module source and compiled module binaries.

The DKMS executable takes care of building and installing the module for any kernel users may have on their systems, eliminating the kernel catch-up game.

First, using DKMS for a module requires that the module source be located on the user's system and that it be located in the directory /usr/src/(module))-((module-version))/. In addition, a dkms.conf file must exist with the appropriately formatted directives within this configuration file to tell DKMS such things as where to install the module and how to build it.






miércoles, 9 de mayo de 2012

Shell

echo $SHELL

  • Un shell es un interprete de comandos, es decir, el shell lee comandos del teclado y los ejecuta.  


  • A number of important shells have appeared over time
     




Hint: Ubuntu makes /bin/sh a symlink to /bin/dash.

Programming Languages  >> http://hyperpolyglot.org/ 

$VAR y ${VAR}

#!/bin/sh
INGREDIENTE=azucar
echo Hay pan $INGREDIENTEado
echo Hay pan ${INGREDIENTE}ado

Variables de entorno:linux

Variables de entorno

A continuacion tenemos la lista de variables reservadas por el interprete de comandos mas comunes. Todas ellas tienen un significado especial para el mismo, algunas de ellas solo se pueden leer, a otras se le asignan ciertos valores automaticamente y algunas pierden su significado si le cambiamos los valores que tienen por defecto.

http://www.linux-es.org/node/107

server2

Ubuntu 9.10 Karmic Koala



Creates patches using diff

Do.  
 
diff -u old.sh new.sh > file.patch
 
example- file.patch 
 
 
--- old.sh      2012-05-09 20:10:05.596606469 -0300
+++ new.sh      2012-05-09 20:12:24.765286827 -0300
@@ -8,4 +8,13 @@

 echo -n "Your full name is:" $nombre

+echo
+
+echo -n " Now tell me your age :"
+
+read age 
+
+
+echo -n " Your age is : " $age
+
 echo
 
 Apply the patch
 
$ patch -p1 old.sh < file.patch 
patching file old.sh

 Your comments are welcome.
 

Tutorial: Puppet 2.7 Install on Ubuntu

Puppet a configuration management tool. 





dropbox: https://www.dropbox.com/sh/5ubehsnaufd8d0w/L37GsWleDR/Tutorial_0.1.pdf


 Your comments are welcome.