Pages

LINUX ADMINISTRATION : BASIC COMMANDS

Wednesday 28 January 2015

1.To check the present working directory 

[root@localhost -]# pwd

Verification

 /root

2. To show the contents of a directory (folder)

 [root@localhost -]# ls

 Verification 

anaconda-ks.cfg Desktop install.log ipstall,log.syslog

3. To see more details including the permission regarding the contents of a directory (folder) 


[root@localhost -]# ls -1 

Verification

total 76 
-rw-r--r--    1    root root 1049  Apr   2  2007 anaconda.cfg
drwxr-xr-x 2    root root 4096   Mar 14 20:13 Desktop
 -rw-r--r--   1    root root 46871 Apr  2  2007 install.log
rw-r--r--     1    root root 5175   Apr   2  2007 inst.syslog

[root@localhost -]# l l 

Verification 

total 76
-rw-r--r--    1 root root  1049   Apr   2 2007   anaconda.cfc
drwxr-xr-x 2 root root  4096   Mar  14 20:13 Desktop
 -rw-r--r--   1 root root  46871 Apr  2  2007   install.log
 -rw-r--r--   1 root root  5175   Apr  2  2007    inst.syslog

4. To see all contents directory (folder) 

[root@localhost 

Verification  

.gnome2private     .esd_auth         .tcshrc 
.evolution              .thumbnails     .fonts.cache-1- 
.Trash                  .gconf .viminfo     .gconfd 
.Xauthority     .gnomeinstall.loc     .elinks 
.syslog                 .gstreamer-0.8   anaconda-ks.cfg
 .gtkrc                .bash_history           .gtkrc-1
.2-gnome2          .baskjogout .ICEauthority 
.bash_profile       .rnd     .gnome2 
.ssh 
s hidden files 
.camel_certs 
.metacity 
.config 
.mozilla 
.cshrc 
.nautilus 
Desktop 
.recently-used 
.dmrc 
.rhn-applet.conf 
.eggcups 
.bashrc install.log 
of 
 

5. To see tree structure of nested directories 

[root@localhost -j# is -R /opt 

Verification

 /opt: 
way2backdoor
 
/opt/way2backdoor:
way2ackdoora 

/opt/way/way2ackdoorba:
way2backdoorb 

/opt/way2backdoor/way2backdoora/way2backdoorb: 
way2backdoorS 

/opt/way2backdoor/way2backdoora/way2backdoorb/way2backdoors: 
20 

6. To see a file starting from f 

[root@localhost-]#ls f*

Verification  

food fish fool fun final 

7. To see a file whose lenth is 6 characters

 [root@localhost-]# 1s ?????

Verification  

Centos fedora Ubuntu packet 

8. To create a file 

Iroot@localhost -J# cat > filel 
hi how are you, how is your zoom 
ctr1+d (to save) 

9. To see file content 

(root@local -1)# cat filel 
hi how are you how is your zoom 


10. To append a file 

,root@localnosL cat >> filel 
- very nice 

[root@localhost -] # cat filel file2 >> file3 
[root@localhost -]#  cat file3 

11. To create a file using touch command 

[root@localhost -]# touch fl f2 f3 f4 
[root@localhost -]# ls

Verification 

anaconda-ks.cfg Desktop install.log install.log.syslog fl f2 f3 f4 

12. Creating a single directory 

[root@localhost -]# mkdir dir 

13. Creating multiple directories 

[root@localhost -]# mkdir dirl dir2 dir3 dir4
[root@localhost -]# ls

Verification 

anaconda-ks.cfq dir' dir2 dir4 f2 f4 file install.log labmanual 
Desktop dirl install.log.syslog 
dir3 
fl 
f3 filel file: 

14. To create nested directories

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

 15. To see the tree structure 

[root@localhost -]# ls

Verification 

dl: d2 dl/d2: d3 dl/d2/d3: d4 dl/d2/d3/d4: 
[root@localhost -]#  

16. To change a directory 

[root@localhost -]# cd dirt
 [root@localhost dirl]# cd 
[root@localhost -]# cd ../.. 
[root@localhost /]# cd -/root 
[root@localhost -]# pwd /root 
[root@localhost -]# cd 
[root@localhost -]# pwd /root 
[root@localhost -]# 

17. To remove files 

[root@localhost -]# rm file1 
rm: remove regular file 'filel'? y 

18. To remove an empty directory

 [root@localhost -]# rmdir dirl 
[root@localhost -]# ls
 anaconda-ks.cfg Desktop dir2 dir4 f2 f4 file3 install.log.syslog dl dir dir3 fl f3 file2 install.log 

19. To remove a directory 


[root@localhost -]#rm -rf dir
[root@localhost -]#ls
ana4. ins Li 
labmanual 
di dir2 dir4 insLall.log.syslog

 20. To copy files 

[root@localhost -]# cp anaconda-ks.cfg filel 
[root@localhost -]# cat filel 

21. To copy folders 

[root@localhost -]# cp -r dir2 Desktop
[root@localhost -]# ls Desktop 

22. To rename directories and files 

[root@localhost -]# my dir3 d4 
[root@localhost -]# ls 

Verification 

anaconda-ks.cfg d4 install.log.syslog dl Desktop install.log labmanual 
dir2 fi f3 filel dir4 f2 f4 file2 

23. To move directories and files 

[root@localhost -]# my dir2 /opt 
[root@localhost -]# ls 

Verification 

file3 
anaconda-k3,.cfq d4 dir4 f2 f4 f ile2 insLali.log labmiinual f-T filel file3 di Deskt,J,p fl install.log.syslog 

[root@localhost -]# cd /opt 
[root@localhost opt]# ls
dir2 zoom 

24. To search a word from single or multiple file's 

[root@localhost -]# grep tom /etc/passwd  /etc/group  /etc/gshadow 
/etc/passwd:tom:x:500:500::/home/tom:/bin/bash 
/etc/group:tom:x:500:
 /etc/gshadow:tom:!:: 

[root@localhost -]# cat /etc/passwd grep tom 

25. To see the type of file 

[root@localhost -]# file * 

26. To view the date 

[root@localhost -]# date 
[root@localhost -]# date -s"sat july 15 10:20:10 ist 2013" 

Day/mm/dd/hh:mm:ss/year Tue Jul 15 00:06:00 EDT 2013 

27. To view the calendar for complete year 

[root@localhost -]# cal 12 200 

28. To take help of command 

[root@localhost -1# man mkdir 

29. To see the content screen wise 

[root@localhost -1#ls -l /bin | less




No comments:

Post a Comment