15 Şubat 2018 Perşembe

yum komutu

Giriş
Centos, Redhat, Fedora yum kullanır. Repository dosyaları
/etc/yum.repos.d/
dizinindeki repo uzantılı dosyalar.

upgrade seçeneği
Şöyle yaparız.
sudo yum upgrade
sudo yum install jq
sudo yum clean all
-y seçeneği
Açıklaması şöyle.
-y, --assumeyes Assume yes; assume that the answer to any question which would be asked is yes. Configuration Option: assumeyes See: https://linux.die.net/man/8/yum
Şöyle yaparız.
yum -y install xxx

14 Şubat 2018 Çarşamba

vlc komutu

Kurulum
Şöyle yaparız
sudo snap remove vlc

sudo apt update && sudo apt install vlc
Örnek
Bat dosyasında şöyle yaparız
start /min vlc -vvv screen:// -screen-fps=30 
  -sout#{vcodec=h264, scale=Auto, acodec=none}:sout-keep

dpkg-deb komutu

Giriş
3 çeşit temel Linux sistemi var.
1. Debian : Debian sistemler apt-get komutunu kullanır. Bu komut altta dpkg komutunu kullanır
2. SUSE : SUSE sistemler zypper komutunu kullanır. Bu komut altta rpm komutunu kullanır
3. Fedora : Fedora sistemler yum komutunu kullanır. Bu komut altta rpm komutunu kullanır

-f seçeneği
deb dosyasının sürümünü gösterir. Şöyle yaparız.
dpkg-deb -f package.deb Version
dpkg-deb --field package.deb Version
-I seçeneği
deb dosya hakkınd bilgi verir. Şöyle yaparız.
dpkg-deb -I package.deb
dpkg-deb --info package.deb

4 Şubat 2018 Pazar

bash kodlama - history built-in komutu

Giriş
Oturum (session) kapandıktan sonra komutlar şu dosyaya yazılır.
~/.bash_history
Aslında bash içinde iki tane history belleği vardır. Açıklaması şöyle
Your bash history consists of two "histories", not one. One of these histories is stored in a file - its size/depth is governed by the parameter HISTFILESIZE. The other history is cached in memory - its size is governed by the parameter HISTSIZE.
Komutlar önce session'daki belleğe yazılır. Eğer bu bellek yetmezse, taşan komutlar dosyaya yazılır. Açıklaması şöyle. Bu komut session history içindir. 
The reason for two histories is that one is associated with each shell session (HISTSIZE), while the other history is a file ~/.bash_history that is "permanent", and eventually receives the session histories when they overrun their max depth, or when the session is terminated. 
En Komutlar
En son 10 komutu görmek için şöyle yaparız.
history 10 > ~/Desktop/History.txt
-c seçeneği
session history listesini silmek içindir.
Örnek
Şöyle yaparız
$ history -cw
-d seçeneği
Belli bir satırı tarihçeden silmek için şöyle yaparız.
history -d ROW#
Diğer
Komut tarihçeye dahil olması istersek boşluk karakteri ile başlarız. Şöyle yaparız.
$ echo test
test
$ history | tail -n2
 3431  echo test
 3432  history | tail -n2
$ echo test2
test2
$ history | tail -n2
 3431  echo test
 3432  history | tail -n2
Boşluk karakteri ~/bash.rc dosyasında atanıyor.
HISTCONTROL=ignoreboth
Açıklaması şöyle.
HISTCONTROL
A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespacelines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand for ignorespace and ignoredups.

30 Ocak 2018 Salı

ldd komutu

Giriş
ldd komutu bir uygulama tarafından yüklenen shared object'leri gösterir. Açıklaması şöyle.
For ldd, a binary is statically linked if it has no DT_NEEDED symbols, i.e. no undefined symbols.
Örnek
date komutu tarafından yüklenen .so dosyaları göstmek için şöyle yaparız
$ ldd /bin/date
  linux-vdso.so.1 =>  (0x00007fff6ffff000)
  librt.so.1 => /lib64/librt.so.1 (0x00007f54ba710000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f54ba384000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f54ba167000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f54ba919000)
