pwdx – report current working directory of a process

A UNIX Command
$pwdx 3805 1413 1412 1799 1009 2002
3805: /home/jeffrin
1413: Permission denied
1412: Permission denied
1799: Permission denied
1009: Permission denied
2002: Permission denied
$

$sudo pwdx 3805 1413 1412 1799 1009 2002
[sudo] password for jeffrin:
3805: /home/jeffrin
1413: /
1412: /var/lib/mysql
1799: /
1009: /
2002: /
$

UNIX Explanation

The pwdx command reports the current working directory of
a process or processes.

pmap – report memory map of a process

A UNIX Command
$pmap 2307 | more
2307:   bash
0000000000400000    868K r-x--  /bin/bash
00000000006d9000     36K rw---  /bin/bash
00000000006e2000     24K rw---    [ anon ]
00000000010b9000    304K rw---    [ anon ]
00007f1e4c89b000     44K r-x--  /lib/libnss_files-2.13.so
00007f1e4c8a6000   2044K -----  /lib/libnss_files-2.13.so
00007f1e4caa5000      4K r----  /lib/libnss_files-2.13.so
00007f1e4caa6000      4K rw---  /lib/libnss_files-2.13.so
00007f1e4caa7000     40K r-x--  /lib/libnss_nis-2.13.so
00007f1e4cab1000   2044K -----  /lib/libnss_nis-2.13.so
00007f1e4ccb0000      4K r----  /lib/libnss_nis-2.13.so
00007f1e4ccb1000      4K rw---  /lib/libnss_nis-2.13.so
00007f1e4ccb2000     84K r-x--  /lib/libnsl-2.13.so
00007f1e4ccc7000   2044K -----  /lib/libnsl-2.13.so
00007f1e4cec6000      4K r----  /lib/libnsl-2.13.so
00007f1e4cec7000      4K rw---  /lib/libnsl-2.13.so
00007f1e4cec8000      8K rw---    [ anon ]
00007f1e4ceca000     28K r-x--  /lib/libnss_compat-2.13.so
00007f1e4ced1000   2044K -----  /lib/libnss_compat-2.13.so
00007f1e4d0d0000      4K r----  /lib/libnss_compat-2.13.so
00007f1e4d0d1000      4K rw---  /lib/libnss_compat-2.13.so
00007f1e4d0d2000 106700K r----  /usr/lib/locale/locale-archive
00007f1e53905000   1512K r-x--  /lib/libc-2.13.so
00007f1e53a7f000   2044K -----  /lib/libc-2.13.so
00007f1e53c7e000     16K r----  /lib/libc-2.13.so
00007f1e53c82000      4K rw---  /lib/libc-2.13.so
00007f1e53c83000     20K rw---    [ anon ]
00007f1e53c88000      8K r-x--  /lib/libdl-2.13.so
00007f1e53c8a000   2048K -----  /lib/libdl-2.13.so
00007f1e53e8a000      4K r----  /lib/libdl-2.13.so
--More--

$pmap -d 2307 | more
2307:   bash
Address           Kbytes Mode  Offset           Device    Mapping
0000000000400000     868 r-x-- 0000000000000000 008:00001 bash
00000000006d9000      36 rw--- 00000000000d9000 008:00001 bash
00000000006e2000      24 rw--- 0000000000000000 000:00000   [ anon ]
00000000010b9000     304 rw--- 0000000000000000 000:00000   [ anon ]
00007f1e4c89b000      44 r-x-- 0000000000000000 008:00001 libnss_files-2.13.so
00007f1e4c8a6000    2044 ----- 000000000000b000 008:00001 libnss_files-2.13.so
00007f1e4caa5000       4 r---- 000000000000a000 008:00001 libnss_files-2.13.so
00007f1e4caa6000       4 rw--- 000000000000b000 008:00001 libnss_files-2.13.so
00007f1e4caa7000      40 r-x-- 0000000000000000 008:00001 libnss_nis-2.13.so
00007f1e4cab1000    2044 ----- 000000000000a000 008:00001 libnss_nis-2.13.so
00007f1e4ccb0000       4 r---- 0000000000009000 008:00001 libnss_nis-2.13.so
00007f1e4ccb1000       4 rw--- 000000000000a000 008:00001 libnss_nis-2.13.so
00007f1e4ccb2000      84 r-x-- 0000000000000000 008:00001 libnsl-2.13.so
00007f1e4ccc7000    2044 ----- 0000000000015000 008:00001 libnsl-2.13.so
00007f1e4cec6000       4 r---- 0000000000014000 008:00001 libnsl-2.13.so
00007f1e4cec7000       4 rw--- 0000000000015000 008:00001 libnsl-2.13.so
00007f1e4cec8000       8 rw--- 0000000000000000 000:00000   [ anon ]

UNIX Explanation

The pmap command reports the memory map of a process or
processes.

id – print real and effective user and group IDs

A UNIX Command
$id
uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark)
$id -n
id: cannot print only names or real IDs in default format
$id -a
uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark)
$id -g
1000
$id -G
1000 29 1001
$id -Gn
jeffrin audio wireshark
$id -r
id: cannot print only names or real IDs in default format
$id -rG
1000 29 1001
$id -u
1000
$id -un
jeffrin
$

UNIX Explanation

GNU/Linux Based Explanation
Print  user  and  group  information  for  the  specified
USERNAME, or (when USERNAME omitted) for the current user

SunOS Based Explanation
If no user operand is provided, the id utility writes the
user and  group IDs and the corresponding  user and group
names of the invoking process to standard output.  If the
effective and real IDs do not match, both are written. If
multiple groups  are supported by  the underlying system,
/usr/xpg4/bin/id  also  writes  the  supplementary  group
affiliations of the invoking process.


If a  user operand  is provided and  the process  has the
appropriate  privileges, the  user and  group IDs  of the
selected user  are written.  In this  case, effective IDs
are assumed to be identical  to real IDs. If the selected
user has more than  one allowable group membership listed
in  the group database,  /usr/xpg4/bin/id writes  them in
the same manner as  the supplementary groups described in
the preceding paragraph.

FreeBSD Based Explanation
The  id utility  displays the  user and  group  names and
numeric  IDs, of  the  calling process,  to the  standard
output.   If the  real and  effective IDs  are different,
both are  displayed, otherwise only  the real ID  is dis-
played.

If a user (login name  or user ID) is specified, the user
and group IDs of that  user are displayed.  In this case,
the real and effective IDs are assumed to be the same.

logname – print user´s login name

A UNIX Command

$logname
jeffrin
$logname --help
Usage: logname [OPTION]
Print the name of the current user.

      --help     display this help and exit
      --version  output version information and exit

Report logname bugs to bug-coreutils@gnu.org
GNU coreutils home page: 
General help using GNU software: 
For complete documentation, run: info coreutils 'logname invocation'
$logname --version
logname (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by FIXME: unknown.
$

UNIX Explanation

Solaris Based Explanation
The logname  utility will write the user's  login name to
standard output.  The login name is the string that would
be  returned  by the  getlogin(3C)  function.  Under  the
conditions  where  getlogin()  would fail,  logname  will
write  a diagnostic  message to  standard error  and exit
with a non-zero exit status.

csplit – split a file into sections determined by context lines

A UNIX Command

$cat test.text
hello
how
are you ?
$csplit test.text 1
0
20
$cat xx00
$cat xx01
hello
how
are you ?
$rm xx*
$csplit test.text 2
6
14
$cat xx00
hello
$cat xx01
how
are you ?
$rm xx*
$csplit test.text 3
10
10
$cat xx01
are you ?
$cat xx00
hello
how
$csplit test.text 4
20
csplit: `4': line number out of range
$cat xx01
are you ?
$ls xx00
ls: cannot access xx00: No such file or directory
$


UNIX Explanation

Output pieces  of FILE  separated by PATTERN(s)  to files
`xx00', `xx01', ..., and output byte counts of each piece
to standard output.

truncate – shrink or extend the size of a file to the specified size

A UNIX Command

$cat example.text
hello
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 6 Jun 21 02:32 example.text
$truncate -s 10 example.text
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 10 Jun 21 02:35 example.text
$hexdump example.text
0000000 6568 6c6c 0a6f 0000 0000
000000a
$cat example.text
hello
$truncate -s 9 example.text
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 9 Jun 21 02:36 example.text
$hexdump example.text
0000000 6568 6c6c 0a6f 0000 0000
0000009
$

UNIX Explanation

`truncate' shrinks  or extends the  size of each  FILE to
the specified size.If a FILE is larger than the specified
size, the extra  data is lost.  If a  FILE is shorter, it
is extended and the extended part (or hole) reads as zero
bytes.

xwd – dump an image of an X window

A UNIX Command

$xwd -out ldump
$du -h ldump
1.4M	ldump
$hexdump -n 1 ldump
0000000 0000
0000001
$hexdump -n 5  ldump
0000000 0000 7600 0000
0000005
$hexdump -n 10   ldump
0000000 0000 7600 0000 0700 0000
000000a
$hexdump -n 50   ldump
0000000 0000 7600 0000 0700 0000 0200 0000 1000
0000010 0000 0004 0000 ad02 0000 0000 0000 0000
0000020 0000 2000 0000 0000 0000 2000 0000 1000
*
0000030
$

UNIX Explanation

Xwd is  an X Window  System window dumping  utility.  Xwd
allows  X users  to store  window images  in  a specially
formatted  dump file.   This  file can  then  be read  by
various  other  X   utilities  for  redisplay,  printing,
editing,  formatting, archiving,  image  processing, etc.
The target window is  selected by clicking the pointer in
the desired  window.  The keyboard  bell is rung  once at
the  beginning of  the dump  and twice  when the  dump is
completed.