Guanhua Lu’s Web Notes

September 29, 2009

Useful Unix Commands

Filed under: Software — Tags: , , , — guanhualu @ 11:03 am

The ps command
You can also use the Unix command ps. At the Unix prompt, enter:

ps -u username
Replace username with your username. You will see something like the following:

PID TTY TIME COMMAND
10005 ? 3:03 a.out
15852 rb 0:01 -tcsh (tcsh)
24980 rb 0:00 sh -c /usr/local/bin/emacs /usr1/mmouse/snd.18106
24981 rb 0:02 /usr/local/bin/emacs /usr1/mmouse/snd.18106
22311 rf 0:22 elm
In this example, the “TIME” column shows that the process running Elm has used 22 CPU seconds.

On most Unix systems, you can use the uname command to determine which Unix system (e.g., SunOS, AIX, IRIX, Linux, Darwin) is running on your computer. On most systems, to obtain additional information about the operating system, at the Unix prompt, enter:

uname -a

To display how much disk space is free on mounted file systems in Unix, use the df command. At the Unix prompt, enter:

df

This is not the same as your quota; rather, this displays how much space is left on the device or devices designated. The output and capabilities of the df command vary depending on which variety of Unix you are using, so consult the man pages for specifics. However, typically, you can see information about all mounted file systems, including total space, used space, and free space.

To output information on a specific device or file system node, you may also specify the device or node, for example:

df /node_or_dirname

Replace /node_or_dirname with the name of your chosen file system node or mounted directory name.

 

 

 

The following table lists the basic Unix job control commands:

Command Explanation Example
& Run the command in the background % long_cmd &
Ctrl-z Stop the foreground process [Ctrl-z]
Stopped
jobs List background processes % jobs
[1] – Stopped vi
[2] – big_job &
%n Refers to the background number n % fg %1
%?str Refers to the background job containing str % fg %?ls
bg Restart a stopped background process % bg
[2] big_job &
fg Bring a background process to the foreground % fg %1
kill Kill a process % kill %2
~ Ctrl-z Suspend an rlogin or ssh session host2>~[Ctrl-z]
Stopped
host1>
~~ Ctrl-z Suspend a second level rlogin or ssh session host3>~~[Ctrl-z]
Stopped
host2>

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.