Linux Basic Commands

Semakness | Sunday, May 22, 2011 | 1 comments




For changing directory / to /etc
  • [root@semakness /]# cd /etc
One step back /etc to /
  • [root@semakness etc]# cd ..
Go to previous working directory
  • [root@semakness /]# cd -
Go to current login user home directory
  • [root@semakness etc]# cd ~
Show the contents of /etc in single color
  • [root@semakness ~]#  dir  /etc
Show the contents of /etc in different colors with nature of contents
  • [root@semakness ~]#  Ls  /etc
Create a folder on root partition
  • [root@semakness  ~]#  mkdir  /disk
Create a folder in /disk
  • [root@semakness  ~]#  mkdir  /disk/dir
Create multiple folder in multiple directories with single command
  • [root@semakness  ~]#  mkdir  /etc/dir1 /var/dir2 /usr/dir3
Create multiple folder in same directory
  • [root@semakness  ~]#  mkdir  dir1 dir2 dir3
Copy a file in directory
  • [root@semakness  disk]#  cp  file dir
Copy a file from /disk/file and paste it in /disk/dir/
  • [root@semakness  disk]#  cp  /disk/file /disk/dir
Copy a directory with –r option
  • [root@semakness  disk]#  cp  -r  dir  dir2
Copy a file from /disk/file and paste it in /etc with myfile name
  • [root@semakness  disk]#  cp  /disk/file  /etc/myfile
Remove a file
  • [root@semakness  disk]#  rm file
Remove a file with forcefully option
  • [root@semakness  disk]#  rm –f  file
Remove a directory with out –r option and you face will an error
  • [root@semakness  disk]#  rm dir
Remove a directory with –r option
  • [root@semakness  disk]#  rm  -r  /disk
Remove a directory with forcefully option
  • [root@semakness  disk]#  rm  -rf  dir
Move /etc/dir1 to /disk/ with different name
  • [root@semakness  disk]#  mv  /etc/dir1  /disk/mydir
Rename the folder name mydir to dir
  • [root@semakness  disk]#  mv  /disk/mydir  /disk/dir
Rename the file name with myfile
  • [root@semakness  disk]#  mv file myfile
Read a file page by page with less command
  • [root@semakness  disk]# less  /etc/grub.conf
Read a file page by page with more command
  • [root@semakness  disk]# more  /etc/qrub.conf
Read first ten lines of grub.conf
  • [root@semakness  disk]# head  /etc/grub.conf
Read last ten lings of grub.conf
  • [root@semakness  disk]# tail  /etc/grub.conf
Read first 12 lines with –n option
  • [root@semakness  disk]# head  -n  12  /etc/grub.conf
Read last 11 lines with –n option
  • [root@semakness  disk]# tail  -n 11  /etc/grub.conf
Copy the contents of /etc/grub.conf in /disk/file
  • [root@semakness  disk]# cat  /etc/grub.conf > /disk/file
Append the contents /etc/mtab in /etc/file
  • [root@semakness  disk]# cat  /etc/mtab >>  /disk/file
Merging tow commands with pipe sign output of the first command is input of second command
  • [root@semakness  disk]# cat  /etc/squid/squid.conf I more
Count the total lines of squid.conf
  • [root@semakness  disk]# cat  /etc/squid/squid.conf I wc  -L
Show only spool words in squid.conf
  • [root@semakness  disk]# cat  /etc/squid/squid.conf  I grep  spool
Flush the contents of file
  • [root@semakness  disk]# cat  /dev/null  >  /var/log/messages

Category: ,

About Semakness: My name is Semakness Fio . Known as Jack .I'm administrator of Semakness Technologies blog .This blog was opened for Tips and Tricks .

1 comments

  1. good basic of linux**

    thank for sharing**


    blogwalking with us

SPONSORED BY