Home   Notes   Contact Me

Unix Utilities

Local

See Commands by Name below

Commands By Name

External


od

Use od to show the raw data in a file.

// Show as unsigned ints: # od -t u1 version.txt 0000000 57 46 51 46 49 100 0000006 // Show as octal: # od version.txt 0000000 027071 027063 062061 0000006 // Show the contents as ascii: # od -t c version.txt 0000000 9 . 3 . 1 d 0000006

top

# show cpu activity and load info: top # type control-c to exit

id

Shows uid (userid), gid (groupid), and groups

# show your id info id # show the id info of another user id username

ldd

Shows what dynamic libraries an executable or dynamic library needs.

# Solaris ldd libMyStuff.so

nm

Shows what (?)symbols(?) are in an object file. Look for UNDEF symbols to see what it needs (good for figuring out what libraries it needs).

# nm stuff.o # to have it demangle c++ names (Solaris): nm -C stuff.o

mount

# Mounting a Solaris nfs share on a Red Hat Enterprise Linux machine # note that you are prompted for the password this way: mount -t cifs //solarisMachineName/sharedDirName /mnt/somedirectoryName -o username=usernameGoesHere

smbclient

I have had luck looking at Windows shares from Linux and from Solaris using smbclient. smbclient is very much like ftp. Type help to get a list of commands.

# mount a Windows share from a workgroup machine or a windows machine on a domain: smbclient //windowsMachineName/Xfer -U username

sort

commandaction
sort -t '>' -k 2.1 Sorts from the key field 2 starting at character 1, using > as the delimiter when finding the key field
So lines like this:
http://www.google.com/search?hl -> /notes/antivirus.html
would be sorted by their part like this:
 /notes/antivirus.html

cut

command action
cut -c 10- Removes the first 10 chars of each line
cut -d '>' -f 2 uses > as the field delimiter, and shows only field 2
in:
http://www.google.com/search?hl -> /notes/antivirus.html
out:
 /notes/antivirus.html

find

Good reference: http://linux.die.net/man/1/find

find . -print find . -name '*.jar' -print find . -name '*.jar' -exec jar -tvf {} \;

Skipping files

Inspired by http://www.cyberciti.biz/faq/find-command-exclude-ignore-files/

# Skips .png .css .gif and .js files then does a grep on the files it finds find . -type f \( ! -iname "*.png" ! -iname "*.css" ! -iname "*.gif" ! -iname "*.js" \) -exec grep -Hi whatever {} \;

sed

external


tar

# copy a directory using tar. # This copies links (instead of what they point to) # This was used under Solaris: cd {sourcedirectory} tar cpf - | (cd {dest directory} && tar -xvpBf - ) # for example: cd ~/junk/saveme tar cpf - | (cd ~/preserve && tar -xvpBf - )