Sunday 28 August 2011

Permissions in Linux

Create three users:

Example:

[root@test119 ~]# useradd kavita
[root@test119 ~]# useradd ramu
[root@test119 ~]# useradd srinu

Make ramu the member of the group kavita

Example:
[root@test119 ~]# gpasswd -a ramu kavita
Adding user ramu to group kavita


Create a directory


Example:

[root@test119 ~]# mkdir /linux

Check the default permission of the above created directory

[root@test119 ~]# ls -ld /linux/
drwxr-xr-x 2 root root 4096 Aug 28 11:26 /linux/

Give full permissions to the above created directory

Example using absolute mode

[root@test119 ~]# chmod 777 /linux/
                         (or)
Example using symbolic mode

[root@test119 ~]# chmod ugo=rwx /linux/

Check the permissions on the directory


[root@test119 ~]# ls -ld /linux/
drwxrwxrwx 2 root root 4096 Aug 28 11:26 /linux/

Log in as the user kavita

Example:

[root@localhost~]# su -kavita

As user kavita create a file inside the above created directory

-sh-4.1$ cd /linux/
-sh-4.1$ ls
-sh-4.1$
-sh-4.1$ cat >fedora
This is a version of linux operating system
ctrl+D

Check the permisson on the file


Example: 

-sh-4.1$ ls -l
total 4
-rw-r--r-- 1 kavita kavita 44 Aug 28 11:41 fedora

Explaination

1. The user kavita has Read and Write permission on this file
2. The group kavitha has read and write permisson on this file (as ramu is a member of the group kavita he     will also have rad and write permisson).
3. Others will have read only permisson ( as srinu belong to others he will have only read permisson).


To check the permissons


Example:- As kavita try to read and add some content to the file

-sh-4.1$ cat fedora
This is a version of linux operating system
-sh-4.1$ cat >> fedora
This line has been added by kavita
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita

Example:- As ramu try to read and add some content to the file ( open another terminal and do the following)

-sh-4.1$ su - ramu
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
-sh-4.1$ cat >> fedora
This line has been added by ramu

Example:- As srinu to read and add some content to the file (Open another terminal and do the following)