Örnek
Şöyle yaparız.
$ ldd exit-test
    linux-gate.so.1 =>  (0xb7748000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb757b000)
    /lib/ld-linux.so.2 (0x8005a000)

28 Ocak 2018 Pazar

readelf komutu

-d seçeneği
dynamic section hakkında bilgi gösterir. Şöyle yaparız.
readelf -d a.out
NEEDED alanı
Eğer bir .so kütüphanesi bir başka .so kütüphanesine bağımlıysa elf dosyasında bu alan NEEDED olarak işaretlidir.  Şöyle yaparız.
$ readelf -d liba.so | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
-debug-dump seçeneği
debug section hakkında bilgi gösterir. Açıklaması şöyle.
The .debug_info section contains the actual debugging information. This section does not contain strings.
Şöyle yaparız.
readelf --debug-dump filename.o
Çıktı olarak şunu alırız.
    ...
Item 123:
    Type of information: Data type
    Name: 2b /* String #2b in ".debug_str" is "int" */
    Kind of data type: Signed integer
    Number of bits: 32
    ... some more information ...
Item 124:
    Type of information: Global variable
    Name: 8 /* "lvar" */
    Data type defined by: Item 123
    Stored at: Address 0x1234
    ... some more information ...
Begin item 125:
    Type of information: Function
    Name: 6 /* "main" */
    ... some more information ...
Item 126:
    Type of information: Local variable
    Name: 5 /* "svar" */
    Data type defined by: Item 123
    Stored at: Address 0x1238
    ... some more information ...
End item 125 /* Function "main" */
Item 127:
    ...
- h seçeneği
Header bilgisini gösterir. Şöyle yaparız.
readelf -h MyApp
Çıktı olarak şunu alırız.
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          2548 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         16
  Section header string table index: 13
Class alanı 32/64 bit olduğunu gösterir. 64 bit uygulamanın çıktısı şöyledir.
ELF Header:
Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
Class:                             ELF64
Data:                              2's complement, little endian
Version:                           1 (current)
OS/ABI:                            UNIX - System V
ABI Version:                       0
Type:                              DYN (Shared object file)
Machine:                           Advanced Micro Devices X86-64
Version:                           0x1
Entry point address:               0x1158
Start of program headers:          64 (bytes into file)
Start of section headers:          308248 (bytes into file)
Flags:                             0x0
-S seçeneği
Section'lar hakkında bilgi gösterir. Şöyle yaparız.
$ readelf -S true
There are 30 section headers, starting at offset 0x7368:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000000238  00000238
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             0000000000000254  00000254
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .note.gnu.build-i NOTE             0000000000000274  00000274
       0000000000000024  0000000000000000   A       0     0     4
  ...
  [23] .dynamic          DYNAMIC          0000000000206dd8  00006dd8
       00000000000001e0  0000000000000010  WA       6     0     8
  [24] .got              PROGBITS         0000000000206fb8  00006fb8
       0000000000000030  0000000000000008  WA       0     0     8
  [25] .got.plt          PROGBITS         0000000000207000  00007000
       0000000000000188  0000000000000008  WA       0     0     8
  [26] .data             PROGBITS         00000000002071a0  000071a0
       0000000000000080  0000000000000000  WA       0     0     32
  [27] .bss              NOBITS           0000000000207220  00007220
       00000000000001a0  0000000000000000  WA       0     0     32
  [28] .gnu_debuglink    PROGBITS         0000000000000000  00007220
       0000000000000034  0000000000000000           0     0     1
  [29] .shstrtab         STRTAB           0000000000000000  00007254
       000000000000010f  0000000000000000           0     0     1


16 Ocak 2018 Salı

Windows ipconfig komutu

Giriş
Bu komut Windows'ta olmasına rağmen çok kullanıldığı için yazmak istedim.

all seçeneği
Windows'ta ipconfig /all ile hangi DHCP sunucusundan IP adresi aldığımız öğrenilebilir. Şöyle yaparız.
ipconfig /all > output.txt

flushdns seçeneği
Şöyle yaparız.
ipconfig /flushdns
release seçeneği
DHCP sunucusundan alına IP adresini bırakır. Şöyle yaparız.
ipconfig /release