Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Some useful commands utilities

Where to find more command utilities for process status, disk and cpu utilization etc? by MaheshRathi
Posted: 8 Feb 02

Some useful commands utilities on Linux

Author:    Mahesh M. Rathi

Date written:     08 Feb 2002

    chage, chattr, chfn, chpasswd, colrm, df, du, dumpkeys, fuser, groups, iostat, kbd_mode, keymaps, last, linux, loadkeys, lsattr, lsof, ltrace, pstree, strace, Tee, userinfo, setleds

This document gives a list of linux command utilities, which can be used for library calls tracing, process hierarchy, disk space usage, changing file attributes, getting dump of keyboard transition tables etc. For more details, refer corresponding man pages.

Disk / CPU Usage Statistics:

1.    To report filesystem disk space usage, df can be used. df displays the amount of disk space available on the filesystem containing each file name argument. If no file name is given, the space available on all currently mounted filesystems is shown. By default, df shows the disk space in 1K blocks. But one can change it to 521-byte block by setting an environment variable POSIXLY_CORRECT. (Ref. man page of df).

2.    Estimation of usage of file space can be given by du command. Summarize disk usage of each FILE, recursively for directories. (Ref. man page of du).

3.    To report Central Processing Unit (CPU) statistics and input/output statistics for tty devices and disks, iostat can be used. One can  monitor system input/output device loading by observing the time the physical disks are active in relation to their average transfer rates.

It  generates reports that can be used to change system configuration to better balance the input/output load between physical disks. The first report generated by the iostat command provides statistics concerning the time since the system was booted. Each subsequent report covers the time since the previous report. All statistics are reported each time the iostat command is run. The report consists of a tty (if enabled in the kernel) and CPU header row followed by a row of tty (if enabled in the kernel) and CPU statistics.
On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A disks header row is displayed followed by a line of statistics for each disk that is configured. (Ref. man page of iostat).

File Attributes manipulation:

4.    Tee is a utility to read from standard input and write to standard output and files. It copies the standard input to each FILE, and also to standard output. (Ref. man page of tee).

5.    One can change file attributes on a Linux second extended file system using the command utility called chattr. The format of a symbolic mode is +-=[ASacdisu]. The operator `+' causes the selected attributes to be added to the existing attributes of the files; `-' causes them to be removed; and `=' causes them to be the only attributes that the files have. (Ref. man page of chattr).

6.    User can list the file attributes on a Linux second extended file system using lsattr command. (Ref. man page of lsattr).

7.    One can remove one or more columns from a file using colrm command. Colrm removes selected columns from a file. By default, input is taken from standard input and output is sent to standard output. (Ref. man page of colrm).

8.    One can list all the open files using lsof command. An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket). A specific file or all the files in a file system may be selected by path. (Ref. man page of lsof).

User login and passwords manipulation:

9.    To print the groups a user is in, groups command can be used. (Ref. man page of groups).

10.    To see listing of last logged in users, last command can be used. This command searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. If the names of users and tty's are given as arguments, then last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0. (Ref. man page of last).

11.    User can change his/her finger information using chfn command. chfn is used to change your finger information. This information is stored in the /etc/passwd file, and is displayed by the finger program. The Linux finger command will display four pieces of information that can be changed by chfn: your real name, your workroom, work phone and home phone.
A graphical equivalent to chfn is userinfo. ItÆs a graphical tool to allow users to conveniently change their finger information. (ref. man page of chfn and userinfo).

12.    To change the user password expiry information, chage is useful. chage changes the number of days between password changes and the date of the last password change. System can use this information to determine when a user must change her password. Though, chage command is restricted to the root user, an unprivileged user can use it with ûl option to determine when her password or account is due to expire. (ref. man page of chage).

13.    Updating a password file in batch is possible through chpasswd command. chpasswd reads a file of user name and password pairs from standard input and uses this information to update a group of existing users. Without the -e switch, the passwords are expected to be clear text. With the -e switch, the passwords are expected to be in encrypted form. Each line is of the format user_name:password
The named user must exist. The supplied password will be encrypted as necessary, and the password age updated, if present. This command is intended to be used in a large system environment where many accounts are created at a single time. (ref. man page of chpasswd).

Process Information:

14.    The command, fuser can be used to identify processes using files or sockets. It displays the PIDs of processes using the specified files or file systems. In the default display mode, each file name is followed by a letter denoting the type of access:
c - current directory.
e - executable being run.
f - open file. f is omitted in default display mode.
r - root directory.
m - mmap'ed file or shared library.
(ref. man page of fuser).

15.    Processes can be seen in tree format using the command pstree. It shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown. pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count.
For Example..
(ref. man page of pstree).

System calls and Library calls trace:

16.    A library call tracer called ltrace. It simply runs the specified command until it exits. It intercepts and records the dynamic library calls, which are called by the executed process and the signals, which are received by that process. It can also intercept and print the system calls executed by the program. (ref. man page of ltrace).

17.    A utility to trace system calls and signals, called strace. It simply runs the specified command until it exits. It intercepts and records the system calls, which are called by a process and the signals, which are received by a process. The name of each system call, its arguments and its return value are printed on standard error. The output can be redirected to the file, if specified with the -o option.
strace is a useful diagnostic, instructional, and debugging tool. System administrators, diagnosticians and trouble-shooters 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. Students, hackers and the overly-curious will find that a great deal can be learned about a system and its system calls by tracing even ordinary programs. And programmers will find that since system calls and signals are events that happen at the user/kernel interface, a close examination of this boundary is very useful for bug isolation, sanity checking and attempting to capture race conditions. (ref. man page of strace).

Keyboard information:

18.    One can dump keyboard translation tables using dumpkeys command utility. The command dumpkeys writes, to the standard output, the current contents of the keyboard driver's translation  tables, in the format specified by keymaps (ref. man page of dumpkeys and keymaps).

19.    The command kbd_mode can be used to report or set the keyboard mode. Without argument, kbd_mode prints the current keyboard mode. With argument, it sets the keyboard mode as indicated:
-s: scancode mode (RAW),
-k: keycode mode (MEDIUMRAW),
-a: ASCII mode (XLATE),
-u: UTF-8 mode (UNICODE).
(ref. man page of kbd_mode).

20.    User can load keyboard translation tables using loadkeys command. The loadkeys program reads the file or files specified by filename option. Its main purpose is to load the kernel keymap for the console.(ref. man page of loadkeys).

21.    The command setleds can be used to set the keyboard leds. setleds reports and changes the led flag settings of the current VT (namely NumLock, CapsLock and ScrollLock). Without arguments, setleds prints the current settings. With arguments, it sets or clears the indicated flags (and leaves the others unchanged). The settings before and after the change are reported if the -v flag is given. (ref. man page of setleds).

Back to Linux (server) FAQ Index
Back to Linux (server) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close