Archive for the ‘ linux ’ Category

How to set static IP address on Unix

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 4 out of 10)
Loading ... Loading ...

In Unix system like Debian, Ubuntu or Red Hat, It is possible to set a static IP address with ifconfig command.

My current Debian system IP address is 10.70.0.61

mkyong:~# ifconfig
eth0    Link encap:Ethernet  HWaddr 00:15:17:1D:CE:2F  
          inet addr:10.70.0.61  Bcast:10.70.3.255  Mask:255.255.252.0

I want change it to 10.70.0.66, just issue following command to set a static IP address in unix

ifconfig eth0 10.70.0.66 netmask 255.255.252.0
mkyong:~# ifconfig eth0 10.70.0.66 netmask 255.255.252.0
mkyong:~# ifconfig
eth0    Link encap:Ethernet  HWaddr 00:15:17:1D:CE:2F  
          inet addr:10.70.0.66  Bcast:10.70.3.255  Mask:255.255.252.0

Done.

P.S eth0 is your system network card.

How to check Linux CPU Information

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 3 out of 10)
Loading ... Loading ...

Linux CPU information is store in /proc/cpuinfo, we can check our Linux CPU information by issue following command

cat /proc/cpuinfo

Sample output in my Linux machine

debian:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 CPU          6300  @ 1.86GHz
stepping        : 8
cpu MHz         : 1861.324
cache size      : 2048 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                   pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc up pni ds_cpl                                                                                                   cx16 lahf_lm
bogomips        : 3734.51

How to check Linux / Unix distribution version

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (3 votes, average: 4.67 out of 10)
Loading ... Loading ...

Today my boss ask me install a tomcat in linux machine. After i ssh into that machine, i wonder what is the Linux distribution version? Red Hat? Ubuntu? Fedora? Debian?

However with a simple command, i can check what is linux distribution version

mymachine:~# cat /proc/version
Linux version 2.6.18-5-686-bigmem (Debian 2.6.18.dfsg.1-13etch3) (dannf@debian.org)
(gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21))
#1 SMP Wed Sep 26 19:03:46 UTC 2007
mymachine:~#

I’m using Debian Linux version 2.6.18-5-686-bigmem

cat /proc/version

How to Enable Mouse Wheel Scrolling in Ubuntu (VMware)

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (6 votes, average: 5.17 out of 10)
Loading ... Loading ...

Ubuntu…Beside Default VI is suck, here is another issue for me. My mouse wheel scrolling is not working in Ubuntu8.04. However i installed Ubuntu in vmware, but i do not think it is vmware cause of this issue. Here i find some useful information regarding Mouse Wheel Scrolling malfunction issue, please check Ubuntu Mouse Configuration Official website.

https://help.ubuntu.com/community/ManyButtonsMouseHowto

After studying above article, here i provided some steps to enable mouse wheel scrolling in Ubuntu under VMware.


1) Open terminal

2) issue command “sudo gedit /etc/X11/xorg.conf”

sudo gedit /etc/X11/xorg.conf

3) Modify /etc/X11/xorg.conf , Change below part

From

Section “InputDevice”
Identifier “Configured Mouse”
Driver “vmmouse”
Option “CorePointer”
Option “Device” “/dev/input/mice”
EndSection

to

Section “InputDevice”
Identifier “Configured Mouse”
Driver “vmmouse”
Option “CorePointer”
Option “Device” “/dev/input/mice”
Option “Protocol” “ImPS/2″
Option “Buttons” “5″
Option “ZAxisMapping” “4 5″
EndSection

4) Save it

5) Hit Ctrl+Alt+Backspace to restart Ubuntu X windows (If Ctrl+Alt+Backspac is not working, just reboot Ubuntu normally)

6) Login again , your mouse wheel scrolling should be working in Ubuntu now

7) Done

P.S Please refer here if you want to know more detail about mouse wheel scrolling configuration in Ubuntu.

https://help.ubuntu.com/community/ManyButtonsMouseHowto

Find a package with Apt command - Ubuntu

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 4 out of 10)
Loading ... Loading ...

apt-get install is a useful command in Ubuntu, it can help user easily install application, it just like yum in fedora core.however, sometime we do not know exactly what package name to be install. Here is apt-cache search come to place and solve it. We can search a package name available to install with following command

sudo apt-cache search <package-name>

For example, i want to install java sdk in Ubuntu, but i do not know the exatly package name to install, i can issue following command to search “java sdk”.

sudo apt-cache search java sdk

Got it, just install it with following command

sudo apt-get install sun-java6-sdk

How to check directory file size on linux (Solution)

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 2 out of 10)
Loading ... Loading ...

hmm… linux whatever also in command line, it really make me uncomfortable, i even need to issue a command to check a directory size.

du -lh

P.S
always issue -h to display file size in human readable format

check-directory-size-on-linux

We can check summary of a directory by issuing

du -sh <directory>

How to copy Entire Directory in Linux

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1 out of 10)
Loading ... Loading ...

Command is simple, here i provide two samples to show how to copy entire directory in linux.

cp -r sourcedir targetdir

for instance,

1) Copy anything from current directory to /usr/local/download

cp -r * /usr/local/download

2) Copy whole directory (include content) /usr/local/fromdownload to target /usr/local/download

cp -r  /usr/local/fromdownload  /usr/local/download

Fedora Password is Strong !!!

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 2 out of 10)
Loading ... Loading ...

Fedora you are strong !!! Here i share a bit funny stuff, regarding when i reset my postgres user password in fedora core 8.

Please view below picture.

Actually i just want to set a easy remember password for user postgres. However i unable to do it.

First i enter password as “password”

Fedora : BAD PASSWORD, it is based on dictionary word.
Me : What? … ok, dictionary word ..

Then i enter password as “postgres”, it is not a dictionary word.

Fedora : BAD PASSWORD, it is based on your username.
Me : What? …..can not again !!!!…..

Shit , i just want a simple password for it, i type password as “123456″ finally.

Fedora : BAD PASSWORD, it is too simplistic/systematic
Me : WTF…..

Fedora directly kill my session and kick me out… haha……Fedora you are strong !!! i can not set a easy remember at all. ~

How to Set Environment Variable in Ubuntu

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 5 out of 10)
Loading ... Loading ...

I need to set LD_LIBRARY_LIB path into Ubuntu Environment Variable, but i cant find ~/.bash_profile in Ubuntu? I issue following command to search through whole file system

sudo find / -name .bash_profile

It return me nothing, hmm… it seem Ubuntu do not have ~/.bash_profile like other Linux distribution version. It left me no choice but set environment variable in /etc/profile.

Here i provide two ways to set environment variable in /etc/profile

1) su to root and Issue following command

  echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib;" >> /etc/profile

2) VI to edit /etc/profile
Append “export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib;” to end of the /etc/profile content (after what unmask xxx).

After modified /etc/profile, hit CTRL+ALT+Backspace to restart x windows to take effect.

P.S user also can append export into .bashrc to set environment variable in linux

cd ~
vim .bashrc

Ubuntu Default VI Is Suck!!!

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 2 out of 10)
Loading ... Loading ...

As i said last post, Ubuntu default VI is suck, i totally do not know how to use it, all my up, down, left and right become funny character , cant edit or code a line at all. If not mistake, Ubuntu is using vim-tinny as default VI editor.

Hi i totally surrender to you tinny, you are genius product, however i’m just a normal people, so i just need back my normal vi editor enough already. You can go download a latest full feature VI or issue following command to get a simple gnome normal vi.

apt-get install vim-gnome

After installed, it will overwrite the default vi, finally my favorite simple vi editor is back.