Archive for the ‘UNIX’ Category

h1

Preventing ctrol+alt+del rebooting in our machine

May 1, 2009

Edit the /etc/inittab file as root

There’s a line like this in the file

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

Just comment it, or replace it with something like this
ca:12345:ctrlaltdel:echo "Use the "shutdown -r now" command if you want to reboot the system"

Also you should read the shutdown manual. This is a part of this that I think is important if we want to lock the rebooting system.
ACCESS CONTROL
shutdown can be called from init(8) when the magic keys CTRL-ALT-DEL are pressed, by creating an appro-
priate entry in /etc/inittab. This means that everyone who has physical access to the console keyboard
can shut the system down. To prevent this, shutdown can check to see if an authorized user is logged in
on one of the virtual consoles. If shutdown is called with the -a argument (add this to the invocation
of shutdown in /etc/inittab), it checks to see if the file /etc/shutdown.allow is present. It then
compares the login names in that file with the list of people that are logged in on a virtual console
(from /var/run/utmp). Only if one of those authorized users or root is logged in, it will proceed. Oth-
erwise it will write the message

shutdown: no authorized users logged in

to the (physical) system console. The format of /etc/shutdown.allow is one user name per line. Empty
lines and comment lines (prefixed by a #) are allowed. Currently there is a limit of 32 users in this
file.

In some distros like Fedora, you must look for the /etc/event.d/control-alt-delete file to modify this event

Cheers

h1

Which distro version am I using?

April 18, 2009

Maybe you have asked yourself sometimes about this. There are some ways:
This shows a text like the uname -a command output
cat /proc/version
This is another way which should works in practically all *NIX systems
cat /etc/issue
And this is valid for Debian and Debian based distros
cat /etc/debian_version

h1

How to: Recovering your Debian/FreeBSD root password

November 1, 2008

Hi there again.

Probably, you’ve lost your root password at least one time in your life (yea, you are not the only one ;) )… There’s no problem, I’m gonna show you a easy way to fix it.

  • For Debian (Using GRUB, anyway, this will work in any boot loader)
  1. In the line where is our Debian installation, press “e”
  2. Now a kind of editor will be opened. Type the following command after the current commands: “init=/bin/bash”
  3. Press enter
  4. Now you would be back in the first step. Just press de “b” key, to boot the system with the new parameters
  5. Now the system prompt would be a root session. But if you try to use “passwd” command, the system will deny the operation. To fix this, type “mount -o remount,rw /dev/[your_drive]“. Usally your drive will be sda1, hda1 or similar.
  6. Now use the passwd root command to change.
  7. Reboot and your computer and use your new root password :P
  • For FreeBSD
  1. In the boot menu, choose the option 4 “FreeBSD in single mode user”
  2. Now a message like “Enter fill pathname of shell or RETURN for /bin/sh” will be shown. Just press ENTER
  3. The next step is typing “mount -t ufs -a“. This will mount every file system found in /etc/fstab
  4. Now just use the passwd root command
  5. Reboot the system
h1

Adding quotas support on FreeBSD

November 1, 2008

I followed these steps to add the QUOTA module in the kernel. Moreover, the new kernel will has the generic freebsd kernel options.

First, log in the system as root and type the following commands

  • cd /sys/i386/conf
  • vi QUOTAS_SUPPORT        You can write the file name you want
  • In the file type:

include GENERIC
options QUOTA

  • config CUOTAS_SUPPORT         Be sure that you type the file name you typed
  • cd ../compile/CUOTAS_SUPPORT
  • make cleandepend && make depend && make && make install

That’s all. You can also edit the /sys/i386/GENERIC or DEFAULTS file, but it is highly not recommended because you would lost the default kernel configuration.

h1

Some useful *NIX commands

March 12, 2008

This is a collection of some *NIX commands (i’m using it on a FreeBSD  6.2), to manage some system process and signals.

wait -> It restore the second plane of the terminal until the process is running. You can type new commands, but it will be executed when the process ends.

[command] > /dev/null & -> This will not show the messages that the command print in the screen.

nice -> This command sets the priority of a process. The priority range goes from -20 to +20. To use it, type “nice +15 [process]“. You can also add a rule to a user or group using the “-g” and “-u” modifiers.

time -> This command allows you to watch how much time a process needs to execute.

h1

How to: Telnet server

November 24, 2007

Today i’ve done a telnet server in one of my computers… I’m conscious that telnet isn’t a safe way to access a server through, but i just wanted to learn something about this application , furthermore i did it into my LAN. Ok, lets go install it! (You must login as root user)

apt-get install telnetd netkit-inetd

Maybe, the system ask you to install “openbsd-inetd” or “inetutils-inetd, i chose the second and it works fine.

Before this, you should start the server

/usr/sbin/in.telnetd

Now the telnet server is running and you can access it through a telnet cliente like ssh in linux or PuTTy in Windows.

Here we’ve a screen capture of a Telnet login in Ethereal/Wireshark. ;-)
ethereal_telnetjoin.jpg

h1

Adding a UNIX user

November 22, 2007

useradd -c College_classmate -d /home/MyNewUser -u [user_ID] -g [Group] -p [Password] MyNewUser

See useradd –help for more information about “useradd” command.

h1

Searching files in Unix

November 20, 2007

A simple search

find [root_directory] [filename]

find / "*MyFile*"

Searching a application path

whereis [appname]

whereis ssh

Searching files by content in a directory

egrep -i "hello world" /home/[mydir]/*

h1

Downloading a entire web site

October 9, 2007

If we need to save a entire website in our drive, we can choose some applications like:

  • HTTrack (Avaible for Windows and Linux)
  • Webcopier
  • In Linux type in a terminal: wget -r --level=3 http://www.url.com/

*–level=3 means that 3 sub-levels of the web will be downloaded.

h1

Free Un*x terminals by Hewlett Packard

October 4, 2007

HP it’s offering free Un*x terminals to try some OS:

  • HP-UX 11i v3
  • Linux (Debian Etch, Red Hat Enterprise 5, Madriva Corporate, SuSe server 10)
  • HP OpenVMS
  • FreeBSD 6.2

All this OS are running on different machines as HP Proliant servers or PA-RISC.

There’re some apps to test those servers, GCC, Oracle, Fortran compilers, etc

This is the link http://www.testdrive.hp.com/