Friday, May 10, 2013

Difference between SAN and NAS                                Netstat Command in Linux

1.       What are the run levels?
There are total seven run levels as follows:
0 – halt
1—single user mode
2—multiuser mode without NFS
3—Multiuser with NFS
4 -- Unused
5 -- Multiuser mode with X11.
6 – Reboot.

2.       How to check all logged in user currently on server?
Ans.  W and who are the commands to check all logged in users on server. There many different commands to check this but mostly used w or who or finger.
root@rhel:~/rhel/shellscript# w
 01:17:45 up 12 days,  6:43,  3 users,  load average: 0.03, 0.04, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
nielsen2 pts/0    10.136.26.166    Wed20    3days  1.05s  0.69s -bash
nielsenpts/1    10.136.26.227    01:05    0.00s  0.62s  0.07s sshd: nielsen [priv]
nielsen2 pts/2    10.136.26.92     Wed20    4days  0.43s  3.39s sshd: nielsen2 [priv]
root@rhel:~/rhel/shellscript#
root@rhel:~/rhel/shellscript# who
nielsen2 pts/0        2013-04-24 20:24 (10.136.26.166)
nielsenpts/1        2013-04-30 01:05 (10.136.26.227)
nielsen2 pts/2        2013-04-24 20:26 (10.136.26.92)
root@rhel:~/rhel/shellscript# finger
Login     Name       Tty      Idle  Login Time   Office     Office Phone
nielsen   Nielsen   *pts/1          Apr 30 01:05 (10.136.26.227)
nielsen2             pts/0      3d  Apr 24 20:24 (10.136.26.166)
nielsen2            *pts/2      4d  Apr 24 20:26 (10.136.26.92)
root@rhel:~/rhel/shellscript#

3.       What is the difference between soft link and hard link?
Ans. Soft link also called as Symbolic link. Soft link means link the new file to original file without copying whole file to new location. And New files size will be the characters in filename of original file. If you want to get detailed difference then click on next link: Difference between Soft Link and Hard Link.

4.       How to change hostname permanently for server?
Ans. Generally, we are changing hostname from `hostname command` but this is not the way to change the hostname permanently. You should have to open the file `/etc/sysconfig/network` and change the hostname parameter of this file and then restart the network service.

5.       What is the command to convert dos file into unix format ?
Ans. `dos2unix` command is generally used for convert dos file into unix format and `unix2dos` command is used to vice versa.
6.       On which port DNS server is running ?
Ans. 53 Port .
7.       How to get the lines which matches pattern and 4 lines after the matched pattern ?
Ans. We can use grep command to get 4 lines after matched pattern.
root@rhel:~/rhel/shellscript# cat /etc/passwd | grep -nA 4 root
1:root:x:0:0:root:/root:/bin/bash
2-daemon:x:1:1:daemon:/usr/sbin:/bin/sh
3-bin:x:2:2:bin:/bin:/bin/sh
4-sys:x:3:3:sys:/dev:/bin/sh
5-sync:x:4:65534:sync:/bin:/bin/sync
root@rhel:~/rhel/shellscript#

To get 4 lines before the matched pattern:
root@rhel:~/rhel/shellscript# cat /etc/passwd | grep -nB 4 snmp
45-jenkins:x:120:65534::/var/lib/jenkins:/bin/bash
46-bind:x:121:131::/var/cache/bind:/bin/false
47-nagios:x:122:132::/var/lib/nagios:/bin/false
48-guest-ZI4XVo:x:123:133:Guest,,,:/tmp/guest-ZI4XVo:/bin/bash
49:snmp:x:124:134::/var/lib/snmp:/bin/false
root@rhel:~/rhel/shellscript#

8.       How to create 10 files in single command?
Ans.  You can use 10 different names after touch command.
root@rhel:~/rhel/shellscript/test# touch test{1..10}
root@rhel:~/rhel/shellscript/test# ls
test1  test10  test2  test3  test4  test5  test6  test7  test8  test9
root@rhel:~/rhel/shellscript/test#

9.       Find commans syntax to find the file by inodenumber ?
Ans. as follows:
root@rhel:~/rhel/shellscript# ls -li
total 32
5644165 -rw-r--r-- 1 root root 4922 2013-04-17 20:02 bid.log
5644164 -rwxr-xr-x 1 root root  479 2013-04-24 22:27 shellscript.sh
5770666 drwxr-xr-x 2 root root 4096 2013-04-30 01:42 test
5644159 -rw-r--r-- 1 root root 2173 2013-04-17 17:50 test1.log
5644160 -rwxr-xr-x 1 root root  353 2013-04-16 20:04 test1.sh
5644161 -rwxr-xr-x 1 root root  514 2013-04-16 18:30 test2.sh
5644117 -rw-r--r-- 1 root root 1731 2013-04-17 17:55 test.log
root@rhel:~/rhel/shellscript# find . -inum 5644164
./shellscript.sh
root@rhel:~/rhel/shellscript#

10.   Find command syntax to get files accessed within last 30 days:
Ans:
root@rhel:~/rhel/shellscript#
root@rhel:~/rhel/shellscript# find . -type f -atime -30
./test2.sh
./bid.log
./test/test1
./test/test9
./test/test5
./test/test6
./test/test10
./test/test4
./test/test2
root@rhel:~/rhel/shellscript#

Check CPU usage in Linux                                              Usermod command in Linux
Posted by Machindra Dharmadhikari On 5/10/2013 09:27:00 AM 4 comments

4 comments:

Post a Comment

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

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner