Wednesday, July 31, 2013

Interview Questions for Linux Administrator                                             Linux Commands & Tools 

There are many devices or mount points mounted on system. But sometimes, we need to mount these mount points by unique ID. This case generally happens in network because in same network, might have same name mount points on different disks. To avoid this conflict, we will mount the mount points by their block ID which is always unique.

Before doing entry in /etc/fstab file, we need to find block ID of that file. We will do it by following commands as follows:

root@hello:~/myhome/test# blkid /dev/sda1
/dev/sda1: UUID="s91ed12-d675-46bf-a42f-07fgc2313505" TYPE="ext3"
root@hello:~/myhome/test#
root@hello:~/myhome/test# blkid /dev/sda3
/dev/sda3: UUID="k4161839-0b4d-45aa-b4d5-49c76g989628" TYPE="ext3"
root@hello:~/myhome/test#


As per above example, block id will show for only created partitions and we need to provide one parameter for this command and that is partition name.

After this, we can mount file system or partition on operating system with this block ID. It is permanent block id for this partition and it will never change. For each physical partition, there is unique block id for it.
Example of /etc/fstab file configuration by UUID.

# swap was on /dev/sda5 during installation
UUID=72c7301e-239b-44a0-9ccd-41693680d91c none            swap    sw              0       0


If you see in above example, we have used UUID for that device not device or partition name while mounting it in /etc/fstab file.

This method i.e. mounting by block ID is not useful for single home desktop because we will not enterprise grade storage or requirements. 

Chkconfig command in Linux                                                                                   Basic Uses of tar command
Posted by Machindra Dharmadhikari On 7/31/2013 11:48:00 PM No comments READ FULL POST
VI Editor                                                                                                   Useradd Command in Linux

There are many shells which are not coming by default in our operating system. So, that time we need to install it externally by downloading rpm package for Linux, deb package for Solaris, do apt-get for Ubuntu etc. But when we install this shell and somehow it is not working then we need configure it with following steps:

Step 1:

Install shell’s rpm, deb etc. package into operating system.

Step 2:

 Now try to access that shell or try to switch that shell if it is not working then run following steps.

Step 3:

Check configuration file /etc/shells and make entry for that shell like /bin/csh/ or /usr/bin/es or /usr/bin/rc or /bin/rbash etc. If entry is already present then don’t do anything.
But this step has to execute after installation only.

Step 4:

Run following command after making entry  in /etc/shells.

root@hello:~/home/test# add-shell shell-name


add-shell command is used to add shell in kernel. i.e. it updates the kernel information for this shell if it is not present in kernel’s database.

Advanced tricks of Sed command                                          Difference between SAN and NAS
Posted by Machindra Dharmadhikari On 7/31/2013 11:41:00 PM No comments READ FULL POST

Tuesday, July 30, 2013

Crontab in Linux                                                                            Steps to create Logical Volume

Vi editor works as text editor in Linux. We can create, modify, search and replace patterns in a file like these multiple operations, we can do using vi editor. Vi and vim editors are almost same commands but vim is having many advanced features as compared to vi editor. Vim is advanced version of vi editor.

Mostly vi search operation is very useful for us to while editing any file or changing any configuration file. Below are some of the examples of vi/vim editor commands:

Shortcut
Command
Vi filename
Open a file called filename/ we can use absolute path of file here
Esc + i
Insert mode
Esc + :wq
Save and quit
Esc + :q
Quit without save
Esc + :w
Save
Esc + /pattern
It will search pattern in a file and highlight that pattern if found
Esc + dw
Current word delete where cursor points
Esc + dd
Delete current line/ Cuts the current Line
Esc + x
Delete current character
Esc  + P
Paste whatever copied or cut before cursor
Esc + yy
Copy current Line
Esc  + 2yy
Copy current Line and one more immediate line of it
Esc + y$
Copy current line to end of file
Esc + p
Paste after cursor
Esc + q!
Quit and throw away any changes
Esc + ?Pattern
Search backward pattern in Vi editor
Esc + a
Append after cursor
Esc + I
Insert at beginning of Line
Esc + w
Jump word by word/ cursor always remain at beginning of word
Esc + W
Jump word by word
Esc + h
Move left
Esc + j
Move down
Esc + e
Jump to end of words
Esc + b
Jump to backward by words
Esc + B
Jump to backward by words
Esc + 0
Start of Line
Esc + _
Go to the start of Line
Esc  + $
Go to the end of Line
Esc + cc
Change of line
Esc + cw
Change current word
Esc + u
Undo current change
Esc + U
Undo current changes made to the current Line only
Esc + .
Repeat last command in vi editor
Esc + :e filename
Edit a file in a new buffer
Ctrl +ws
Split Windows
Ctrl + wv
Split Windows vertically
Ctrl + ww
Split Windows in Vi editor
Ctrl + wq
Quit windows
Esc + :bn
Go to next buffer
Esc  + :s/Pattern1/Pattern2/g
Replace all pattern1 with pattern2 in vi editor

                

How to recover deleted files in Linux                                                     Shells in Unix/Linux
Posted by Machindra Dharmadhikari On 7/30/2013 10:53:00 AM 2 comments READ FULL POST

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 READ FULL POST
  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner