Monday, 21 December 2009

Astazi am facut - Disable SElinux

-Security-Enhanced Linux (SELinux) is a Linux feature that provides a mechanism for supporting access control security policies

In fisierul /etc/selinux/config se modifica

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

din enforcing se pune disabled

Thursday, 17 December 2009

Astazi am facut

Disable GUI in linux
Change the default run level in /etc/inittab to 3

id:3:initdefault:

Enable GUI in linux
Change the default run level in /etc/inittab to 5

id:5:initdefault:


======
mount/unmount cdrom

mount /dev/cdrom /mnt

umount /dev/cdrom

=======

Wednesday, 16 December 2009

Astazi am facut

oprire toate procesele php /toate procesele java ( atentie pkill kill every process with the text string "php" or "java" in it, including not only php/java-sessions

pkill php

pkill java


Crontab in linux


.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed

Astazi am facut

Comenzi utile in mysql (2)

Pentru a creea o baza de date

mysql> CREATE DATABASE name_database;

Creare MySQL user accounts si grant drepturi pentru accounts

mysql> GRANT ALL PRIVILEGES ON name_database.* TO username@localhost IDENTIFIED BY 'password';

Daca se modifica manual tabelul cu grant trebuie executat

mysql> FLUSH PRIVILEGES;

Pentru stergere baza de date

mysql> drop database name_databse;

Pentru a sterge un tabel

mysql> drop table if exists 'nume_tabel';

Creare user nou

mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Tuesday, 15 December 2009

Astazi am facut

Comenzi utile in mysql

Pentru conectare la o baza de date

[root@localhost ~]# mysql namedatabase -u username_database -p password_database

Pentru a vedea bazele de date

mysql> show databases;

Pentru a vedea tabelele dintro baza de date

mysql> show tables;

Pentru a vedea coloanele intr-un tabel

mysql> show columns from nume_tabel;

Pentru a vedea continutul unui tabel

mysql> select * from nume_tabel;

Pentru a vedea o coloana dintr-un tabel cu continutul ei

mysql> select nume_tabel.nume_coloana from nume_tabel;

Pentru a vedea continutul unui tabel care indeplinseste anumite conditii

mysql> select * from nume_tabel where cond1 or cond2 and cond3;

Modificarea anumitor celule dintr-un tabel

mysql> update nume_tabel set nume_tabel.nume_coloana where cond1 ....

Adaugarea unei linii noi in tabel

mysql>insert into nume_tabel (nume_coloana1, nume_coloanax, nume_coloanaN...) values ( 'valoare1', 'valoare2'...)

Creearea unei baze de date

mysql> create nume_database;

Verificare baza de date

[root@localhost /]# mysqlcheck nume_database

Reparare baza de date

[root@localhost /]# mysqlcheck -r nume_database

Astazi am facut

Pentru aflare cu snmpget doar hostname statie

snmpwalk -c public -v 2c ip-ul-routerului system.sysName.0|sed 's/SNMPv2-MIB::sysName.0 = STRING: //'

=============

Pentru a vedea clock intr-un anumit format

date +%Y-%m-%d-%M-$S

======

fping -a -q -g 192.168.0.0/24

ping un range de ip-uri

pentru o statistica fping -s

Astazi am facut

Adauga user in linux

useradd newuser
passwd newuser

Setare user in linux cu drepturi de root

in /etc/passwd

newuser :x:0:502::/home/newuser:/bin/bash

Stergere user

userdel newuser

userdel -r newuser ( sterge si home directory)

Modificare user

usermod

•-d home directory
•-s starting program (shell)
•-p password
•-g (primary group assigned to the users)
•-G (Other groups the user belongs to)


=========================
Afisarea doar cuvant care incepe cu 192.x.x.x din fisier text dat

grep -oh "\w*192.\w*.\w*.\w*" fisier.txt

pentru a afisa doar civintele unice
|sort|unique -c

Friday, 4 December 2009

Astazi am facut IPv6

IPv6 Global Unicast Address Format

-Global Routing Prefix: The network ID or prefix of the address, used for routing. The first three bits are “001” to indicate a unicast address.

-Subnet Identifier: A number that identifies a subnet within the site.

-Interface ID: The unique identifier for a particular interface (host or other device). It is unique within the specific prefix and subnet.