[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
cat: fedora: Permission denied

Change the permisson on the above file


Example:- Remove write permission for the group kavita

-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod g=r fedora
-sh-4.1$ ls -l
total 4
--w-r---w- 1 kavita kavita 106 Aug 28 12:04 fedora


Check the permisson on the above file


Example:- As ramu try to read and add some content to the file

-sh-4.1$ su - ramu
Password:
-sh-4.1$ whoami
ramu
-sh-4.1$
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
-sh: fedora: Permission denied

Change the permisson on the above file


Example:- Give write permission for others

-sh-4.1$ su - kavita
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod 646 fedora
-sh-4.1$ ls -l
total 4
-rw-r--rw- 1 kavita kavita 106 Aug 28 12:04 fedora

check the permisson on the above file

Example:- As srinu try to read and add some content to the file

[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
This line has been added by srinu
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
This line has been added by srinu

Friday 26 August 2011

Group Membership in Linux

Syntax:- 

[root@localhost~]# gpasswd <option> <arguments> <groupname>

Options:

-M -- Add multiple users to a group
-A -- Add a group Administrator
-a -- Add a single user to a group
-d -- Delete a user from a group


Example:- Add multiple users (ravi, sunil) to the group marketing
Note: Before doing this the group marketing should be exists.

[root@test119 ~]# gpasswd -M ravi,sunil marketing

To check if the users are added to the group

[root@test119 ~]# grep marketing /etc/group

marketing:x:2006:ravi,sunil


Example:- Add user rani as the administrator for the group marketing

[root@test119 ~]# useradd rani
[root@test119 ~]# gpasswd -A rani marketing

To check if rani has been added as the administrator for the group marketing

[root@test119 ~]# grep marketing /etc/gshadow
marketing:!:rani:ravi,sunil


Example:- Add a user ahmed to the group marketing

[root@test119 ~]# useradd ahmed
[root@test119 ~]# gpasswd -a ahmed marketing
Adding user ahmed to group marketing

To check if the user has been added to the group

[root@test119 ~]# grep marketing /etc/group
marketing:x:2006:ravi,sunil,ahmed


Example:- Delete the user ravi from the group marketing

[root@test119 ~]# gpasswd -d ravi marketing
Removing user ravi from group marketing

To check if the user has been deleted from the group

[root@test119 ~]# grep marketing /etc/group
marketing:x:2006:sunil,ahmed

Creating a user along with it Group Membership

Example:- Creating a user sri with primary group as hr and member of the group finance

[root@test119 ~]# groupadd hr
[root@test119 ~]# groupadd finance
[root@test119 ~]# useradd -g hr -G finance sri

To check if the user has been created along with group membership

[root@test119 ~]# grep sri /etc/passwd /etc/group
/etc/passwd:sri:x:2008:2009::/home/sri:/bin/sh
/etc/group:finance:x:2010:sri

Adding or Modifying or Deleting users and groups using a graphical tool

Open the graphical too using command


[root@test119 ~]# system-config-users &


Group Administration in Linux

Creating a Group

Syntax:- 

[root@localhost~]# groupadd <groupname>

                          (or)

[root@localhost~]# groupadd <option> <argument> <groupname>

Options:

-g -- Group ID
-0 -- Override


Example:- Creating a group Sales with default options

[root@test119 ~]# groupadd sales


To check if the group has been created

[root@test119 ~]# tail -5 /etc/group

avdefs:x:504:
ali:x:2001:
tom:x:2002:
anu:x:2003:
sales:x:2004:


Example:- Creating a group mktg whose group id (GID) is 750

[root@test119 ~]# groupadd -g 750 mktg

To check if the group has been created

[root@test119 ~]# tail -5 /etc/group

ali:x:2001:
tom:x:2002:
anu:x:2003:
sales:x:2004:
mktg:x:750:


Modifying the Properties of a Group


Syntax:-

[root@localhost~]# groupadd <option> <argument> <groupname>

Options:

-g -- Group ID
-o -- Override
-n -- Group Name


Example:- Change the GID of the group sale to 800

[root@test119 ~]# groupmod -g 800 sale

To check if the group ID has changed

[root@test119 ~]# tail -5 /etc/group

tom:x:2002:
anu:x:2003:
sales:x:2004:
mktg:x:750:
sale:x:800:

Deleting a group

Syntax:-

[root@localhost~]# groupdel <groupname>

Example:- Delete the group sale

[root@test119 ~]# groupdel sale


To check if the group has been deleted

[root@test119 ~]# tail -5 /etc/group ali:x:2001:
tom:x:2002:
anu:x:2003:
sales:x:801:
mktg:x:750:


Thursday 25 August 2011

Creating an User

Syntax :-


[roort@localhost~]# useradd <username>

or

[roort@localhost~]# useradd <option> <argument> <username>

Options:

-u -- UID                                                        -c -- comment

-g -- Primary Group Name or GID                  -d -- Home directory

-o -- Override                                                 -s -- Shell

-G -- Secondary Group

Example :- Creating a user ravi with defalut options

[root@test119 ~]# useradd ravi

To check if the  user has been created

[root@test119 ~]# tail -5 /etc/passwd

gdm:x:42:42::/var/lib/gdm:/sbin/nologin
Ganesh:x:500:500:Ganesh Tulagapu:/home/Ganesh:/bin/bash
ram:x:501:501:ramakrishna:/home/ram:/bin/bash
admin:x:503:503::/home/admin:/bin/sh
ravi:x:504:505::/home/ravi:/bin/sh



Example :- Creating a user ali whose user id (UID) is 2001


[root@test119 ~]# useradd -u 2001 ali

To check if the user has been created

[root@test119 ~]# tail -5 /etc/passwd

Ganesh:x:500:500:Ganesh Tulagapu:/home/Ganesh:/bin/bash
ram:x:501:501:ramakrishna:/home/ram:/bin/bash
admin:x:503:503::/home/admin:/bin/sh
ravi:x:504:505::/home/ravi:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh


Example :- Creating a user tom with a comment 'Manager'


[root@test119 ~]# useradd -c Manager tom


To check if the user has been created

[root@test119 ~]# tail -5 /etc/passwd

ram:x:501:501:ramakrishna:/home/ram:/bin/bash
admin:x:503:503::/home/admin:/bin/sh
ravi:x:504:505::/home/ravi:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
tom:x:2002:2002:Manager:/home/tom:/bin/sh

Example :- Creating a user anu whose home directory is inside /'salesdept'

Note: Before creating a user in salesdept, you should create a directory as /salesdept

[root@test119 ~]# useradd -d /salesdept/anu anu

To check if the user has been created

 [root@test119 ~]# tail -5 /etc/passwd

admin:x:503:503::/home/admin:/bin/sh
ravi:x:504:505::/home/ravi:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
tom:x:2002:2002:Manager:/home/tom:/bin/sh
anu:x:2003:2003::/salesdept/anu:/bin/sh

Example :- Creating a user Jack whose shell is 'c shell'

[root@test119 ~]# useradd -s /bin/csh Jack


To check if user has been created with 'c shell'


[root@test119 ~]# tail -5 /etc/passwd

ravi:x:504:505::/home/ravi:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
tom:x:2002:2002:Manager:/home/tom:/bin/sh
anu:x:2003:2003::/salesdept/anu:/bin/sh
Jack:x:2004:2004::/home/Jack:/bin/csh


Example :- Change the login name of user tom to jill


[root@test119 ~]# usermod -l jill tom

To check if the user has been Modified

[root@test119 ~]# tail -5 /etc/passwd

ravi:x:504:505::/home/ravi:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
anu:x:2003:2003::/salesdept/anu:/bin/sh
Jack:x:2004:2004::/home/Jack:/bin/csh
jill:x:2002:2002:Manager:/home/tom:/bin/sh


To delete a user

Syntax :- 

[root@localhost~]# userdel <option> <username>


Options:

-r -- Recursively (along with the home directory and mailbox)

Example :- Deleting the user ravi

[root@test119 ~]# userdel ravi

To check if the user has been deleted

ram:x:501:501:ramakrishna:/home/ram:/bin/bash
admin:x:503:503::/home/admin:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
anu:x:2003:2003::/salesdept/anu:/bin/sh
Jack:x:2004:2004::/home/Jack:/bin/csh
jill:x:2002:2002:Manager:/home/tom:/bin/sh

[root@test119 ~]# ls /home/
admin  ali  Ganesh  Jack  lost+found  ram  rama  ravi  tera  tom


Example :- Deleting the user Jack along his home directory and mail box
[root@test119 ~]# userdel -r Jack


To check if the user has been deleted

[root@test119 ~]# tail -6 /etc/passwd

Ganesh:x:500:500:Ganesh Tulagapu:/home/Ganesh:/bin/bash
ram:x:501:501:ramakrishna:/home/ram:/bin/bash
admin:x:503:503::/home/admin:/bin/sh
ali:x:2001:2001::/home/ali:/bin/sh
anu:x:2003:2003::/salesdept/anu:/bin/sh
jill:x:2002:2002:Manager:/home/tom:/bin/sh

[root@test119 ~]# ls /home/
admin  ali  Ganesh  lost+found  ram  rama  ravi  tera  tom

To view the details of a user from all database files

Example:- To view the details of a user anu

[root@test119 ~]# grep anu /etc/passwd /etc/shadow
/etc/passwd:anu:x:2003:2003::/salesdept/anu:/bin/sh
/etc/shadow:anu:!!:15211:0:99999:7:::


To view the UID and GID of a user

Example:- To view the details of a user Anu

[root@test119 ~]# id anu
uid=2003(anu) gid=2003(anu) groups=2003(anu)


To Change the Password Parameters

Syntax:-

[root@localhost~]# chage <username>

Example:- To change the Password Parameters for the User Jill

[root@test119 ~]# chage jill

Changing the aging information for jill
Enter the new value, or press ENTER for the default

        Minimum Password Age [0]: 1
        Maximum Password Age [99999]: 10
        Last Password Change (YYYY-MM-DD) [2011-08-25]:
        Password Expiration Warning [7]: 4
        Password Inactive [-1]:
        Account Expiration Date (YYYY-MM-DD) [1969-12-31]:


To check do the following steps:

1. Log off Root
2. Log in as Jill
3. Try changing the Password
4. Log off as Jill
5. Log in as Root
6. Change the system date to two days ahead
7. Log off as Root
8. Login as Jill
9. Try changing the Password

Wednesday 24 August 2011

Basic Commands - 2.1

To View the calender

Example : To see the current month

[root@localhost ~] # cal

     August 2011  
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Example : -   TO see the past, current and next month

[root@localhost ~] # cal -3
 
     July 2011            August 2011         September 2011 
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                1  2      1  2  3  4  5  6               1  2  3
 3  4  5  6  7  8  9   7  8  9 10 11 12 13   4  5  6  7  8  9 10
10 11 12 13 14 15 16  14 15 16 17 18 19 20  11 12 13 14 15 16 17
17 18 19 20 21 22 23  21 22 23 24 25 26 27  18 19 20 21 22 23 24
24 25 26 27 28 29 30  28 29 30 31           25 26 27 28 29 30 
31                                                             

Example :- To see the calender of the current year

[root@localhost ~] # cal -y

Example: To see the calender for the month of December for the year 2010

[root@localhost ~] # cal 12 2010

Example: To see the calender for the full year 2009

[root@localhost ~] # cal 2009

To View help for a command (manual Pages)


Syntax :-


[root@localhost ~] # man <command>


To See the help for the command mkdir

[root@localhost ~] # man mkdir

To View the top 10 lines of a file

Example :- 

[root@localhost ~] # head anaconda-ks.cfg

To View the top 5 lines of a file

Example :-


[root@localhost ~] # head -5 anaconda-ks.cfg

To view the bottom 10 lines of a file

Example :-

[root@localhost ~] # tail anaconda-ks.cfg

To view the bottom 3 lines of a file

Example :-

[root@localhost ~] # tail -3 anaconda-ks.cfg

Basic Commands - 2.0

Copying files and Directories

[root@localhost ~]# cp <option> <source> <destination>


Example :- To copy a file

[root@localhost ~]# cp completereport /opt

To check if the file has been copied

[root@localhost ~]# cd /opt

[root@localhost ~]# ls

completereport


Example :- To copy a directory

[root@localhost ~]# cp -r directory1/ /opt/

To check if the directory has been copied

[root@localhost ~]# cd /opt

[root@localhost ~]# ls

completereport directory1

Moving files and directories

Syntax :-

[root@localhost ~]# mv <option> <source> <destination>


Example :- To Move a file

[root@localhost ~]# salesreport /opt

To check if the file has been moved


completereport directory1 salesreport


Example :- To move a directory

[root@localhost ~]# mv dir1 /opt


To check if the directory has been moved

[root@localhost ~]# cd /opt

[root@localhost ~]# ls

completereport directory1 dir1 salesreport

Renaming files and directories

Syntax :- 

[root@localhost ~]# mv <old name> <new name>

Example :- To rename a file

[root@localhost ~]# mv completereport fullreport


To check if the file has been Renamed

[root@localhost ~]# ls

anaconda-ks.cfg  file1       install.log         savap-install.log
Desktop          file2       install.log.syslog  sav-install.log
directory1       file3       mktgreport          savjlu-install.log
directory2       file4       POOL.log            savui-install.log
directory3       fullreport  POOL.logpid
directory4       glassfish3  salesreport

Deleting an empty directory

Syntax :- 

 [root@localhost ~]# rmdir <directory name>

Example :- To delete an empty directory

[root@localhost ~]# rmdir directory2

To check if the directory has been deleted
anaconda-ks.cfg  file2        install.log.syslog  sav-install.log
Desktop          file3        mktgreport          savjlu-install.log
directory1       file4        POOL.log            savui-install.log
directory3       fullreport   POOL.logpid
directory4       glassfish3   salesreport
file1            install.log  savap-install.log

Deleting a file or directory

Syntax :-

 [root@localhost ~]# rm <option> <file or directory>

Options :

-r -- recursive
-f -- forcefully

Example :- To delete a file

[root@localhost ~]# rm file4

rm: remove regular empty file `file4'? y


To check if the file has been deleted

[root@localhost ~]# ls

anaconda-ks.cfg  file1       install.log         salesreport
Desktop          file2       install.log.syslog  savap-install.log
directory1       file3       mktgreport          sav-install.log
directory3       fullreport  POOL.log            savjlu-install.log
directory4       glassfish3  POOL.logpid         savui-install.log

To delete a file forcefully

[root@localhost ~]# rm -f mktgreport

To check if the file has been deleted

[root@localhost ~]# ls
anaconda-ks.cfg  file1       install.log         savap-install.log
Desktop          file2       install.log.syslog  sav-install.log
directory1       file3       POOL.log            savjlu-install.log
directory3       fullreport  POOL.logpid         savui-install.log
directory4       glassfish3  salesreport

Example :- To delete a directory

[root@localhost ~]# cd /opt

 [root@localhost ~]# rm -rf dir1


To check if the directory has been deleted

[root@localhost ~]# ls

completereport directory1 salesreport

To view the system date and time

[root@localhost ~]# date

Wed Aug 24 20:34:34 IST 2011

To change the system date and time

Syntax :-

[root@localhost ~]# date -s "MM/DD/YYYY hh:mm:ss"

Example:

[root@localhost ~]#date -s "07/15/2009 00:06:00"

Wed Jul 15 00:06:00 IST 2009

Monday 22 August 2011

Creating Directories & Directory Navigation

Syntax :-

[root@localhost~]# mkdir <option> <directory name>

Example :- Creating a single directory

[root@localhost~]# mkdir directory1

Example :- Creating multiple directories

[root@localhost~]# mkdir direcoty2 directory3 directory4

To check if the directories have been created

[root@localhost~]# ls -d directory*

directory1  directory2  directory3  directory4

Example :- To create nested directories (Sub directories inside directories)

[root@localhost~]# mkdir -p d1/d2/d3/d4

To check if the nested directories have been created

[root@localhost~]# ls -R d1

/d1:
d2

/d1/d2:
d3

/d1/d2/d3:
d4

/d1/d2/d3/d4:

Note :- To list the contents and create a file or directory in a location different from the present working directory, Specify the complete path (example /var/directory1)

Directory Navigation

Syntax :-

[root@localhost~]# cd <argument>

Example :- To go into a directory

[root@localhost~]# cd d1

[root@localhost d1]# cd d2

 [root@localhost d2]#

Example :- To back one level, type cd press spacebar then dot dot

[root@localhost d2]# cd ..

[root@localhost d1]#

Example :- To go back two levels

[root@localhost d1]# cd ../..

[root@localhost /]#

Example :- To go to the Previous working directory 

[root@localhost /]# cd -

/root/d1

Example :- To go to current logged in user's home directory

[root@localhost d1]#cd

[root@localhost ~]# pwd

/root

Basic Commands -1.2

Creating files and adding data using cat command

Syntax :-

[root@localhost~]# cat <option> <arguments>

Example :- To create a file along with some data

[root@localhost~]# cat > salesreport

This file contains the sales report for the month Aug.

( Now press Ctrl+d to Save )

Example :- To create one more  file along with some data

[root@localhost~]# cat > mktgreport

This file contains the mktg report for the month of Aug.


( Now press Ctrl+d to Save )



Example :- To read the contents of a file

[root@localhost~]# cat salesreport

This file contains the sales report for the month of Aug.

Example : - To append (add) to a file

[root@localhost~]# cat >> mktgreport

This year the efforts in mktg have increased.

Ctrl+D

Check the contents of the file mktgreport

[root@localhost~]# cat mktgreport

This file contains the mktg report for the month of Aug
This year the efforts in mktg have increased.


Example :- To merge contents of two files into a third file

[root@localhost~]# cat salesreport mktgreport >> completereport

Check the contents of the file Completereport

[root@localhost~]# cat completereport

This file contains the sales report for the month of Aug.
This file contains the mktg report for the month of Aug.
This year the efforts in mktg have increased.

Creating 0 byte (empty) files using touch command

 Syntax :- Creating a single file with the touch command 

 [root@localhost~]# touch <filename>

Example :- Creating a single file with touch command

[root@localhost~]# touch file1

To check if the file has been created

 [root@localhost~]# ls -ld file1

-rw-r--r--. 1 root root 0 Aug 23 09:13 file1

Example :- Creating multiple file using the touch command

[root@localhost~]# touch file2 file3 file4

To check if the file has been created

 [root@localhost~]# ls -ld file*

-rw-r--r--. 1 root root 0 Aug 23 09:13 file1
-rw-r--r--. 1 root root 0 Aug 23 09:16 file2
-rw-r--r--. 1 root root 0 Aug 23 09:16 file3
-rw-r--r--. 1 root root 0 Aug 23 09:16 file4

To change the timestamp (date and time of modification) of a file or directory

Syntax :-

 [root@localhost~]# touch <option> <arguments> <file or directory name>

Example :- To change to the current date and time

[root@localhost~]# touch file1

To check if the timestamp has changed

[root@localhost~]# ls -ld file1

-rw-r--r--. 1 root root 0 Aug 23 09:20 file1

Syntax :-

[root@localhost~]#  touch -t YYYYMMDDHHMM <file or directory name>

Example :- To change to a different date and time

[root@localhost~]# touch -t 200905150842 file2

To check if the timestamp has changed

[root@localhost~]# ls -ld file2

-rw-r--r--. 1 root root 0 May 15  2009 file2


Sunday 21 August 2011

Basic Commands -1.1

To check the Present working directory

Syntax :-
[root@localhost`]# pwd

Example :-
[root@localhost~]# pwd
/root


To See the contents of a directory (folder)


Syntax :-
[root@localhost~]# ls <option> <argument>

Options:

-l          Long list including attributes
 -a         All files and directories including hidden
-d         To check for a particular file or directory
-R        Recursively, to see the contents in a tree structure


Example :- To list the contents of the present working Directory



[root@localhost~]# ls
 anaconda-ks.cfg    install.log.syslog  POOL.logpid
Desktop          install.log  POOL.log
Example :- To see the list of files and directories along with their attributes (Properties)

[root@localhost~]# ls -l
 total 96
-rw-------. 1 root root  1280 Jul  3 00:46 anaconda-ks.cfg
drwxr-xr-x. 2 root root  4096 Jul 15 14:47 Desktop
drwxr-xr-x. 2 root root  4096 Jul 15 16:38 glassfish3
-rw-r--r--. 1 root root 56509 Jul  3 00:46 install.log
-rw-r--r--. 1 root root 12953 Jul  3 00:44 install.log.syslog
-rw-r--r--. 1 root root   822 Aug 16 11:22 POOL.log
-rw-r--r--. 1 root root    32 Aug 16 11:22 POOL.logpid

Example :- To see all files and directories including hidden files of files and directories

[root@localhost~]# ls -a
.                .bash_profile  .gconfd             .lesshst     .tcshrc
..               .bashrc        glassfish3          .macromedia  .updatetool
anaconda-ks.cfg  .config        .gnome2             .nbi         .viminfo
.asadminpass     .cshrc         install.log         POOL.log     .xauthsjBb2W
.bash_history    Desktop        install.log.syslog  POOL.logpid
.bash_logout     .gconf         .java               .ssh


Example :- To check if a perticular file or directory is present

[root@localhost~]# ls -d Desktop
Desktop

Example :- To see tree structure of nested directories

[root@localhost~]# ls -R
/opt:
galaxy
/opt/galaxy:
galaxya
/opt/galaxy/galaxya:
galaxyb
/opt/galaxy/galaxya/galaxyb:
galaxys
/opt/galaxy/galaxya/galaxyb/galaxys:

Example :- To see a list of all file or directories starting with a perticular letter

[root@localhost~]# ls i*
install.log  install.log.syslog

Example :-  To see the attributes of a perticular file or directory

[root@localhost~]# ls -ld install.log.syslog
 -rw-r--r--. 1 root root 12953 Jul  3 00:44 install.log.syslog

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews