Posts Tagged ‘LINUX’

Dec
27
2009

Linux: Determining IP information for eth0… failed

When setting up a workstation to connect to internet, you may come across a message
Determining IP information for eth0… failed

The above error message basically means that eth0 i.e your network interface card is not setup correctly.

Some of the commands that can come handy in troubleshooting where the error lies are listed below

$ dmesg | grep eth0
(displays information about the ethernet controller card, mac address etc.)

$ cat /etc/sysconfig/network(displays the network settings)
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.122.1

$ cat /etc/sysconfig/network-scripts/ifcfp-eth0

$ ifconfig eth0 down (to down the nic)
$ ifconfig eth0 up (to start the nic)
$ netstat -rn (display kernel routing IP table)
$ cat ifcfg-eth0 (eth0 configuration settings)
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:16:18:33:B3:CF
ONBOOT=yes

$ service network restart (restart the network settings)

$ ping -c4 google.ca(to check if the internet connection works)

$ traceroute google.ca (to check how the IP navigation path is set)

Refer Red Hat linux 5 configure network article for additional info

  • Share/Save/Bookmark
Sep
29
2009

How to reset the screen terminal output?

You might have come across instances like trying to print or output the content of binary files or similar instances when the screen spews out unreadable set of characters which then would disrupt the normal display of characters.

stty” is the command that is used to reset your screen content.

$ stty sane

  • Share/Save/Bookmark
Aug
29
2009

Linux: which vs. whereis command difference

Difference between which command and whereis command in Linux

For e.g. lets find where “samba” is located in a CentOS server

$ which samba
which command searches the list of programs listed down through the PATH settings

$ whereis samba
whereis command also searches for programs that are not present in the PATH setting

  • Share/Save/Bookmark
Aug
14
2009

Ubuntu: Change menu order in GRUB loader

GRUB stands for GRand Unified Bootloader. This is to enable the listing of multiple operating systems so the users could choose the OS of their choice.

To change the menu order we need to edit a file called menu.lst

# vi /boot/grub/menu.lst

Look for a line “default 0“. This is the option to indicate that the first menu on the list should be loaded by default. In order for you to set the default menu content in the GRUB loader that needs to get started you can set this parameter.

This is of the form “default <ID>” where ID = N -1. If there are 4 list items in the menu and if you want to load the 4th item by default, you need to set this configuration setting to “default 3″.

Another option for you is to have the menu list with the entry “savedefault = true“. This would enable the last used menu entry to get loaded during the next boot.

  • Share/Save/Bookmark
Jul
26
2009

Linux: How to change the default Run Level?

To list the current run level
$ who -r
run-level 5 2008-07-22 21:35 last=5

To change the default Run level edit /etc/inittab

You can also switch to another run level number by issuing
$ init

For example,
$ init 3

Now the system switches from Run level 5 to Run level 3

To list the current run level
$ who -r
run-level 3 2008-07-22 22:35 last=5

In the above result notice the last part which states “last=5″. This indicates that the last run level was 5

When the system is running and if we want to apply patches or alter certain configurations, the above command comes in handy.

The other option to change the current level is
$ telinit <run level number>

  • Share/Save/Bookmark
Jul
25
2009

Linux: How to find the current Run Level?

Default init level is set in /etc/inittab.

$ cat /etc/inittab (to display the init levels)

Inside that file, you can note a line which will state the run level number like
id:5:initdefault: (indicating run level 5 which means that the system is running with x windows)

To find the current run level you can execute the following commands

$ who -r
run-level 5 2008-07-22 21:35 last=5
which indicates that the system is in run-level 5

Other option to find the run level is
$ /sbin/runlevel
N 5

To find out what sub processes are associated with each run level you can go to
$ cd /etc/rcN.d/ (Where N denotes the run level number)

For example
$ cd /etc/rc1.d/
$ ls -l

This will list symbolic links to various processes associated with run level 1.

  • Share/Save/Bookmark
Jul
23
2009

Linux: How many Run Levels are there and what are they?

Linux systems have 7 Run Levels and they are as follows.

0 – system halt
1 – single user mode (system maintenance mode)
2 – multiuser mode without network access
3 – full multiuser mode with network access
4 – not used
5 – multiuser mode with X windows
6 – reboot or restart

Each run level in linux has a very specific purpose.

Run level 1 is also known as system maintenance mode and at this level the system prompt appears without root level password. It should be used only when it is absolutely necessary for system maintenance.

Run level 4 is not used and it can be used by the user to customize his own level.

Note: Solaris Run Level is different from Linux run levels.

  • Share/Save/Bookmark
Jul
22
2009

Linux: What is Run Level?

Run Level is a term to indicate your computer’s state of operation. When your computer starts it initially starts the the first process called the init process. Init process in turn starts associated sub-processes for that state of operation.

Run Level is the state of the machine – indicating the processes and sub-processes that needs to be started in order for the Operating System to be in that state.

  • Share/Save/Bookmark
Jul
15
2009

How to display the history of commands executed by the user?

Linux: History command

Each bash sessions stores the history of commands executed in .bash_history file which in turn in stored under each user’s home directory

usr100@dev01:/tmp/user$ ls
07-14.txt a.txt b.txt d.txt

usr100@dev01:/tmp/user$ cat ~/.bash_history
clear
su root
rm -i d.txt
ls -ltr
touch c.txt

  • Share/Save/Bookmark
Jul
13
2009

How to restrict folder, file permission settings for each user?

Sticky bit

There may be situation where you wanted all users to store files in a certain folder but might want to restrict users from deleting other users file. For this scenario, you can set the sticky bit of the folder which will serve our purpose.

For example we have created a folder inside /tmp directory called “user”

root@dev:/tmp# ls -l | tail -1
drwxr-xrwx 2 root root 4096 2009-07-13 11:39 user
root@dev:/tmp# cd user

Now create a file called a.txt (you are currently with root privileges)
root@dev:/tmp/user# touch a.txt

Now change to the user with normal privileges (i have created a user called ‘usr100′ for this purpose)
usr100@dev:/tmp/user$ su usr100
password:
usr100@dev:/tmp/user$ whoami
usr100
(more…)

  • Share/Save/Bookmark