≡ Menu

system administrators

Linux Disabling Squid Proxy Server

Q. How do I disable Squid Proxy Serer under CentOS Linux operating system so that I can directly connect to the internet?
[click to continue…]

FreeBSD Install Strace – A Process Tracer And Debugging Tool

Q. How do I install Strace utility under FreeBSD operating system so that I can trace and debug my applications and report 3rd party software bugs?

A. Strace is a process tracer, i.e. a debugging tool that prints out a trace of all the system calls made and signals received by a process itself or a process and its descendants.

Strace is similar to the native BSD truss utility, but it's output style is more convenient in most cases.

For strace to work, procfs has to be mounted. FreeBSD does not mount it by default.

WARNING! These examples only work for i386 32 bit FreeBSD computer (strace is not ported to amd64 arch [64 bit]).

Install strace

First update FreeBSD ports collection and install strace from /usr/ports/devel/strace:
# portsnap fetch update
# cd /usr/ports/devel/strace
# make install clean

Mount /proc file system

You need to mount /proc filesystem to use trace command under FreeBSD, enter:
# mount -t procfs proc /proc

How do I use Strace tool?

Please see our previous FAQ / tutorials about strace command:

  1. Debugging Tip: Trace the Process and See What It is Doing with strace
  2. Truss like command under Linux to monitor and diagnostic the system calls

Truss like command under Linux to monitor and diagnostic the system calls

Q. Solaris and FreeBSD both provide the truss command to monitor and debug system calls. I'm unable to find this command or package. How can I install truss under Linux?

A. truss is a debugging utility in Solaris and FreeBSD to monitor the system calls used. It is used to trace call and useful debugging many problems. Linux provides strace command. This command is installed by default. strace is a useful diagnostic, instructional, and debugging tool. System administrators, diagnosticians and troubleshooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them.
[click to continue…]

How to use shutdown command under Ubuntu Linux

Q. I've just installed Ubuntu Linux on my computer. I'd like to know - how to shutdown Ubuntu box over ssh session?

A. If you are not using GUI, you can run halt or shutdown command to powerdown box.

shutdown command

shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented. The shutdown utility provides an automated shutdown procedure for supersers to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such niceties.

How do I use shutdown command?

The shutdown command can be used to turn off or reboot a computer. Type the command as follows to shutdown server / computer immediately:
$ sudo shutdown -h now
$ sudo shutdown -h 0

How do I shutdown compute at specific time?

To shutdown computer at 6:45pm, enter:
$ sudo shutdown -h 18:45 "Server is going down for maintenance"
At 6:30pm message will go out to all user and 6:45 system will shutdown.

Please note that you can also use halt or poweroff or reboot command for stopping and restarting the system:
$ sudo halt
$ sudo poweroff

How do I reboot computer?

Simply use reboot command:
$ sudo reboot
$ sudo shutdown -r 0

update-rc.d like command on Redhat Enterprise / CentOS Linux

Q. I’m using Debian Linux for last 4 years. I’m not able to find out update-rc.d like command ( install and remove System-V style init script links) on Redhat enterprise Linux (RHEL 5). Can you specify equivalent command for the same task?

A. update-rc.d updates the System V style init script links /etc/rcrunlevel.d/NNname whose target is the script /etc/init.d/name. These links are run by init when it changes runlevels; they are generally used to start and stop system services such as daemons. runlevel is one of the runlevels supported by init, namely, 0123456789S, and NN is the two-digit sequence number that determines where in the sequence init will run the scripts. Please note that this program was designed for use in package maintainer scripts and, accordingly, has only the very limited functionality required by such scripts. System administrators are not encouraged to use update-rc.d to manage runlevels. They should edit the links directly or use runlevel editors such as sysv-rc-conf and bum instead.

Under RHEL / CentOS you use command called ntsysv or chkconfig.

Redhat ntsysv tool

ntsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. Just type ntsysv and select service you want to run:
# ntsysv
Sysv Service managment tool
(Fig.01: ntsysv in action under Red Hat Linux)

Redhat chkconfig tool

chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories. chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service.

Add service called foo

This option adds a new service for management by chkconfig:
# chkconfig --add foo

Delete service called foo

The service is removed from chkconfig management, and any symbolic links in /etc/rc[0-6].d which pertain to it are removed:
# chkconfig --del foo

List status for foo service

This option lists all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel.
# chkconfig --list foo

Turn on or off services:
# chkconfig foo on
# chkconfig foo off
# chkconfig --level 2 foo on

Note that --level 35 specifies run levels 3 and 5, so following will turn on httpd service for 3 and 5 only:
# chkconfig --level 35 httpd on

What Is POSIX Shell?

What is POSIX Shell under UNIX / Linux operating systems?
[click to continue…]