Linux Examples

From MediaWiki

(Difference between revisions)
Jump to: navigation, search
 
(29 intermediate revisions not shown)
Line 1: Line 1:
-
This page is dedicted to people who wants to get familiar with basic usage of Linux shell. In this exercise will be demonstrated basic of navigating the file system, standard Linux commands, archive tools, data management, basics of bash script language.
+
This page is dedicted to people who wants to get familiar with basic usage of Linux shell. In this exercise will be demonstrated basic of navigating the file system, standard Linux commands, archive tools, data management, basics of bash script language. For more tutorials and exercise use google.
Let`s get started:
Let`s get started:
-
==1. ls command==
+
==ls command==
-
List folder:
+
List folder :
  [ngrkic@ui ~]$ ls /tmp
  [ngrkic@ui ~]$ ls /tmp
-
You will get output simular like this:  
+
You will get output simular like this :  
  007-01-22 people                misanu
  007-01-22 people                misanu
Line 27: Line 27:
  [ngrkic@ui ~]$ ls -las
  [ngrkic@ui ~]$ ls -las
-
You will get output simular like this:  
+
You will get output simular like this :  
Line 52: Line 52:
     28 -rw-rw-r--  1 ngrkic ngrkic      27854 Sep 20  2010 gctest.prj
     28 -rw-rw-r--  1 ngrkic ngrkic      27854 Sep 20  2010 gctest.prj
-
==2. pwd command==
+
==pwd command==
Print name of current/working directory:  
Print name of current/working directory:  
Line 58: Line 58:
  [ngrkic@ui ~]$ pwd
  [ngrkic@ui ~]$ pwd
-
You will get something like this:
+
You will get something like this :
  /home/ngrkic
  /home/ngrkic
-
==3. cd command==
+
==cd command==
To change directory to /tmp type :
To change directory to /tmp type :
Line 88: Line 88:
  [ngrkic@ui ~]$ cd
  [ngrkic@ui ~]$ cd
-
==4. mkdir command==
+
==mkdir command==
-
When you want to make new folder type next:
+
When you want to make new folder type next :
-
  [ngrkic@ui ~]$ mkdir testdir
+
  [ngrkic@ui ~]$ mkdir testdirNikola
-
==5. touch command==
+
==touch command==
-
If you want to make empty file, you can do it with touch command like this:
+
If you want to make empty file, you can do it with touch command like this :
   [ngrkic@ui ~]$ touch testfile
   [ngrkic@ui ~]$ touch testfile
 +
 +
==cp command==
 +
 +
For copying files type :
 +
 +
[ngrkic@ui ~]$ cp testfile testdirNikola/
 +
 +
For copying folder to /tmp folder type :
 +
 +
[ngrkic@ui ~]$ cp -rf testdirNikola /tmp/
 +
 +
==mv command==
 +
 +
To move file type :
 +
 +
[ngrkic@ui ~]$ mv testfile testdirNikola/
 +
 +
To move folder :
 +
 +
[ngrkic@ui ~]$ cp -mv testdirNikola /tmp/
 +
 +
==rm command==
 +
 +
To delete file from folder type :
 +
 +
[ngrkic@ui ~]$ rm  /tmp/testdirNikola/testfile
 +
 +
To delete a folder :
 +
 +
[ngrkic@ui ~]$ rm -rf /tmp/testdirNikola
 +
 +
==chmod command==
 +
First lets touch testfile :
 +
 +
[ngrkic@ui ~]$ touch testfile
 +
 +
Then list the file like this:
 +
 +
[ngrkic@ui ~]$ ls -ls testfile
 +
 +
You will get this output :
 +
 +
0 -rw-rw-r-- 1 ngrkic ngrkic 0 Mar 23 22:55 testfile
 +
 +
When you want to add or remove perrmision type command in this syntax :
 +
 +
[ngrkic@ui ~]$ chmod u+x testfile
 +
 +
Now list again and you will get next output :
 +
 +
  0 -rwxrw-r-- 1 ngrkic ngrkic 0 Mar 23 22:56 testfile
 +
 +
==top command==
 +
 +
When you need information about current status of computer type :
 +
 +
[ngrkic@ui ~]$ top
 +
 +
==ps command==
 +
 +
When you need a snapshot of current state of process type :
 +
 +
[ngrkic@ui ~]$ ps aux
 +
 +
You will get simular output to this one :
 +
 +
kic  19409  0.0  0.0  90136  1852 ?        S    22:39  0:00 sshd: ngrkic@pts/9
 +
ngrkic  19410  0.0  0.0  66220  1684 pts/9    Ss  22:39  0:00 -bash
 +
ngrkic  19600  0.0  0.0  65632  984 pts/9    R+  23:03  0:00 ps aux
 +
root    24045  0.0  0.1  90160  3316 ?        Ss  Mar17  0:00 sshd: zlatko [priv]
 +
zlatko  24047  0.0  0.1  90492  2144 ?        S    Mar17  0:00 sshd: zlatko@notty
 +
zlatko  24048  0.0  0.1  54028  2180 ?        Ss  Mar17  0:00 /usr/libexec/openssh/sftp-server
 +
root    24104  0.0  0.1  90160  3344 ?        Ss  Mar17  0:00 sshd: zlatko [priv]
 +
zlatko  24106  0.0  0.0  90160  1908 ?        S    Mar17  0:00 sshd: zlatko@pts/1
 +
zlatko  24107  0.0  0.0  66228  1652 pts/1    Ss  Mar17  0:00 -bash
 +
zlatko  24166  0.0  0.1  58388  3212 pts/1    S+  Mar17  0:00 ssh n89
 +
root    28045  0.0  0.0  62628  1216 ?        Ss  Mar19  0:00 /usr/sbin/sshd
 +
nobody  30385  0.0  0.1 103000  2316 ?        Ss  Feb10  0:04 /usr/sbin/gmond
 +
root    31963  0.0  0.1  90132  3284 ?        Ss  Mar22  0:00 sshd: igor [priv]
 +
igor    31965  0.0  0.0  90328  2064 ?        S    Mar22  0:00 sshd: igor@pts/3
 +
igor    31966  0.0  0.0  66232  1656 pts/3    Ss  Mar22  0:00 -bash
 +
igor    32026  0.0  0.1  58524  3348 pts/3    S+  Mar22  0:00 ssh -X n89
 +
root    32247  0.0  0.1  90160  3336 ?        Ss  Mar15  0:00 sshd: jaksa [priv]
 +
jaksa    32249  0.0  0.0  90160  1964 ?        S    Mar15  0:00 sshd: jaksa@pts/8
 +
jaksa    32250  0.0  0.0  66228  1688 pts/8    Ss+  Mar15  0:00 -bash
 +
root    32507  0.0  0.1  90132  3280 ?        Ss  Mar22  0:00 sshd: zeki [priv]
 +
zeki    32509  0.0  0.0  90132  1840 ?        S    Mar22  0:00 sshd: zeki@pts/4
 +
zeki    32510  0.0  0.0  66228  1748 pts/4    Ss+  Mar22  0:00 -bash
 +
 +
==kill command==
 +
 +
When you need to end your process type :
 +
 +
[ngrkic@ui ~]$ kill 100
 +
 +
Where 100 is number of process.
 +
 +
==du command==
 +
 +
When you want get information how much space takes folder or file, type:
 +
 +
[ngrkic@ui ~]$ du -sh /tmp
 +
 +
1.5G /tmp
 +
 +
==df command==
 +
 +
df reports file system disk space usage
 +
 +
[ngrkic@ui ~]$ df -h
 +
 +
==man command==
 +
 +
If you need more documentation for some command (for example ls) type :
 +
 +
[ngrkic@ui ~]$ man ls
 +
 +
Where you enter in man reading mode
 +
 +
LS(1)                            User Commands                          LS(1)
 +
 +
NAME
 +
      ls - list directory contents
 +
 +
SYNOPSIS
 +
      ls [OPTION]... [FILE]...
 +
 +
DESCRIPTION
 +
      List  information  about  the  FILEs  (the  current  directory  by
 +
      default).  Sort entries alphabetically if none  of  -cftuvSUX  nor
 +
      --sort.
 +
 +
      Mandatory  arguments  to  long  options  are  mandatory  for short
 +
      options too.
 +
 +
      -a, --all
 +
              do not ignore entries starting with .
 +
 +
      -A, --almost-all
 +
              do not list implied . and ..
 +
 +
      --author
 +
              with -l, print the author of each file
 +
 +
      -b, --escape
 +
              print octal escapes for nongraphic characters
 +
 +
      --block-size=SIZE
 +
              use SIZE-byte blocks
 +
 +
      -B, --ignore-backups
 +
              do not list implied entries ending with ~
 +
 +
