Dış IP’yi öğrenmek

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

$ curl ifconfig.me
$ curl icanhazip.com
$ curl ident.me
$ curl ipecho.net/plain
$ curl whatismyip.akamai.com
$ curl tnx.nl/ip
$ curl myip.dnsomatic.com
$ curl ip.appspot.com
$ curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g' 

History’i Silmek

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Current Session historisini silmek

unset HISTFILE && exit

veya

kill -9 $$

Bütün History’i silmek

history -c && exit
HISTSIZE=0 && exit
rm -f $HISTFILE && unset HISTFILE && exit

İsminin Başında “-” Olan Dosyalarla Çalışmak

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Aşağıdaki komut çalışmayacaktır. Zira -file dosyası bash tarafından lessin parametresi olarak algılanır.

less -file

Bunu aşmak için

less ./-file

touch ./-test

echo "test content to file" > ./-test

cat ./-test

rm ./-test

Cat İle Görünmeyen Karakterleri Görmek!

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Dosyamızı oluşturalım:

printf 'testing\012\011\011testing\014\010\012more testing\012\011\000\013\000even more testing\012\011\011\011\012' > /tmp/testing.txt

Dosyanın içeriği

cat /tmp/testing.txt

testing
		testing
 
more testing
 
        even more testing

Tab karakterini “^I” olarak görmek için

cat -T /tmp/testing.txt

testing
^I^Itesting
 
more testing
^I
  even more testing
^I^I^I

Satır sonlarını “$” olarak görmek

cat -E /tmp/testing.txt

testing$
		testing
                      $
more testing$
 
        even more testing$
			$

Bütün görünmeyen karakterleri görmek için

cat -A /tmp/testing.txt

testing$
^I^Itesting^L^H$
more testing$
^I^@^K^@even more testing$
^I^I^I$

Cat ile dosya oluşturmak

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

# Create file
$ cat > /tmp/temp_file_name.txt
some content
more content
and even more content
<Ctrl-D>
 
# View file content
$ cat /tmp/temp_file_name.txt
some content
more content
and even more content
# Append to file
$ cat >> /tmp/temp_file_name.txt
append content
append more content
append even more content
<Ctrl-D>
 
# View file content
$ cat /tmp/temp_file_name.txt
some content
more content
and even more content
append content
append more content
append even more content

Linux versiyon bilgilerini görmek

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

cat /proc/version
dmesg | grep "Linux version"
lsb_release -a
LSB Version:	:core-4.0-ia32:core-4.0-noarch
Distributor ID:	Fedora
Description:	Fedora release 14 (Laughlin)
Release:	14
Codename:	Laughlin
uname -a

Postgresql’de rastgele sayı oluşturma

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Postgresql random() fonksiyonu ile 0-1 arasında rastgele sayı döner.

5 tane rastgele sayı dönelim:

SELECT random() FROM generate_series(1,5);
      random       
-------------------
 0.595817462075502
 0.350072300527245
 0.989073566626757
 0.700899163261056
 0.940509075298905
(5 ROWS)

Rastgele sayıları 1-100 arasına getirelim

SELECT random() * 99 + 1 FROM generate_series(1,5);
     ?COLUMN?     
------------------
 45.0829070857726
 96.3123500789516
 30.1867960244417
 63.0484761050902
 44.2645903658122
(5 ROWS)

trunc ile sayıları yuvarlayalım

SELECT trunc(random() * 99 + 1) FROM generate_series(1,5);
 trunc 
-------
    21
     6
     2
    57
    58
(5 ROWS)

Şimdi bu işleri yapan bir fonksiyon yazalım

CREATE OR REPLACE FUNCTION get_random_number(INTEGER, INTEGER) RETURNS INTEGER AS $$
DECLARE
    start_int ALIAS FOR $1;
    end_int ALIAS FOR $2;
BEGIN
    RETURN trunc(random() * (end_int-start_int) + start_int);
END;
$$ LANGUAGE 'plpgsql' STRICT;

Şimdi deneyelim

SELECT get_random_number(1, 100); 
get_random_number 
-------------------
                11
(1 ROW)
 
SELECT get_random_number(45, 46);
 get_random_number 
-------------------
                45
(1 ROW)
 
SELECT get_random_number(300, 400);
 get_random_number 
-------------------
               372
(1 ROW)
 
SELECT MIN(get_random_number(100, 1000)), MAX(get_random_number(100, 1000)) FROM generate_series(1,100000);
 MIN | MAX 
-----+-----
 100 | 999
(1 ROW)

Vim Syntax Highlighting Aktivasyonu

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

İlgili “vim-enhanced” paketini kuralım:

yum install vim-enhanced

/etc/profile veya /etc/profile.d/vi-vim.sh veya kullanıcının ~/.bashrc dosyasına alias ekleyelim.

vi .bashrc
...
# User specific aliases and functions
alias vi=vim

vimrc dosyasını düzenleyelim

vi /etc/vimrc 
...
syntax on

İşte sonuç:

vi-vim-syntax-highlighting-560x456

Not: Vi içinde “:syntax on” ile “:syntax off” bu özellik açılıp kapanabilir.

Yum History Kullanımı

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Bütün yum işlerini listele

[root ~]> yum history
### OR ###
[root ~]> yum history list
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
ID     | Login user             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    45 | System <unset>         | 2010-01-18 09:57 | I, U           |   21
    44 | User <username>        | 2010-01-14 15:31 | Install        |    1
    43 | System <unset>         | 2010-01-14 08:13 | Update         |   19
    42 | System <unset>         | 2010-01-13 10:39 | I, U           |   40
    41 | System <unset>         | 2010-01-11 07:59 | Update         |   16
    40 | System <unset>         | 2010-01-08 07:58 | Update         |   38
    39 | System <unset>         | 2010-01-07 08:39 | I, O, U        |   39
    38 | System <unset>         | 2010-01-05 08:23 | O, U           |   18
    37 | User <username>        | 2010-01-04 15:43 | Install        |    1
    36 | System <unset>         | 2010-01-04 07:56 | Update         |   66
    35 | User <username>        | 2009-12-30 10:07 | Install        |    2
    34 | User <username>        | 2009-12-30 10:01 | Update         |   15
    33 | User <username>        | 2009-12-30 08:14 | Install        |   13
    32 | System <unset>         | 2009-12-29 07:52 | I, U           |   26
    31 | System <unset>         | 2009-12-28 08:31 | E, I, U        |   66
    30 | System <unset>         | 2009-12-23 12:11 | Update         |    7
    29 | System <unset>         | 2009-12-22 13:59 | Update         |   36
    28 | User <username>        | 2009-12-21 13:21 | Install        |    1
    27 | System <unset>         | 2009-12-18 14:59 | Update         |   56
    26 | User <username>        | 2009-12-18 08:46 | Install        |    1
history list

ID ile history bilgisine ulaşalım:

[root ~]> yum history info 2
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Transaction ID : 2
Begin time     : Tue Jan 19 15:10:13 2010
Begin rpmdb    : 2431:fe4c2c846fd45c9125fb8ab27542a27b22e0d3df
End time       :            15:10:27 2010 (14 seconds)
End rpmdb      : 2430:2eeb12b0b0f2ef3fcb31b4447b439e76e92e3866
User           : User <username>
Return-Code    : Success
Transaction performed with:
    Installed    rpm-4.7.2-1.fc12.i686
    Installed    yum-3.2.25-1.fc12.noarch
    Installed    yum-plugin-fastestmirror-1.1.24-2.fc12.noarch
Packages Altered:
    Erase        arora-0.10.2-2.fc12.i686
history info

ID ile redo ve undo yapmak

[root ~]> yum history repeat 2
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.cogentco.com
 * livna: rpm.livna.org
[...]
Repeating transaction 2, from Tue Jan 19 15:10:13 2010
    Erase        arora-0.10.2-2.fc12.i686
No package matched to remove
history repeat

[root ~]> yum history undo 2
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
[...]
Undoing transaction 2, from Tue Jan 19 15:10:13 2010
    Erase        arora-0.10.2-2.fc12.i686
Resolving Dependencies
--> Running transaction check
---> Package arora.i686 0:0.10.2-2.fc12 set to be updated
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=================================================================================================================================================================================
 Package                                 Arch                                   Version                                          Repository                                 Size
=================================================================================================================================================================================
Installing:
 arora                                   i686                                   0.10.2-2.fc12                                    updates                                   1.1 M
 
Transaction Summary
=================================================================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)
 
Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
arora-0.10.2-2.fc12.i686.rpm                                                                                                                              | 1.1 MB     00:00     
[...]
Running Transaction
  Installing     : arora-0.10.2-2.fc12.i686                                                                                                                                  1/1 
 
Installed:
  arora.i686 0:0.10.2-2.fc12                                                                                                                                                     
 
Complete!

[root ~]> yum history redo 2
Loaded plugins: dellsysidplugin2, fastestmirror, refresh-packagekit
[...]
Repeating transaction 2, from Tue Jan 19 15:10:13 2010
    Erase        arora-0.10.2-2.fc12.i686
Resolving Dependencies
--> Running transaction check
---> Package arora.i686 0:0.10.2-2.fc12 set to be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=================================================================================================================================================================================
 Package                                Arch                                  Version                                           Repository                                  Size
=================================================================================================================================================================================
Removing:
 arora                                  i686                                  0.10.2-2.fc12                                     installed                                  3.7 M
 
Transaction Summary
=================================================================================================================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)
 
Is this ok [y/N]: y
[...]
Running Transaction
  Erasing        : arora-0.10.2-2.fc12.i686                                                                                                                                  1/1 
 
Removed:
  arora.i686 0:0.10.2-2.fc12                                                                                                                                                     
 
Complete!

Yum ile tek bir depodan paket kurmak

Temmuz 30, 2013 § Yorum yok § Kalıcı bağlantı

Repoları listeleyelim

$ yum repolist
Loaded plugins: dellsysidplugin2, refresh-packagekit
repo id                                                      repo name                                                                        status         
adobe-linux-i386                                             Adobe Systems Incorporated                                                       enabled:     17
fedora                                                       Fedora 12 - i386                                                                 enabled: 15,366
google                                                       Google - i386                                                                    enabled:      4
livna                                                        rpm.livna.org for 12 - i386                                                      enabled:      3
rpmfusion-free                                               RPM Fusion for Fedora 12 - Free                                                  enabled:    383
rpmfusion-free-updates                                       RPM Fusion for Fedora 12 - Free - Updates                                        enabled:    551
rpmfusion-nonfree                                            RPM Fusion for Fedora 12 - Nonfree                                               enabled:    124
rpmfusion-nonfree-updates                                    RPM Fusion for Fedora 12 - Nonfree - Updates                                     enabled:    228
updates                                                      Fedora 12 - i386 - Updates                                                       enabled:  4,587
repolist: 21,263

Google reposundan paket kuralım

$ yum --disablerepo="*" --enablerepo="google" list available
Loaded plugins: dellsysidplugin2, refresh-packagekit
Available Packages
google-chrome-beta.i386                                                          5.0.307.9-39052                                                       google
google-chrome-unstable.i386                                                      5.0.322.2-38810                                                       google
google-desktop-linux.i386                                                        1.2.0-0088                                                            google
picasa.i386

Neredeyim ben!?

Temmuz, 2013 arşivinde geziniyorsun.