Home > Unix > UNIX – Lesson 001 – pwd, df, du, w, whereis and which commands

UNIX – Lesson 001 – pwd, df, du, w, whereis and which commands

The “pwd” returns an absolute path  name  of  the  current  working directory to standard output (for example as standard output we can see the “monitor”).


DF (disk free)
The “df” command displays the amount of disk space occupied by mounted  or   unmounted file systems, the amount of used and available space, and how much of  the  file  system’s  total capacity has been used. The file system is specified by device, or by referring to a file or directory on the specified file system.

Syntax :
df [-kl] [filesystem]
Key argument:

  • -k   prints the allocation in KB
  • – l   reports on local filesystem only


DU (disk usage)
The “du” utility writes to standard output  the  size  of  the file  space  allocated  to,  and  the size of the file space allocated to each subdirectory of, the file hierarchy rooted in  each  of the specified files. The size of the file space allocated to a file of type directory is defined as the  sum total  of space allocated to all files in the file hierarchy rooted in the directory plus  the  space  allocated  to  the directory itself.

Syntax :
du [-sk] [name]
Key argument:

  • -s   report,  instead of the default output, only the total sum for each of the specified files or the total sum for the filesystem.
  • -k   write the files sizes in units of 1024  bytes

# du -sk *.pdf

368    Basic_Unix_Training_v7.0.pdf
472    Phyton_Programming.pdf
192    Shell_Programming_v1.1.pdf
2936  java1.pdf


W (who)
The “w” command displays a summary of the current activity  on the  system,  including what each user is doing. The heading line shows the current time, the length of time  the  system has been up, the number of users logged into the system, and the average number of jobs in the run queue over the last 1, 5 and 15 minutes.
The fields displayed are: the user’s login name, the name of the  tty  the user is on, the time of day the user logged on (in hours:minutes), the idle time-that  is,  the  number  of minutes   since   the   user   last   typed   anything   (in hours:minutes), the CPU time used by all processes and their children on that terminal (in minutes:seconds), the CPU time used by the currently active processes (in minutes:seconds), and the name and arguments of the current process.



The “whereis” utility locates source/binary and  manuals  sections  for a command.

Syntax :
whereis [-bms] command

Key argument:

  • -b   Search only for binaries.
  • -m  Search only for manual sections.
  • -s    Search only for sources.

# whereis sh
sh: /sbin/sh /usr/bin/sh

# whereis perl
perl: /usr/bin/perl /usr/local/bin/perl /usr/local/bin/perl5.00503



The “which” command locates the first occurrence found in your PATH for a command.

Syntax :
which  command

# which sh

#which perl

Categories: Unix
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: