1. To check the present working directory
[root@server ~]# pwd
Example:
[root@server ~]# pwd
/root
2. To show the contents of a directory (folder)
[root@server ~]# ls
Example
[root@server ~]# ls
anaconda-ks.cfg Desktop install.log install.log.syslog
3. To see more details including the permission regarding the contents
of a directory (folder)
[root@server ~]# ls -l
Example
[root@server ~]# ls -l
total 76
-rw-r--r-- 1 root root 1049 Apr 2 2007 anaconda-ks.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 install.log.syslog
[root@server ~]# ll
total 76
-rw-r--r-- 1 root root 1049 Apr 2 2007 anaconda-ks.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 install.log.syslog
4. To see all contents including hidden files of a directory (folder)
[root@server ~]# ls -a
Example
[root@server ~]# ls -a
.camel_certs .esd_auth .gnome2_private
.metacity
.tcshrc
.config .evolution .gstreamer-0.8
.mozilla
.thumbnails
anaconda-ks.cfg .cshrc .fonts.cache-1 .gtkrc
.nautilus
.Trash
.bash_history Desktop .gconf .gtkrc-1.2-gnome2
.recently-
[root@server ~]# ls -R /opt
/opt:
zoom
/opt/zoom:
zooma
/opt/zoom/zooma:
zoomb
/opt/zoom/zooma/zoomb:
zooms
/opt/zoom/zooma/zoomb/zooms:
To see a file starting from f
[root@server ~]# ls f*
To see a file have a middle string as disk
[root@server ~]# ls /bin/*disk*
To see a file whose length is 3 charaters
[root@server ~]# ls ???
To see a file which starts with single char & ends up with any number of character
[root@server ~]# ls ?edh*
5. To create a file
[root@server ~]# cat > file1
hi how are you, how is your zoom
6. To see file content
[root@server ~]# cat file1
hi how are you how is your zoom
7. To append a file
[root@server ~]# cat >> file1 iam fine, it is very nice
[root@server ~]# cat file1 file2 >> file3 [root@server ~]# cat file3
8. To create a file using touch command
[root@server ~]# touch f1 f2 f3 f4 [root@server ~]# ls
9. Creating a single directory
[root@server ~]# mkdir dir
10. Creating multiple directories
[root@server ~]# mkdir dir1 dir2 dir3 dir4 [root@server ~]# ls
anaconda-ks.cfg dir dir2 dir4 f2 f4 file2 install.log
labmanual
Desktop dir1 dir3 f1 f3 file1 file3 install.log.syslog
11. To create nested directories
[root@server ~]# mkdir -p d1/d2/d3/d4
To see the tree structure
[root@server ~]# ls -R d1
d1:
d2
d1/d2:
d3
d1/d2/d3:
d4
d1/d2/d3/d4:
[root@server ~]#
12. To change a directory
[root@server ~]# cd dir1
[root@server dir1]# cd ..
[root@server ~]# cd ../..
[root@server /]# cd -
/root
[root@server ~]# pwd
/root
[root@server ~]# cd
[root@server ~]# pwd
/root
[root@server ~]#
13. To remove files
[root@server ~]# rm file1
rm: remove regular file `file1'? y
14. To remove an empty directory
[root@server ~]# rmdir dir1
[root@server ~]# ls
anaconda-ks.cfg Desktop dir2 dir4 f2 f4 file3
install.log.syslog
d1 dir dir3 f1 f3 file2 install.log labmanual
15. To remove a directory
[root@server ~]# rm -rf dir
[root@server ~]# ls
anaconda-ks.cfg Desktop dir3 f1 f3 file2 install.log labmanual
d1 dir2 dir4 f2 f4 file3 install.log.syslog
16. To copy files
[root@server ~]# cp anaconda-ks.cfg file1
17. To copy folders
[root@server ~]# cp -r dir2 Desktop
18. To move directories and files
[root@server ~]# mv dir3 d4
[root@server ~]# ls
anaconda-ks.cfg d4 dir2 f1 f3 file1 file3
install.log.syslog
d1 Desktop dir4 f2 f4 file2 install.log labmanual
[root@server ~]# mv dir2 /opt
[root@server ~]# ls
anaconda-ks.cfg d4 dir4 f2 f4 file2 install.log
labmanual
d1 Desktop f1 f3 file1 file3 install.log.syslog
[root@server ~]# cd /opt
[root@server opt]# ls dir2 zoom
19. To search a word from single or multiple file¶s
[root@server ~]# 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@server ~]# cat /etc/passwd | grep tom
20. To see the type of file
[root@server ~]# file *
21. To view the date
[root@server ~]# date
[root@server ~]# date -s "07/15/2008 00:06:00 "
mm/dd/yyyy hh:mm:ss
Tue Jul 15 00:06:00 EDT 2008
[root@server ~]# cal
[root@server ~]# cal 12 2008
[root@server ~]# man mkdir
[root@server ~]# man cal
22. To see the content screen wise
No comments:
Post a Comment