Visualizzazione post con etichetta Linux / Unix. Mostra tutti i post
Visualizzazione post con etichetta Linux / Unix. Mostra tutti i post

venerdì 25 febbraio 2011

Linux: boot with terminal

I've just finished installing "stuff" on a VM with Oracle Enterprise Linux and I need to configure the machine without the resource consuming X11 automatically loaded at startup.

The Linux boot process has six states of operation of which "0" is the shutdown state and "3" and above are fully operational with all essential processes running for user interaction. The init process is the last step of the boot procedure and it is identified by process with id=1; Init is responsible for starting system processes as defined in the "/etc/inittab" file.

Editing the inittab file, I changed the default line:

id:5:initdefault:

with the following:

id:3:initdefault:

Here there are the available states:

0 halt system (loaded the /etc/rc.d/rc0.d/ library)
1 single user (/etc/rc.d/rc1.d/)
2 multiuser with no network (...2.d)
3 terminal
4 reserved for local use
5 X11 GUI mode
6 reboot


After startup type "starx" or "init 5" to enter X11.

mercoledì 14 ottobre 2009

Search inside files

In order to search for a specific text pattern inside every file in every subdirectory of a given path in linux you can do:

grep -r "text_2_search" *

"-r" stands for "recursive."
Note that with "zgrep" util you can search recursively inside a .zip or .tar.gz file.

Linux resize screen resolution with xrandr

You can quickly resize the screen resolution using "xrandr" utility (/usr/bin/xrandr).

with xrandr -q you can see all the available resolutions

Input xrandr -s (size) to dynamically resize screen; for example:

xrandr -s 1440x900

giovedì 27 marzo 2008

LSOF: Who's doing what

Sometimes i got problems on identifing what kind of thing is doing a specified process.
First of all, you need to identify your process in "ps -efl" list.

To learn what program is listening on wich port:

netstat -tlnp

You can also identify processes using files or sockets:

fuser [FILENAME]

now check if you have LSOF utility on you machine.

locate lsof

probably you will find it under "/usr/sbin/lsof".
LSOF (LiSt Open Files) is a useful and powerful tool that will show you opened files.

When lsof is called without parameters, it will show all the files opened by any processes.

lsof | nl

Other examples on who is using the apache executable file, /etc/passwd, what files are opened on device /dev/hda6 or who's accessing /dev/cdrom:

lsof `which apache2`
lsof /etc/passwd
lsof /dev/hda6
lsof /dev/cdrom


What process IDs are using the apache binary, and only the PID?

lsof -t `which apache2`


what files are opened by processes whose names starts by "k" (klogd, kswapd...) and bash?

lsof -c k
lsof -c bash

what files are opened by init?

lsof -c init


what files are opened by processes whose names starts by "courier", but exclude those whose owner is the user "mack"?

lsof -c courier -u ^mack


processes opened by user apache and user mack:

lsof -u apache,mack

Show what files are using the process whose PID is 30297:

lsof +p 30297

Search for all opened instances of directory /tmp and all the files and directories it contains:

lsof +D /tmp

List all opened internet sockets and sockets related to port 80:

lsof -i
lsof -i :80

List all opened Internet and UNIX domain files:

lsof -i -U

Show us what process(es) has an UDP connection opened to or from the host www.akadia.com at port 123 (ntp):

lsof -iUDP@www.akadia.com:123




(about LSOF: http://www.akadia.com/services/lsof_intro.html)