ifconfig vs ip

ifconfig vs ip

The command /bin/ip has been around for some time now. But people continue using the older command /sbin/ifconfig. Let’s be clear: ifconfig will not quickly go away, but its newer version, ip, is more powerful and will eventually replace it.

The man page of ip may look intimidating at first, but once you get familiar with the command syntax, it is an easy read. This page will not introduce the new features of ip. It rather features a side-by-side comparison if ifconfigand ip to get a quick overview of the command syntax.

Show network devices and configuration 

ip addr show
ip link show

Enable a network interface 

ifconfig eth0 up
ip link set eth0 up

A network interface is disabled in a similar way:

ifconfig eth0 down
ip link set eth0 down

Set IP address 

ifconfig eth0
ip address add dev eth0

This was the simple version of the command. Often, also the network mask or the broadcast address need to be specified. The following examples show the ifconfig and ip variants.

Needless to say that the netmask can also be given in CIDR notation, e.g. as

ifconfig eth0 netmask broadcast
ip addr add broadcast dev eth0

Delete an IP address 

With ip it is also possible to delete an address:

ip addr del dev eth0

Add alias interface 

ifconfig eth0:1
ip addr add dev eth0 label eth0:1

ARP protocol 

Add an entry in your ARP table.

arp -i eth0 -s 00:11:22:33:44:55
ip neigh add lladdr 00:11:22:33:44:55 nud permanent dev eth0

Switch ARP resolution off on one device

ifconfig -arp eth0
ip link set dev eth0 arp off

Skidanje web sajta kroz CLi sa wget

Ova komanda slika web sajt na adresi www.website.hr/upute/.

wget –recursive –no-clobber –page-requisites –html-extension –convert-links –restrict-file-names=windows –domains websajt.hr –no-parent www.websajt.hr/upute/

Opis opcija koje su korište redom:

  • –recursive: skini cijeli websajt
  • –no-clobber: nemoj prepisati ve? skinute datoteke (u slu?aju da je skidanje prekinuto i ponovno pokrenuto)
  • –page-requisites: skini sve komponente koje ?ine stranicu (slike, CSS, js i ostalo)
  • –html-extension: snimi datoteke sa .html nastavkom/ekstenzijom
  • –convert-links: pretvori linkove da su funkcionalni i lokalno korištenje (off-line)
  • –restrict-file-names=windows: promijeni imena datoteka da rade ispravno u Windows-ima
  • –domains websajt.hr: nemoj pratiti linkove koji nisu na domeni
  • –no-parent: nemoj pratiti linkove izvan direktorija upute/

sys-unconfig: Reconfigure the System Upon Next Boot

I can use unconfigure command on a previously configured Solaris Unix box and leave it in an unconfigured state. How do I unconfigure CentOS Linux OR RHEL 6.x on HP server. How do I reconfigure the system upon next boot?

You can use sys-unconfig command whoch provides a simple method of reconfiguring a system in a new environment. Upon executing sys-unconfig will halt your system, and run the following configuration programs at boot:

  1. Change the root password.
  2. Reconfigure networking / routing.
  3. Reconfigure time / date / time zone etc.
  4. Reconfigure Keyboard and mapping.
  5. Reconfigure system authentication resources.
  6. Reconfigure system runlevel.
  7. Reconfigure system services.

Type the following command as root user. Warning: do not type the following command on a production server for just testing purpose. The system will go down immediately:

# sys-unconfig

This command will create a file called /.unconfigured. The presence of this file will cause /etc/rc.d/rc.sysinit to run the programs mentioned above. Also, all persistent rules will be deleted from /etc/udev/rules.d/.

Izvor: http://www.cyberciti.biz/faq/redhat-rhel-centos-fedora-linux-sys-unconfig-command/

Kako snimiti na brzaka audio stream

Kako najednostavnije krenuti sa snimanjem streama sa neke web adrese? Na Linuxu nam stoji na rasploaganju program mplayer.

mplayer mms://xxx.x.hostname:port1234/path -nocache -ao pcm:file=recstream.wav -vo null -vc dummy

Par primjera snimanja audio streama Radio Samobor

mplayer -nocache -ao pcm:file=radio_samobor_stream.wav -vo null -vc dummy

mplayer -nocache -ao pcm:file=kidesign_radio_samobor.wav -vo null -vc dummy

Ukoliko želite snimati stream bez nadzora pogledajte odli?nu skriptu na http://linuxgazette.net/183/brownss.html (Unattended stream recording with MPlayer)


Konverzija wav u ogg

sox kidesign_radio_samobor.wav kidesign_radio_samobor.ogg

Preslušavanjesa sox komandom play

play kidesign_radio_samobor.wav

play kidesign_radio_samobor.ogg

ili izravno sa mplayer

