Monday, July 29, 2013

Check CPU usage in Linux                                           Interview Questions for Linux Administrator

There are many commands which needed to know beginner of Unix OS. But it is not possible to understand all commands in one day. If you really new to Linux then please go through this article and understand the most used commands in Linux.

If you are new to Linux then, you will need to know, how to create directory, how to create file, how to read file, open file and edit it, copy file, move file, delete file and directories etc. let’s see how  we are going to do this operations by commands with examples:

mkdir Command


1.  Once you logged on to machine and opened terminal then first of all you need to create directory for your work. Create directory by following command:
login as: root
root@192.168.136.132's password:
[root@localhost ~]#
[root@localhost ~]# mkdir test
[root@localhost ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  test
[root@localhost ~]#

cd command

2. Once you create directory then you have to go inside the directory for this purpose, you can do it as follows:
  [root@localhost ~]#
[root@localhost ~]# cd test
[root@localhost test]#

touch command

3. Once you go inside the directory then we need to create a file. It is as :

[root@localhost test]#
[root@localhost test]# touch test.txt
[root@localhost test]# ls
test.txt
[root@localhost test]#

Vi editor

4. There are different ways of creation of files and generally touch, vi, cat or redirection output used to create a files. We will use vi to create one more file. But we can edit above created file by this way as well. Vi editor creates file if it is not present and if it is present then vi editor edits that file. If you want to know more about VI editor then please click here : VI editor in Linux

[root@localhost test]#
[root@localhost test]# vi test1.txt
[root@localhost test]#

cat command

5.  Once you edit that file and want to read it then use following command.
[root@localhost test]#
[root@localhost test]# cat test1.txt
Hello Linux Concepts and Commands Author
How are you?


[root@localhost test]#

more command

6. Sometimes, file will be very big and you can’t see it on one single screen output then you can read that file as follows:
More command reads file page by page. You just need to press Enter key for next page and backward page press b.
[root@localhost test]#
[root@localhost test]# vi test2.txt
[root@localhost test]#
[root@localhost test]# cat test2.txt | more
[root@localhost test]#
##We can use more command like cat also
[root@localhost test]# more test2.txt

cp command 

7. Now copy the one file to other i.e. create one more copy of test2.txt file and give name to new file as : test2.txt_bak
[root@localhost test]#
[root@localhost test]# cp test2.txt test2.txt_bak
[root@localhost test]#
[root@localhost test]# ls
test1.txt  test2.txt  test2.txt_bak  test.txt
[root@localhost test]#

mv command

8. Now rename to existing file (test1.txt) to test3.txt.

[root@localhost test]# ls
test1.txt  test2.txt  test2.txt_bak  test.txt
[root@localhost test]#
[root@localhost test]# mv test1.txt test3.txt
[root@localhost test]# ls
test2.txt  test2.txt_bak  test3.txt  test.txt
[root@localhost test]#







 rm command, rmdir command

 9.  Now delete the file by rm command, delete directory by rmdir command and if you have many directories inside the one directory then remove that main directory as follows:


[root@localhost test]# ls
test2.txt  test2.txt_bak  test3.txt  test.txt
[root@localhost test]#
[root@localhost test]# rm test2.txt
rm: remove regular file `test2.txt'? y
[root@localhost test]# ls
test2.txt_bak  test3.txt  test.txt
[root@localhost test]# mkdir test1
[root@localhost test]# cd test1
[root@localhost test1]# touch file1
[root@localhost test1]# touch file2 file3
[root@localhost test1]# cd ..
[root@localhost test]# ls
test1  test2.txt_bak  test3.txt  test.txt
[root@localhost test]# rm -r test1/
rm: descend into directory `test1'? y
rm: remove regular empty file `test1/file3'? y
rm: remove regular empty file `test1/file2'? y
rm: remove regular empty file `test1/file1'? y
rm: remove directory `test1'? y
##If you want to delete without prompt then use following command.
[root@localhost test]# rm -rf test1
###Crearting a empty directory
[root@localhost test]# mkdir test1
##rmdir command removes only empty directory
[root@localhost test]# rmdir test1
[root@localhost test]#


How to Run Windows application on Linux                                 Jmap Command in Linux
Posted by Machindra Dharmadhikari On 7/29/2013 02:11:00 PM No comments

0 comments:

Post a Comment

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner