LAB4 : grep, find, exec, tar and chmod



THE grep COMMAND
    Search one one more files fo lines that match a regular expression pattern
ARCHIVING
  1. tar [options] dir.tar dir
    1. <bash prompt> tar cvf aero361.tar aero361 ______> this will create a tar archive of aero361
    2. <bash prompt> tar xvf aero361.tar _____________> this will unroll the tar archive aero361.tar and leave you with aero361
  2. gzip 
    1. <bash prompt> gzip  aero361.tar ______________> this will compress the file aero361.tar
    2. gunzip file.gz or dir.tar.gz
  3. bzip2
    1. bzip2 file or dir.tar
    2. bunzip2 file.bz2 or dir.tar.bz2
Eventually you will want to archive your aero361 dir so that it does not take up too much disk space. Most often, programs in the net are bundled in a tarball and compressed.
THE | SYMBOL

The | symbol allows the standard output of one command to become the stanadard input to another command in the same line e.g.
THE find COMMAND
    An extremely useful tool to find files and executable in a dir. It comes very habdy in finding the infernal core file.You will all dump cores, infact some of you have them sitting in your dir like some parasite eating up precious disk space. Core files are only useful in debugging to find where and how some program crashed, otherwise they are waste of space!


FILE PERMISSIONS
Files and dirs in a unix system have associated ownership. Some belong to root, system, and other belong you. You need to understand how to manage permissions. The permissions also allow you lock poeple out of drs and files. If you want your classmate to only read a certain file, but not change anything then you need to apply the proper permissions on the file. The same can be done for dirs. This is a security issue, you may have dir that needs to be accessed by your team, but you do not want them to see the contents of the dir. All these securtity protocols can be accomplished with
chmod [options] files or dirs
  • cp some src dir in some aero361 project and name it something. You will be playing with the contents of this dir so make sure you are playing in the copy of some src that you need for your project.
  • type ls -l
drwxr-xr-x    2 viper    users          70 Nov 15 17:54 Back/
-rw-r--r--    1 viper    users        5668 Jan 24 09:00 basis.f95
-rw-r--r--    1 viper    users        6920 Jan 24 09:00 basis.g90
-rw-r--r--    1 viper    users       16892 Jan 24 09:00 basis.o
-rw-r--r--    1 viper    users        4030 Jan 20 10:12 spline.f95
-rw-r--r--    1 viper    users        6244 Jan 22 21:28 spline.g90
-rw-r--r--    1 viper    users       14032 Jan 22 21:28 spline.o
  • in the above example 
    • 1st column contains the permissions a "d" preceeding the permissions means dir
    • 2nd column contains the address
    • 3rd column contains the owners name
  • Concentrate your attention on the 1st column
    • ---         ---         ---
    • user   group  other
LETTER
PERMISSION
OCTAL VALUE
---
No permissions
0
r--
Read only
4
rw-
read and write permissions
6
rwx
read,write and execute permissions
7
r-x
read and execute permissions
5
--x
execute permissions only
1


PERMISSIONS
NUMBER FORM
SYMBOLIC FORM
WHAT JUST HAPPENED
-rw-------
600
u=rw
Owner has read and write permissions. Set for most files
-rw-r--r--
644
u=rw,g=r,o=r
Owner has read and write permissions; group has read permisions and other have read permissions
-rw-rw-rw-
666
a=rw
all have read write permissions
-rwx------
700
u=rwx
only owner has read, write and execute permissions
-rwxr-xr-x
755
u=rwx,go=rx
Owner has read,write and execute; group has read and execute; other has read and execute
-rwxrwxrwx
777
a=rwx
all have read write permissions
-rwx-x--x
711
u=rwx,go=x
Owner read, write and execute permisions; group and other have exucute permissions
  • How to change the permissions
    • chmod 777 file1
      • this will give all rwx permissions
    • chmod 700 file1
      • rwx only to lyou
    • chmod og +x file1
      • add execute permissions to group and other
    • chmod og -x file1
      • takes the execute permissions away from group and other