(Advanced Interactive eXecutive)
(Hewlett Packard Unix)
(Silicon Graphics, Inc.)

File Security in Unix:

On a Unix System all files & directories have permissions in 3 classes.

  1. User class represents the file or directory owner of which there can only be 1.
  2. Group class represents the group that has been assigned to the file or dir, only 1 group.
  3. Other class – all other users outside of the user and group classes.

There are 3 main types of permissions:
r – Read file: read contents of the file
dir: read the names of files contained within the directory but no other information.
the directory. Only 1 group.

w – write – file modify the contents of a file
dir -> rename, create, delete files in the directory
x – execute – file -> execute binary executable file (application)
dir -> means that you can traverse this directory to access files or subdirectories.

Note: there are additional permissions that can be set on files/directories, however these represent the bulk you will need.

Modifying File Classes/Permissions:
chown -> change ownership: must be a priveleged user. (i.e. – root)
syntax -> chown [options] newuser[:newgroup] files
option -R recursive

chgrp – change group
syntax -> chgrp [options] new_group files
option -R recursive

chmod -change access_mode
syntax: chmod [options] mode files
mode can be specified as follows

define who:
define how:
define what:
u-user, o-other
+-add, -remove
g-group, a-all

r=read, w=write, x=execute

ls -l
rwx rwx rwx r-xr–r–
user group other

Alternatively, we can set permissions via a 3-octal sequence (0-7).
digit 1 – user
2 – group
3 – other

bit 1 – 4 – read
2 – 2 – write
3 – 1 – execute

chmod u+x file.out
chmod -R755 /webs/*

Additional Commands in Unix

MD5SUM – Computes an MD5 hash (CRC):Checksum
CRC – Cyclic Redundancy Check
syntax -> md5sum [options] [file]
md5sum [options] –check sum [file] -> can redirect output to md5 file

see cksum
sha1sum which are both popular checksums

Unix Job Control:
Any currently executing application is called a process.
Unix supports the concurrent execution of processes.
How to execute >= 1 process without windows (note lower case w in the windows).
Commands that we need to know:
ps -> snapshot of executing processes (live processes).
command & -> execute ‘command’ in the background
jobs – list the active & suspended jobs.
fg – bring a job to the foreground.
bg – execute a process in the background.
suspend – pause execution of a process.
wait – wait for background processes to complete.
Ctrl+c – kills the active process (the one in the foreground).
Ctrl +z – suspend the foreground process.
Kill – terminate a process.

i.e. – java app &
java app > outfile &
ps will who it running in the background

grep -R cs * > test &
kill -9 pid_num

Searching Commands:
which -> gives the full path of executable that would be executed “which java” /usr/bin/java on pizza server.
find -> used to find files
syntax find [options] pathname(s) conditions
-name pattern
-group gname
-user uname

if pathname is omitted then current_path is searched

grep – find pattern in file
syntax grep [options] regexp [files]
-c count
-r R recursive
take output of other commands to search
command | grep pattern

cat file.out | grep pattern

Script: [very handy on assignment 3]
-record all items displayed on the screen
syntax script [options] [output_file]
options -> -a append
-f flush after each write (useful when scripting while another user watching file).

tail -uf file.out (way of watching log files).
‘exit’ to stop the script

Author: Anonymous

General Manager of Qingdao Saint John IT Co., Ltd.

Leave a Reply