Linux Shell Scripting



$ rm -rf oldfiles
To change file access
permissions

u - User who owns the
file
g - Group file owner
o - User classified as
other
a - All other system user

+ Set permission
- Remove permission

r - Read permission
w - Write permission
x - Execute permission

chmod {u|g|o|a} {+|-} {r|w|x} {filename}
$ chmod
u+x,g+wx,o+x myscript

NOTE: This command set
permission for file called
'myscript' as User (Person
who creates that file or
directory) has execute
permission (u+x) Group of
file owner can write to this
file as well as execute this
file (g+wx) Others can
only execute file but can
not modify it, Since we
have not given w (write
permission) to them. (o+x).

Read your mail.
mail
$ mail
To See more about
currently login person
(i..e. yourself)

who am i
$ who am i
To login out
logout (OR press CTRL+D)
$ logout
(Note: It may ask
you password type
your login password,
In some case this
feature is disabled by
System
Administrator)
Send mail to other person mail {user-name}
$ mail ashish
To count lines, words and
characters of given file

wc {file-name}
$wc myfile
To searches file for line
that match a pattern.

grep {word-to-lookup} {filename}
$ grep fox
myfile
To sort file in following
order
-r Reverse normal order
-n Sort in numeric order
-nr Sort in reverse
numeric order

sort -r -n -nr {filename}
$sort myfile
Linux Shell Script Tutorial