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

0 comments:

Post a Comment

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