Search This Blog

Monday, December 29, 2008

Use of "find" command in Linux

http://www.cyberciti.biz/tips/linux-findinglocating-files-with-find-command-part-2.html

In the first part we talked about find command basic usage.

Now let us see how to use find command
(a) To gain lots of useful information about users and their files

(b) Monitor and enhance the security of system using find command

Finding all set user id files

setuid ("suid") and setgid are access right flags that can be assigned to files and directories on a Unix based operating system. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.
# find / -perm +u=s
OR
# find / -perm +4000

See also, shell script to find all programs and scripts with setuid set on.

Finding all set group id files

# find / -perm +g=s
OR
# find / -perm +2000

See also, shell script to find all programs and scripts with setgid bit set on.

Finding all large directories

To find all directories taking 50k (kilobytes) blocks of space. This is useful to find out which directories on system taking lot of space.
# find / -type d -size +50k
Output:

/var/lib/dpkg/info
/var/log/ksymoops
/usr/share/doc/HOWTO/en-html
/usr/share/man/man3

Finding all large files on a Linux / UNIX

# find / -type f -size +20000k
Output:

var/log/kern.log
/sys/devices/pci0000:00/0000:00:02.0/resource0
/sys/devices/pci0000:00/0000:00:00.0/resource0
/opt/03Jun05/firefox-1.0.4-source.tar.bz2

However my favorite hack to above command is as follows:
# find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

/var/log/kern.log: 22M
/sys/devices/pci0000:00/0000:00:02.0/resource0: 128M
/sys/devices/pci0000:00/0000:00:00.0/resource0: 256M
/opt/03Jun05/firefox-1.0.4-source.tar.bz2: 32M

Above command will find all files block size greater than 20000k and print filename followed by the file size. Output is more informative as compare to normal find command output :D

Friday, December 19, 2008

Short LaTex Math Guide

A short LaTex Math Guide can be found here.

Click the link to download a pdf file.

Thursday, December 18, 2008

Archive command summary (ar)

How to use "ar" command to generate library is here.

Some examples are:
  1. To create a library, enter:

    ar -v -q lib.a strlen.o strcpy.o

    If the lib.a library does not exist, this command creates it and enters into it copies of the files strlen.o and strcpy.o. If the lib.a library does exist, then this command adds the new members to the end without checking for duplicate members. The v flag sets verbose mode, in which the ar command displays progress reports as it proceeds.

  2. To list the table of contents of a library, enter:

    ar -v -t lib.a

    This command lists the table of contents of the lib.a library, displaying a long listing similar to the output of the ls -l command. To list only the member file names, omit the -v flag.

  3. To replace or add new members to a library, enter:

    ar -v -r lib.a strlen.o strcat.o

    This command replaces the members strlen.o and strcat.o. If lib.a was created as shown in example 1, then the strlen.o member is replaced. A member named strcat.o does not already exist, so it is added to the end of the library.

  4. To specify where to insert a new member, enter:

    ar -v -r -b strlen.o lib.a strcmp.o

    This command adds the strcmp.o file, placing the new member before the strlen.o member.

  5. To update a member if it has been changed, enter:

    ar -v -r -u lib.a strcpy.o

    This command replaces the existing strcpy.o member, but only if the file strcpy.o has been modified since it was last added to the library.

  6. To change the order of the library members, enter:

    ar -v -m -a strcmp.o lib.a strcat.o strcpy.o

    This command moves the members strcat.o and strcpy.o to positions immediately after the strcmp.o member. The relative order of the strcat.o and strcpy.o members is preserved. In other words, if the strcpy.o member preceded the strcat.o member before the move, it still does.

  7. To extract library members, enter:

    ar -v -x lib.a strcat.o strcpy.o

    This command copies the members strcat.o and strcpy.o into individual files named strcat.o and strcpy.o, respectively.

  8. To extract and rename a member, enter:

    ar -p lib.a strcpy.o >stringcopy.o

    This command copies the member strcpy.o to a file named stringcopy.o.

  9. To delete a member, enter:

    ar -v -d lib.a strlen.o

    This command deletes the member strlen.o from the lib.a library.

  10. To create an archive library from multiple shared modules created with the ld command, enter:

    ar -r -v libshr.a shrsub.o shrsub2.o shrsub3.o ...

    This command creates an archive library named libshr.a from the shared modules named shrsub.o, shrsub2.o, shrsub3.o, and so on. To compile and link the main program using the libshr.a archive library, use the following command:

    cc -o main main.c -L/u/sharedlib -lshr

    The main program is now executable. Any symbols referenced by the main program that are contained by the libshr.a archive library have been marked for deferred resolution. The -l flag specifies that the libshr.a library be searched for the symbols.

  11. To list the contents of lib.a, ignoring any 32-bit object file, enter:

    ar -X64 -t -v lib.a
  12. To extract all 32-bit object files from lib.a, enter:

    ar -X32 -x lib.a
  13. To list all files in lib.a, whether 32-bit, 64-bit, or non-objects, enter:

    ar -X32_64 -t -v lib.a

Monday, December 15, 2008

LSF user's quick reference guide

LSF User's Quick Reference can be found here.

Thanks.

Wednesday, December 10, 2008

Intel Compiler Options

Options -ip (Linux and Mac OS X) and /Qip (Windows) enable additional interprocedural optimizations  for  single-file compilation.

Option -fma enables the combining  of  floating-point  multiplies  and add/subtract operations. However, if you specify -mp  (Linux)  or -fp-model  strict  (Linux)  but do not explicitly specify -fma, the default  is -no-fma.


Environment Variables for Intel Compilers

export CC=icc
export CFLAGS='-O3 -mp -ip'
export CXX=icpc
export CXXFLAGS='-O3 -mp -ip'
export F77=ifort
export FFLAGS='-O3 -mp -ip'

Thursday, December 4, 2008

Ubuntu


Minimum X11 installation for Ubuntu server:  apt-get install xdm xfce4

Set Up Ubuntu-Server 6.10 As A Firewall/Gateway For Your Small Business Environment
Page: 1, 2, 3, 4, 5, 6, 7, and 8

How to install firefox in Ubuntu: sudo apt-get install firefox

Tuesday, December 2, 2008

Happy Face in LaTex

$\ddot\smile$

Try!

Labels