mplayer kidesign_radio_samobor.ogg

pdf2png – CLI utility for conversion

This simple BASH script uses GhostScript and ImageMagick convert for conversion of PDF file to one or several PNG images. It is possible to select the number of page or an interval, also output resolution and a number of colors.

For example, try to convert this graph, in common way:

convert -geometry 640x data1_amat.pdf data1_amat.png

The convert will use -geometry to set the horizontal size, here 640 px, the vertical size is given by the aspect ratio of image. There is the result:

Now, try to do the same with the pdf2png:

pdf2png -x 640 data1_amat.pdf

The output is stored in file data1_amat_0001.png:

The image size is 75 kB, with ImageMagick it is 226 kB, and the main difference is in quality, the first image is blurry. The difference is in the way of conversion, my script first produce image in huge resolution and than resize it to specified size and a little bit of unsharp mask filter is used to improve the sharp edges.


Invoke pdf2png without any parameters or with -h, to display this help:

Usage:  pdf2png [OPTIONS] FILE

        -h   ... this help
        -a   ... convert all pages
        -f N ... from page number N
        -t N ... to page number N
        -p N ... only page N (default N = 1)
        -d N ... resolution in dpi (default N = 300)
        -x N ... bitmap  width in pixel (if y not given, save aspect ratio)
        -y N ... bitmap height in pixel (if x not given, save aspect ratio)
        -u N ... unsharp radius (default N = 1.0)
        -c N ... number of colors (default N = 16777216)

If no additional options is not given the defaults are used, you can change them inside the script, see the variables on the top.

The name of output is same as original PDF, but the suffix with number of page is added.


pdf2png (3770 B)

Put this file in $PATH, for example /usr/local/bin.

Change log

  • 2012-MAR-23: Version 1.1 released on my home page.

Related articles



Source: http://bruxy.regnet.cz/web/linux/EN/pdf2png

Howto: Configure Linux Virtual Local Area Network (VLAN)

by LINUXTITLI on JUNE 6, 2006


VLAN is an acronym for Virtual Local Area Network. Several VLANs can co-exist on a single physical switch, which are configured via software (Linux commands and configuration files) and not through hardware interface (you still need to configure switch).

Hubs or switch connects all nodes in a LAN and node can communicate without a router. For example, all nodes in LAN A can communicate with each other without the need for a router. If a node from LAN A wants to communicate with LAN B node, you need to use a router. Therefore, each LAN (A, B, C and so on) are separated using a router.

VLAN as a name suggest combine multiple LANs at once. But what are the advantages of VLAN?

  • Performance
  • Ease of management
  • Security
  • Trunks
  • You don’t have to configure any hardware device, when physically moving server computer to another location etc.

VLAN concepts and fundamental discussion is beyond the scope of this article. I am reading following textbooks. I found these textbooks extremely useful and highly recommended:

  • Cisco CNNA ICND books (part I and II)
  • Andrew S. Tanenbaum, Computer Networks book

    Linux VLAN Configuration Issue

I am lucky enough to get couple of hints from our internal wiki docs :D.

  • Not all network drivers support VLAN. You may need to patch your driver.
  • MTU may be another problem. It works by tagging each frame i.e. an Ethernet header extension that enlarges the header from 14 to 18 bytes. The VLAN tag contains the VLAN ID and priority. See Linux VLAN site for patches and other information.
  • Do not use VLAN ID 1 as it may be used for admin purpose.

Linux VLAN How To

My VLAN ID is 5. So I need to copy file /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0.5

# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.5

  • eth0 – Your regular network interface
  • eth0.5 – Your virtual interface that use untagged frames

Do not modify /etc/sysconfig/network-scripts/ifcfg-eth0 file. Now open file /etc/sysconfig/network-scripts/ifcfg-eth0.5 using vi text editor:

 # vi /etc/sysconfig/network-scripts/ifcfg-eth0.5



 # /etc/init.d/network restart

Using vconfig command

Above method is perfect and works with Red hat Enterprise Linux / CentOS / Fedora Linux without any problem. However, you will notice that there is a command called vconfig. The vconfig program allows you to create and remove vlan-devices on a vlan enabled kernel. Vlan-devices are virtual ethernet devices which represents the virtual lans on the physical lan.

Please note that this is yet another method of configuring VLAN. If you are happy with above method no need to read below.

Add VLAN ID 5 with follwing command for eth0:

 # vconfig add eth0 5

The vconfig add command creates a vlan-device on eth0 which result into eth0.5 interface. You can use normal ifconfig command to see device information:

 # ifconfig eth0.5

# ifconfig eth0.5 netmask broadcast up

# cat /proc/net/vlan/eth0.5

# ifconfig eth0.5 down# vconfig rem eth0.5