Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Thursday, October 3, 2013

Configuring NIC network interface on RHEL

Note: ipconfig is deprecated in favour of ip, however a lot of legacy code still uses it.
Very interesting tutorial here and here
This is a UI to edit all configuration without requiring root privileges, bur probably if you are not root you won'et even be able to see any configuration values - forget about changing them:

/usr/sbin/system-config-network-tui

This is what you get:



ââââââââââ⤠Network Configuration âââââââââââ
â                                           â
â                                           â
â Name                 eth0________________ â
â Device               eth0________________ â
â Use DHCP             [*]                  â
â Static IP            ____________________ â
â Netmask              ____________________ â
â Default gateway IP   ____________________ â
â Primary DNS Server   ____________________ â
â Secondary DNS Server ____________________ â
â                                           â
â       ââââââ            ââââââââââ        â
â       â Ok â            â Cancel â        â
â       ââââââ            ââââââââââ        â
â                                           â
â                                           â
âââââââââââââââââââââââââââââââââââââââââââââ



this is equivalent, but requires root privileges:

/usr/bin/system-config-network

They don't require a X-terminal session, they support a text-ui mode.

To manually hack the configuration:
cd /etc/sysconfig/network-scripts/
less ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="08:00:27:29:06:6F"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="ca6ef823-ed13-46ad-8a83-9d688f6cf239"


Some other "global" info is here:
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=osb-vagrant.acme.com

"/sbin/ip -o addr" displays all IPs
to add an extra IP, you must specify an interface eth0:N where N > 0:
/sbin/ifconfig eth0:1 10.0.2.16 netmask 255.255.255.0

(there is an implicit "up" at the end)
Entering "/sbin/ifconfig eth0 10.0.2.16 netmask 255.255.255.0" will crash the NIC, removing the current primary address to replace with the new one.



Tuesday, December 27, 2011

EOL issues on Unix/Windows

in vi, if you want to view a file in HEX mode, do this:

:%!xxd


line feed=10=0x0A (\n)
carriage return=13=0x0D (\r)


in Windows, a EOL is defined by \r\n (0D0A)
in Unix, a EOL is defined by \n (0A)


to change EOL to some other character:

tr '\n' '#' < test1.txt > test2.txt

to turn a Windows file into Unix:
dos2unix filename

Excellent Notepad++ to convert one format into another (Edit/EOL conversion)

Monday, September 19, 2011

Handy settings for your Unix environment

very few things are as frustrating as having to work on a Unix Shell which doesn't have autocomplete and history retrieve enabled, or the backspace.

Here are the settings:

stty erase ^? # backspace here
set -o emacs
alias __A=$(print '\0020') # ^P = up = previous command
alias __B=$(print '\0016') # ^N = down = next command
alias __C=$(print '\0006') # ^F = right = forward a character
alias __D=$(print '\0002') # ^B = left = back a character
alias __H=$(print '\0001') # ^A = home = beginning of line

I am still looking for autocompletion, my shell is /sbin/sh


And remember that ESC-ESC enables autocompletion in HP-UX - like TAB in Linux

Wednesday, July 7, 2010

Unix redirection

command 2>&1 > output.log (stdout and error to output.log)
command 2> output.log (error to output.log, stdout to console)
command 1> output.log 2> error.log (error to error.log, stdout to output.log)


Monday, May 25, 2009

Creating dynamically a CLASSPATH in Unix

buildClassPath() {
jar_dir=$1
if [ $# -ne 1 ]; then
echo "Jar directory must be specified."
exit 1
fi
class_path=
c=1
for i in `ls $jar_dir/*.jar`
do
if [ "$c" -eq "1" ]; then
class_path=${i}
c=2
else
class_path=${class_path}:${i}
fi
done
echo $class_path
#return $class_path
}


CP=`buildClassPath /data/software/cruisecontrol-bin-2.8.2/lib`