Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Chapter 8. Finding information about the system

time

If you are looking for how to change the time please refer to date here: Section 8.1.

time is a utility to measure the amount of time it takes a program to execute. It also measures CPU usage and displays statistics.

Use time -v (verbose mode) to display even more detailed statistics about the particular program.

Example usage:

time program_name options
/proc

The files under the /proc (process information pseudo file-system) show various information about the system. Consider it a window to the information that the kernel uses.

For example:

cat /proc/cpuinfo

Displays information about the CPU.

less /proc/modules 

To view information on what kernel-modules are loaded on your system.

dmesg

dmesg can be used to print (or control) the " kernel ring buffer". dmesg is generally used to print the contents of your bootup messages displayed by the kernel. This is often useful when debugging problems.

Simply type:

dmesg

df Displays information about the space on mounted file-systems. Use the .h option to have df list the space in a 'human readable' format. ie. if there are 1024 kilobytes left (approximately) then df will say there is 1MB left.

Command syntax:

df -options /dev/hdx

The latter part is optional, you can simply use df with or without options to list space on all file-systems.

who Displays information on which users are logged into the system including the time they logged in.

Command syntax:

who

w Displays information on who is logged into the system and what they are doing (ie. the processes they are running). It's similar to who but displays slightly different information.

Command syntax:

w
users

Very similar to who except it only prints out the user names who are currently logged in. (Doesn't need or take any options).

Command syntax:

users 

last Displays records of when various users have logged in or out. This includes information on when the computer was rebooted.

To execute this simply type:

last

lastlog Displays a list of users and what day/time they logged into the system.

Simply type:

lastlog

whoami Tells the user who they are currently logged in as. Doesn't need or take any options.

Simply type:

whoami

free Displays memory statistics (total, free, used, cached, swap). Use the -t option to display totals of everything and use the -m to display memory in megabytes.

Example:

free -tm

This will display the memory usage including totals in megabytes.

uptime Print how long the computer has been "up", how long the computer has been running. It also displays the number of users and the processor load (how hard the CPU has been worked...).

Note: the w command displays uptime's output as the top line of its output when it is executed (ie. you could use w instead...).

uname

uname is used to print information on the system such as OS type, kernel version et cetera.

Some uname options:

  • -a --- print all the available information

  • -m --- print only information related to the machine itself.

  • -n --- print only the machine hostname.

  • -r --- print the release number of the current kernel.

  • -s --- print the operating system name

  • -p --- print the processor type.

Command syntax:

uname -options

xargs Note that xargs is an advanced, confusing, yet powerful command. xargs is a command used to run other commands as many times as necessary, this way it prevents any kind of overload... When you run a command then | xargs command2. The results of command1 will be passed to command2.

Understanding xargs tends to be very difficult and my explanation is not the best. Refer to the examples below or try [6] of the Bibliography for another xargs tutorial.

Note Alternatives to using xargs
 

Please note that the below explanation of xargs is not the strongest (at the time of writing I could not find anything better :()). Alternatives may include writing a simple bash script to do the job which is not the most difficult task in the world.

Examples:

ls | xargs grep work

The first command is obvious, it will list the files in the current directory. For each line of output of ls, xargs will run grep on that particular line and look for the string "work". The output have the each time grep is executed on a new line, the output would look like:

file_name: results_of_grep 

If grep didn't find the word then there would be no output if it had an error then it will output the error. Obviously this isn't very useful (you could just do grep *, its just an example...

xargs also takes various options:

  • -nx --- will group the first x commands together

  • -lx --- xargs will execute the command for every x number of lines of input

  • -p --- prompt whether or not to execute this particular string

  • -t --- (tell) be verbose, echo each command before performing it

  • -i --- will use substitution similar to find's -exec option, it will execute certain commands on something.

Example:

ls dir1 | xargs -i mv dir1/'{}' dir2/'{}'

The {} would be substituted for the current input (in this example the current file/directory) listed within the directory. The above command would move every file listed in dir1 to dir2. Obviously this command won't be too useful, it would be easier to go to dir1 and type mv * ../dir2

Here is a more useful example:

\ls *.wav | xargs -i lame -h '{}' '{}'.mp3

This would find all wave files within the current directory and convert them to mp3 files (encoded with lame) and append a .mp3 to the end of the file, unfortunately it doesn't remove the .wav and so its not too useful...but it works.

 
 
  Published under the terms of the GNU General Public License Design by Interspire