Configure Static IP Address on Linux

It is possible to configure a Linux network interface in multiple ways.

This is the one that might be simpler for beginners.

sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0;
sudo route add default gw 192.168.1.1 eth0;

ifconfig is an application that allows to configure a network interface.

In the above example sudo is the command that allows us to elevate the user privileges to configure the network interface.

eth0 is the available interface, the list of available interfaces can be listed using the command ifconfig.

192.168.1.10 is an example of a IP address it can be what you require to configure your network.

netmask identifies the subnet mask for the network that you are configuring. If you not sure what should be check the configuration settings of your router.

the second configuration line is the configuration of the default gateway. To achieve efficiency in getting out of the local network it is required to provide that information to the computer.

The gateway setting is the exit point of the local network to other networks. Route add is the command that it is used to add the route.

Default identifies that this is a default route. If no other route is inserted in the routing table the computer will use this route to speak with the remaining networks.

The address 192.168.1.1 is the ip address of the gateway normally the address of the router in a local network.

The eth0 is the local interface that will be used to reach the gateway.

How to Find Files With setuid Permissions

find directory -user root -perm -4000 -exec ls -ldb {} \; >/tmp/filename
  • find directory -> Checks all mounted paths starting at the specified directory, which can be root (/), sys, bin, or mail.
  • -user root -> Displays files owned only by root.
  • -perm -4000 -> Displays files only with permissions set to 4000.
  • -exec ls -ldb -> Displays the output of the find command in ls -ldb format.
  • >/tmp/filename -> Writes results to this file.

Como activar o SSH no backtrack

Para activar o ssh no backtrack temos de primeiro criar a chave de ssh.
Para criar a chave podemos usar o seguinte comando:
sshd-generate
Depois deste comando podemos iniciar o ssh com o seguinte comando:
/etc/init.d/ssh start
Ou então para inicializar automáticamente na sequencia de boot podemos utilizar o seguinte comando:
update-rc.d ssh defaults

Activar um interface no linux

Para inicializar um interface especifico no linux apenas temos de escrever o seguinte comando:

ifup eth0

Podemos substituir o eth0 pelo interface que pretendemos inicializar.
Atenção que temos de garantir que ele existe na lista de interfaces configurada no nosso sistema.

Colocar o interface de rede a funcionar BT4R2

Para iniciar a rede no backtrack apenas temos de correr o seguinte comando:

/etc/init.d/networking start

Este comando vai tentar inicializar todas as placas de rede que estão configuradas no ficheiro /etc/network/interfaces.

Por norma são:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto ath0
iface ath0 inet dhcp
auto wlan0
iface wlan0 inet dhcp

Se não temos ou se não queremos nenhuma destas placas então apenas temos de comentar ou remover a linha que não queremos.
Se for necessário criar um ip estático apenas temos de o configurar no ficheiro /etc/network/interfaces
Ex:

auto eth0
iface eth0 inet static
address 192.168.0.1

netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

Temos de garantir que temos um servidor de nomes configurado no ficheiro /etc/resolv.conf
Ex:

nameserver 192.168.0.x

Se por algum motivo tivermos como objectivo iniciar as placas de rede logo no boot do backtrack podemos sempre correr este comando como root.

update-rc.d networking defaults

Como instalar um novo disco no Ubuntu…

Decidi instalar um novo disco no meu servidor ubuntu que tenho em casa.
Como não uso modo gráfico aqui fica a forma de instalar o novo disco em modo consola.

Primeiro temos de ver como o SO reconhece o disco.

sudo lshw -C disk

Vamos obter um output parecido com este:

*-cdrom
description: SCSI CD-ROM
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/cdrom
logical name: /dev/scd0
logical name: /dev/sr0
capabilities: audio
configuration: status=open
*-disk
description: SCSI Disk
physical id: 0.0.0
bus info: scsi@2:0.0.0
logical name:
/dev/sda
size: 8GiB (8589MB)
capabilities: partitioned partitioned:dos
configuration: signature=00032e24

Aqui o que interessa é apenas que o disco é reconhecido pelo SO como sendo /dev/sda

Agora que já sabemos qual é o disco rigido criamos a partição.

sudo fdisk /dev/sda
Opções para criar a partição:

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Eu escolhi a opção n
respondi ás perguntas e depois escolhi a opção W.
As perguntas são sobre o tipo de partição e isso já depende do que queremos.
Depois de criada a partição há que formata-la.
Eu optei por um file system de Linux:
sudo mkfs -t ext3 /dev/sdb1
Também poderia optar por FAT32 para o ter reconhecido tanto em ambientes Windows como Linux.

Agora temos de criar o nosso mount point
sudo mkdir /media/mountpoint em que mountpoint é o nome que eu entender.
Para fazer com que este mount point comece a funcionar logo no arranque temos de editar o fstab e colocar a seguinte entrada:

(editar o ficheiro) sudo vi /etc/fstab
(Adicionar a entrada) /dev/sdb1 /media/mountpoint ext3 defaults 0 2

Neste caso a entrada é partição Linux ext3 🙂

Agora para activar a nova drive ou fazemos reboot ou simplesmente escrevemos o seguinte comando:
sudo mount -a