-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
Monday, 21 December 2009
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
=======
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
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;
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
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
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
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.

-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.
Friday, 30 October 2009
Astazi am facut:
comenzi utile pentru a vedea mem usage in linux
free
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS ( List processes by mem usage )
ps -euf
top
comenzi utile pentru a vedea spatiu pe hard-disk
df
fdisk -l
free
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS ( List processes by mem usage )
ps -euf
top
comenzi utile pentru a vedea spatiu pe hard-disk
df
fdisk -l
Monday, 26 October 2009
Astazi am facut:
pentru load balance pe doua cai. Rutele apar in tabela de rutare in functie de raspunsul la un ping.
track 1 rtr saa-id1 reachability
delay down 15 up 10
!
track 2 rtr saa-id2 reachability
delay down 15 up 10
ip sla saa-id1
icmp-echo IP-de-test1
ip sla schedule 1 life forever start-time now
ip sla saa-id2
icmp-echo IP-de-test2
ip sla schedule 2 life forever start-time now
ip route 0.0.0.0 0.0.0.0 Provider1 track 1
ip route 0.0.0.0 0.0.0.0 Provider2 track 2
track 1 rtr saa-id1 reachability
delay down 15 up 10
!
track 2 rtr saa-id2 reachability
delay down 15 up 10
ip sla saa-id1
icmp-echo IP-de-test1
ip sla schedule 1 life forever start-time now
ip sla saa-id2
icmp-echo IP-de-test2
ip sla schedule 2 life forever start-time now
ip route 0.0.0.0 0.0.0.0 Provider1 track 1
ip route 0.0.0.0 0.0.0.0 Provider2 track 2
Friday, 23 October 2009
Wednesday, 21 October 2009
astazi am facut:
de obicei cand faci ssh pe o statie iti apare ceva de genul
[root@localhost]# ssh IP_statie
The authenticity of host 'IP_statie' can't be established.
RSA key fingerprint is 59:99:4d:2e:4e:55:53:b8:56:80:05:f6:0a:09:81:60.
Are you sure you want to continue connecting (yes/no)?
Pentru ca aceasta interogare sa nu mai apara la fiecare noua conectare pe o statie(daca din anumite motive...nu din motive de siguranta:) se doreste asta, se poate face:
[root@localhost]#cd /etc/ssh/ssh_config
si la inceputul fisierului ssh_config se pune
Host *.*.*.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
In loc de *.*.*.* se poate pune orice clasa de ip-uri pentru care se doreste ca aceasta autentificare sa nu se faca (ecemplu 192.168.0.*)
[root@localhost]# ssh IP_statie
The authenticity of host 'IP_statie' can't be established.
RSA key fingerprint is 59:99:4d:2e:4e:55:53:b8:56:80:05:f6:0a:09:81:60.
Are you sure you want to continue connecting (yes/no)?
Pentru ca aceasta interogare sa nu mai apara la fiecare noua conectare pe o statie(daca din anumite motive...nu din motive de siguranta:) se doreste asta, se poate face:
[root@localhost]#cd /etc/ssh/ssh_config
si la inceputul fisierului ssh_config se pune
Host *.*.*.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
In loc de *.*.*.* se poate pune orice clasa de ip-uri pentru care se doreste ca aceasta autentificare sa nu se faca (ecemplu 192.168.0.*)
Tuesday, 20 October 2009
Astazi am facut:
un script in shell care face telnet/sau ssh pe un numar de statii/routere si da un set de comenzi.
Scriptul expect_telnet
#!/usr/bin/expect -f
log_user 0. ### dace se doreste ca scriptul sa mearga fara echo, sa nu afiseze
set timeout 20 ### daca merge ceva gresit scriptul se opreste dupa 20 de secunde
set address [lindex $argv 0] ###seteaza ca argument pentru
scriptul expect_telnet IP Address
set username [lindex $argv 1] ## seteaza argument pentru
expect_telnet username
set password [lindex $argv 2] ## seteaza argument pentru
expect_telnet password
set enable "enable"
spawn telnet ${address}
expect "Username:"
send -- "${username}\r"
expect "Password:"
send -- "${password}\r"
expect "*> "
send -- "$enable\r"
expect "Password: "
send -- "${password}\r"
## aici se trimit folosind send si expect comenzile ce se doresc da pe routere
send -- "exit\r" ###la final se iese de pe router
Pentru ca acest script sa poate fii executat trebuie definit ca executabil
chmod u+x expect_telnet
Scriptul in bash care apeleaza scriptul expect_telnet si care se conecteaza pe un numar de routere cu ip-uri cunoscute( ip-urile sunt salvate in prealabil in ip_host.txt)
Scriptul comennzi_on_host
#!/bin/bash
nr_hosti=`sed -n '$=' ip_host.txt`
increment=1
usr=user
psw=parola
while [ $increment -le $nr_hosti ] ; do
valoare_ip=`head -$increment ip_host.txttail -1`
./expect_telnet "$valoare_ip" "$usr" "$psw"
increment=$(($increment+1))
done
Pentru ca acest script sa poate fii executat trebuie definit ca executabil
chmod u+x comennzi_on_host
Scriptul expect_telnet
#!/usr/bin/expect -f
log_user 0. ### dace se doreste ca scriptul sa mearga fara echo, sa nu afiseze
set timeout 20 ### daca merge ceva gresit scriptul se opreste dupa 20 de secunde
set address [lindex $argv 0] ###seteaza ca argument pentru
scriptul expect_telnet IP Address
set username [lindex $argv 1] ## seteaza argument pentru
expect_telnet username
set password [lindex $argv 2] ## seteaza argument pentru
expect_telnet password
set enable "enable"
spawn telnet ${address}
expect "Username:"
send -- "${username}\r"
expect "Password:"
send -- "${password}\r"
expect "*> "
send -- "$enable\r"
expect "Password: "
send -- "${password}\r"
## aici se trimit folosind send si expect comenzile ce se doresc da pe routere
send -- "exit\r" ###la final se iese de pe router
Pentru ca acest script sa poate fii executat trebuie definit ca executabil
chmod u+x expect_telnet
Scriptul in bash care apeleaza scriptul expect_telnet si care se conecteaza pe un numar de routere cu ip-uri cunoscute( ip-urile sunt salvate in prealabil in ip_host.txt)
Scriptul comennzi_on_host
#!/bin/bash
nr_hosti=`sed -n '$=' ip_host.txt`
increment=1
usr=user
psw=parola
while [ $increment -le $nr_hosti ] ; do
valoare_ip=`head -$increment ip_host.txttail -1`
./expect_telnet "$valoare_ip" "$usr" "$psw"
increment=$(($increment+1))
done
Pentru ca acest script sa poate fii executat trebuie definit ca executabil
chmod u+x comennzi_on_host
Subscribe to:
Posts (Atom)