==grep  & pipe commands==
 +
 +
To grep type (for example ps command) :
 +
 +
[ngrkic@ui ~]$ ps aux | grep ngrkic
 +
 +
You will see output simular to this :
 +
 +
ngrkic  19409  0.0  0.0  90136  1852 ?        S    22:39  0:00 sshd: ngrkic@pts/9
 +
ngrkic  19410  0.0  0.0  66220  1684 pts/9    Ss  22:39  0:00 -bash
 +
ngrkic  19684  0.0  0.0  65632  984 pts/9    R+  23:22  0:00 ps aux
 +
ngrkic  19685  0.0  0.0  61192  724 pts/9    R+  23:22  0:00 grep ngrkic
 +
 +
 +
==cat command==
 +
When you want to see content of file in output type :
 +
 +
[ngrkic@ui ~]$ cat .bash_profile
 +
 +
Output will be like this:
 +
 +
# .bash_profile
 +
 +
# Get the aliases and functions
 +
if [ -f ~/.bashrc ]; then
 +
. ~/.bashrc
 +
fi
 +
 +
# User specific environment and startup programs
 +
 +
PATH=$PATH:$HOME/bin
 +
 +
export PATH
 +
unset USERNAME
 +
 +
==less command==
 +
 +
When you want just to read some file, type :
 +
 +
  [ngrkic@ui ~]$ less .bash_profile
 +
 +
==tar command==
 +
 +
If you need to make arhive, type :
 +
 +
[ngrkic@ui ~]$ tar -cjf testdirarhiva.tar.bz testdir/
 +
 +
When you need to unpack arhive, type :
 +
 +
[ngrkic@ui ~]$ tar -xjf testdirarhiva.tar.bz testdir/
 +
 +
==scp command==
 +
 +
When you want to copy fire or folder to remote host, type :
 +
 +
[ngrkic@ui ~]$ scp testfile ngrkic@ui.ipb.ac.rs:
 +
 +
If you want to copy folder, type:
 +
 +
[ngrkic@ui ~]$ scp -r testdir ngrkic@ui.ipb.ac.rs:
 +
 +
 +
==Script examples==
 +
 +
Simpe example:
 +
 +
#!/bin/bash
 +
clear
 +
echo "ls > file_list"
 +
ls > file_list
 +
 
 +
echo "ls -la >> file_list"
 +
ls -la >> file_list
 +
 
 +
echo "cat < file_list"
 +
cat < file_list
 +
 +
 +
for loop example:
 +
 +
for i in 1 2 3 4 5
 +
do
 +
echo "Welcome $i times"
 +
done
 +
 +
 +
while example:
 +
 +
#!/bin/sh
 +
#
 +
#Script to test while statement
 +
#
 +
if [ $# -eq 0 ]
 +
then
 +
    echo "Error - Number missing form command line argument"
 +
    echo "Syntax : $0 number"
 +
    echo " Use to print multiplication table for given number"
 +
exit 1
 +
fi
 +
n=$1
 +
i=1
 +
while [ $i -le 10 ]
 +
do
 +
  echo "$n * $i = `expr $i \* $n`"
 +
  i=`expr $i + 1`
 +
done
 +
 +
case example:
 +
 +
# if no vehicle name is given
 +
# i.e. -z $1 is defined and it is NULL
 +
#
 +
# if no command line arg are sdf
 +
 
 +
if [ -z $1 ]
 +
then
 +
  rental="*** Unknown vehicle ***"
 +
elif [ -n $1 ]
 +
then
 +
# otherwise make first arg as rental
 +
  rental=$1
 +
fi
 +
 
 +
case $rental in
 +
    "car") echo "For $rental Rs.20 per k/m";;
 +
    "van") echo "For $rental Rs.10 per k/m";;
 +
    "jeep") echo "For $rental Rs.5 per k/m";;
 +
    "bicycle") echo "For $rental 20 paisa per k/m";;
 +
    *) echo "Sorry, I can not gat a $rental for you";;
 +
esac
 +
 +
if example:
 +
 +
#!/bin/bash
 +
 
 +
if test -s $1
 +
