...

Sunday, February 28, 2010

Debian 11

Debian comes with many open source system utilities that are universal across most Linux distributions. At many times, we want to find out information about the CPU, RAM and the HDD. The first utility we're going to look at is the ps utility.
ps tells us information about processes running. A common way to run ps is:
ps -aux

The GUI equivalent of ps is:
gnome-system-monitor

From ps or gnome-system-monitor, you can see the processes associated with users. ps without parameters returns the processes spawned by a given shell. ps -ef returns all processes for all users, which is similar to -aux.

A non-privileged user can only terminate his/her own processes. Root, however, can terminate anyone's processes. When a non-privileged user kills another user's process, he'll be prompted for the root password.

Another system resource utility is the top program. Top returns the highest utilizers of the CPU, and it refreshes automatically:
top

Top consolidates the output from free, uptime, vmstat and ps programs.

You can stop top after 3 refreshes through:
top -n 3

You can monitor specific PIDs through:
top -p 500, 505, 510

You can also monitor processes from specific users through:
top -u kelvin

You can have a combination of the above parameters to monitor specific PIDs from a specific users for a number of iterations, and so on.

To see information about mountpoints and partitions, use:
df

By default it shows the information in "blocks", which is 1024 bytes each. To see human readable results, use:
df -h

There are two ways to manage users and groups - The GUI and the CLI. From the CLI, you can add users using:
useradd kelvin2

User account database is stored in /etc/passwd, and the hashed passwords are stored in /etc/shadow

A line in passwd looks like:
root:x:0:0:root:/root:/bin/bash

The first field is the login name, which is root.
The second field is a reference to /etc/shadow ('x').
The third field is the UID, which ranges from 0-999.
The fourth field is the GID (group ID) which also ranges from 0-999.
The fifth field is the full name of the user, which in this case is root as well.
The sixth field is the $HOME directory.
The last field is the default shell, which is bash.

A line in shadow looks like this:
root:$1$i75/crGw$hOdYNtDVWQtjPggfz7hTC1:13777:0:99999:7:::

The first field is the login name.
The second field is the hashed password.
The third field is the days since Linux epoch (Jan 1, 1970) since password was last changed.
The fourth field is the days before password may be changed.
The fifth field is the maximum password age in days.
The sixth field is the number of days before password will expire.
The seventh field is the number of days after expiration that account will be disabled.
The last field is the number of days since Unix epoch since the account was disabled.

To delete a user, use:
userdel kelvin2

To reveal package membership of a program, use:
dpkg -S /usr/sbin/useradd

To modify an existing user, use:
usermod -s /bin/bash linuxcbt2

The above example uses the -s parameter which specifies the shell. Use man usermod to check for the parameters you can use.

A GUI tool for user management is:
users-admin

By default, it only shows non-system accounts (non-privileged users only). Each user may belong to 1 and only 1 primary group, but can belong to multiple secondary group.

To add a group, use:
groupadd engineering

To add a user into a group, use:
usermod -G engineering kelvin2

Similarly to userdel, to delete a group, use:
groupdel engineering

No comments :

Post a Comment

<