then
 +
        echo "$1 not empty file"
 +
fi
 +
 
 +
if test -f $1
 +
then
 +
        echo "$1 normal file. Not a directory"
 +
fi
 +
if test -e $1
 +
then
 +
    echo "$1 exists"
 +
fi
 +
 
 +
if test -d $1
 +
then
 +
        echo "$1 is directory and not a file"
 +
fi
 +
 
 +
if test -r $1
 +
then
 +
        echo "$1 is read-only file"
 +
fi
 +
 
 +
if test -x $1
 +
then
 +
        echo "$1 is executable"
 +
fi

Latest revision as of 08:50, 25 March 2011

This page is dedicted to people who wants to get familiar with basic usage of Linux shell. In this exercise will be demonstrated basic of navigating the file system, standard Linux commands, archive tools, data management, basics of bash script language. For more tutorials and exercise use google.

Let`s get started:

Contents

ls command

List folder :

[ngrkic@ui ~]$ ls /tmp

You will get output simular like this :

007-01-22 people                 misanu
c                                 mpi-start
ce_hist                           node11_hist
course                            phpBB-3.0.8.tar.bz2
Epico.iso                         PPROBAMATLAB
fcub                              PROBAMATLAB
gctest                            realtimeoutput
gctest_main.c                     run_gctest.sh
gctest_mcc_component_data.c       run_gctestsing.sh
gctest.prj                        run_magicsquare.sh
gctestsing                        script.sh
gctestsing_main.c                 simulacija

For more details type :

[ngrkic@ui ~]$ ls -las

You will get output simular like this :


total 1011632
     4 drwx------ 38 ngrkic ngrkic       4096 Mar 22 21:18 .
     4 drwxr-xr-x 94 root   root         4096 Mar 21 10:38 ..
    16 -rw-------  1 ngrkic ngrkic      12482 Mar 23 12:01 .bash_history
     4 -rw-r--r--  1 ngrkic ngrkic         24 Jul 31  2009 .bash_logout
     4 -rw-r--r--  1 ngrkic ngrkic        191 Jul 31  2009 .bash_profile
     4 -rw-r--r--  1 ngrkic ngrkic        124 Jul 31  2009 .bashrc
     0 -rw-rw-r--  1 ngrkic ngrkic          0 Mar 22 21:18 c
     8 -rw-r--r--  1 ngrkic ngrkic       5619 Jul 31  2009 .canna
    20 -rw-r--r--  1 ngrkic ngrkic      20224 May  5  2010 ce_hist
     4 drwx------  3 ngrkic ngrkic       4096 Dec 10 15:47 .config
     4 drwxr-xr-x  8 ngrkic ngrkic       4096 Sep  7  2010 course
     4 drwxrwxr-x  4 ngrkic ngrkic       4096 Dec 10 15:43 .eclipse
     4 -rw-r--r--  1 ngrkic ngrkic        383 Jul 31  2009 .emacs
1008604 -rw-r--r--  1 ngrkic ngrkic 1031798784 Nov 25 16:42 Epico.iso
     4 drwxr-xr-x  5 ngrkic ngrkic       4096 Nov 29  2009 fcub
     4 drwxrwxr-x  3 ngrkic ngrkic       4096 Nov 29 10:06 .felix
   156 -rwxrwxr-x  1 ngrkic ngrkic     155129 Sep 20  2010 gctest
     4 -rw-rw-r--  1 ngrkic ngrkic       3513 Sep 20  2010 gctest_main.c
     8 -rw-rw-r--  1 ngrkic ngrkic       6115 Sep 20  2010 gctest_mcc_component_data.c
    28 -rw-rw-r--  1 ngrkic ngrkic      27854 Sep 20  2010 gctest.prj

pwd command

Print name of current/working directory:

[ngrkic@ui ~]$ pwd

You will get something like this :

/home/ngrkic

cd command

To change directory to /tmp type :

[ngrkic@ui ~]$ cd /tmp

Then type just cd :

[ngrkic@ui tmp]$ 

Now you are in your home folder (type pwd if you are not sure). If you want to go one folder back type :

[ngrkic@ui ~]$ cd ..

Now you are in system home folder.

When you want to go to root of filesystem, type :

[ngrkic@ui home]$ cd /

Now you are in / folder. If you want you can type ls to see content.

Now return to your home folder by typing :

[ngrkic@ui ~]$ cd

mkdir command

When you want to make new folder type next :

[ngrkic@ui ~]$ mkdir testdirNikola

touch command

If you want to make empty file, you can do it with touch command like this :

 [ngrkic@ui ~]$ touch testfile

cp command

For copying files type :

[ngrkic@ui ~]$ cp testfile testdirNikola/

For copying folder to /tmp folder type :

[ngrkic@ui ~]$ cp -rf testdirNikola /tmp/

mv command

To move file type :

[ngrkic@ui ~]$ mv testfile testdirNikola/

To move folder :

[ngrkic@ui ~]$ cp -mv testdirNikola /tmp/

rm command

To delete file from folder type :

[ngrkic@ui ~]$ rm  /tmp/testdirNikola/testfile

To delete a folder :

[ngrkic@ui ~]$ rm -rf /tmp/testdirNikola

chmod command

First lets touch testfile :

[ngrkic@ui ~]$ touch testfile

Then list the file like this:

[ngrkic@ui ~]$ ls -ls testfile

You will get this output :

0 -rw-rw-r-- 1 ngrkic ngrkic 0 Mar 23 22:55 testfile

When you want to add or remove perrmision type command in this syntax :

[ngrkic@ui ~]$ chmod u+x testfile

Now list again and you will get next output :

 0 -rwxrw-r-- 1 ngrkic ngrkic 0 Mar 23 22:56 testfile

top command

When you need information about current status of computer type :

[ngrkic@ui ~]$ top

ps command

When you need a snapshot of current state of process type :

[ngrkic@ui ~]$ ps aux

You will get simular output to this one :

kic   19409  0.0  0.0  90136  1852 ?        S    22:39   0:00 sshd: ngrkic@pts/9
ngrkic   19410  0.0  0.0  66220  1684 pts/9    Ss   22:39   0:00 -bash
ngrkic   19600  0.0  0.0  65632   984 pts/9    R+   23:03   0:00 ps aux
root     24045  0.0  0.1  90160  3316 ?        Ss   Mar17   0:00 sshd: zlatko [priv]
zlatko   24047  0.0  0.1  90492  2144 ?        S    Mar17   0:00 sshd: zlatko@notty
zlatko   24048  0.0  0.1  54028  2180 ?        Ss   Mar17   0:00 /usr/libexec/openssh/sftp-server
root     24104  0.0  0.1  90160  3344 ?        Ss   Mar17   0:00 sshd: zlatko [priv]
zlatko   24106  0.0  0.0  90160  1908 ?        S    Mar17   0:00 sshd: zlatko@pts/1
zlatko   24107  0.0  0.0  66228  1652 pts/1    Ss   Mar17   0:00 -bash
zlatko   24166  0.0  0.1  58388  3212 pts/1    S+   Mar17   0:00 ssh n89
root     28045  0.0  0.0  62628  1216 ?        Ss   Mar19   0:00 /usr/sbin/sshd
nobody   30385  0.0  0.1 103000  2316 ?        Ss   Feb10   0:04 /usr/sbin/gmond
root     31963  0.0  0.1  90132  3284 ?        Ss   Mar22   0:00 sshd: igor [priv]
igor     31965  0.0  0.0  90328  2064 ?        S    Mar22   0:00 sshd: igor@pts/3 
igor     31966  0.0  0.0  66232  1656 pts/3    Ss   Mar22   0:00 -bash
igor     32026  0.0  0.1  58524  3348 pts/3    S+   Mar22   0:00 ssh -X n89
root     32247  0.0  0.1  90160  3336 ?        Ss   Mar15   0:00 sshd: jaksa [priv]
jaksa    32249  0.0  0.0  90160  1964 ?        S    Mar15   0:00 sshd: jaksa@pts/8
jaksa    32250  0.0  0.0  66228  1688 pts/8    Ss+  Mar15   0:00 -bash
root     32507  0.0  0.1  90132  3280 ?        Ss   Mar22   0:00 sshd: zeki [priv]
zeki     32509  0.0  0.0  90132  1840 ?        S    Mar22   0:00 sshd: zeki@pts/4 
zeki     32510  0.0  0.0  66228  1748 pts/4    Ss+  Mar22   0:00 -bash

kill command

When you need to end your process type :

[ngrkic@ui ~]$ kill 100

Where 100 is number of process.

du command

When you want get information how much space takes folder or file, type:

[ngrkic@ui ~]$ du -sh /tmp

1.5G	/tmp

df command

df reports file system disk space usage

[ngrkic@ui ~]$ df -h

man command

If you need more documentation for some command (for example ls) type :

[ngrkic@ui ~]$ man ls

Where you enter in man reading mode

LS(1)                            User Commands                           LS(1)

NAME
      ls - list directory contents

SYNOPSIS
      ls [OPTION]... [FILE]...

DESCRIPTION
      List  information  about  the  FILEs  (the  current  directory  by
      default).  Sort entries alphabetically if none  of  -cftuvSUX  nor
      --sort.

      Mandatory  arguments  to  long  options  are  mandatory  for short
      options too.

      -a, --all
             do not ignore entries starting with .

      -A, --almost-all
             do not list implied . and ..

      --author
             with -l, print the author of each file

      -b, --escape
             print octal escapes for nongraphic characters

      --block-size=SIZE
             use SIZE-byte blocks

      -B, --ignore-backups
             do not list implied entries ending with ~

grep & pipe commands

To grep type (for example ps command) :

[ngrkic@ui ~]$ ps aux | grep ngrkic

You will see output simular to this :

ngrkic   19409  0.0  0.0  90136  1852 ?        S    22:39   0:00 sshd: ngrkic@pts/9
ngrkic   19410  0.0  0.0  66220  1684 pts/9    Ss   22:39   0:00 -bash
ngrkic   19684  0.0  0.0  65632   984 pts/9    R+   23:22   0:00 ps aux
ngrkic   19685  0.0  0.0  61192   724 pts/9    R+   23:22   0:00 grep ngrkic


cat command

When you want to see content of file in output type :

[ngrkic@ui ~]$ cat .bash_profile

Output will be like this:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

less command

When you want just to read some file, type :

 [ngrkic@ui ~]$ less .bash_profile

tar command

If you need to make arhive, type :

[ngrkic@ui ~]$ tar -cjf testdirarhiva.tar.bz testdir/

When you need to unpack arhive, type :

[ngrkic@ui ~]$ tar -xjf testdirarhiva.tar.bz testdir/

scp command

When you want to copy fire or folder to remote host, type :

[ngrkic@ui ~]$ scp testfile ngrkic@ui.ipb.ac.rs:

If you want to copy folder, type:

[ngrkic@ui ~]$ scp -r testdir ngrkic@ui.ipb.ac.rs:


Script examples

Simpe example:

#!/bin/bash
clear
echo "ls > file_list"
ls > file_list
 
echo "ls -la >> file_list"
ls -la >> file_list
 
echo "cat < file_list"
cat < file_list


for loop example:

for i in 1 2 3 4 5
do
echo "Welcome $i times"
done

while example:

#!/bin/sh
#
#Script to test while statement
#
if [ $# -eq 0 ]
then
   echo "Error - Number missing form command line argument"
   echo "Syntax : $0 number"
   echo " Use to print multiplication table for given number"
exit 1
fi
n=$1
i=1
while [ $i -le 10 ]
do
  echo "$n * $i = `expr $i \* $n`"
  i=`expr $i + 1`
done 

case example:

# if no vehicle name is given
# i.e. -z $1 is defined and it is NULL
#
# if no command line arg are sdf
 
if [ -z $1 ]
then
  rental="*** Unknown vehicle ***"
elif [ -n $1 ]
then
# otherwise make first arg as rental
  rental=$1
fi
 
case $rental in
   "car") echo "For $rental Rs.20 per k/m";;
   "van") echo "For $rental Rs.10 per k/m";;
   "jeep") echo "For $rental Rs.5 per k/m";;
   "bicycle") echo "For $rental 20 paisa per k/m";;
   *) echo "Sorry, I can not gat a $rental for you";;
esac

if example:

#!/bin/bash
 
if test -s $1
then
        echo "$1 not empty file"
fi
 
if test -f $1
then
        echo "$1 normal file. Not a directory"
fi
if test -e $1
then 
    echo "$1 exists"
fi 
 
if test -d $1
then
        echo "$1 is directory and not a file"
fi
 
if test -r $1
then
        echo "$1 is read-only file"
fi
 
if test -x $1
then
        echo "$1 is executable"
fi
Personal tools