Monday, May 26, 2014

Linux Commands - 4

3:13 PM

This article explains some of the most used Linux commands and their basic usage which will be more helpful for beginners. All these commands should be entered at the command prompt and you must press the ENTER button to execute the desired command. Please note that all Linux commands are case sensitive.

31. rpm command

To install mysql using rpm

root@linuxstorage:~#  rpm -ivh mysql-server-5.5.i386.rpm

To upgrade mysql using rpm.

root@linuxstorage:~#  rpm  -uvh mysql-server-5.5.i386.rpm

To uninstall/remove mysql using rpm.

root@linuxstorage:~#  rpm -ev mysql

32. yum command 

 To install mysql

root@linuxstorage:~#yum install mysql -y

To upgrade mysql

root@linuxstorage:~#yum update mysql

To uninstall/remove mysql

root@linuxstorage:~#yum remove mysql

33. apt-get command

 
 To install mysql

root@linuxstorage:~#apt-get install mysql-server

To upgrade mysql

root@linuxstorage:~#apt-get update mysql-server

To uninstall/remove mysql 

root@linuxstorage:~#apt-get remove mysql-server

34. su - switch user. we switch to different users account in system using su command in terminal.Super user can switch to any other user without entering their password.

 root@linuxstorage:~#su - username

only su will change to root user.

 username@linuxstorage:~#su

35.  less-  less is very efficient while viewing huge files, as it doesn’t need to load the full file while opening.

 root@linuxstorage:~# less data.log

36. tail - tail use to view last 10 line in file.it's use full for viewing log files.

 root@linuxstorage:~#tail data.log

Print N number of lines from the file

root@linuxstorage:~#tail -n 20 data.log

now we can see last 20 line in that file.

37. whatis - Whatis command displays a single line description about a command.

root@linuxstorage:~#whatis cp
cp                   (1)  - copy files and directories
cp                   (1p)  - copy files

38. ps  - ps command is used to display information about the processes that are running in the system.

To view current running processes

root@linuxstorage:~#ps -ef | more
 UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 09:11 ?        00:00:00 /sbin/init
root         2     0  0 09:11 ?        00:00:00 [kthreadd]
root         3     2  0 09:11 ?        00:00:00 [migration/0]
root         4     2  0 09:11 ?        00:00:00 [ksoftirqd/0]
root         5     2  0 09:11 ?        00:00:00 [migration/0]
root         6     2  0 09:11 ?        00:00:00 [watchdog/0]
root         7     2  0 09:11 ?        00:00:00 [migration/1]
root         8     2  0 09:11 ?        00:00:00 [migration/1]
root         9     2  0 09:11 ?        00:00:00 [ksoftirqd/1]
root        10     2  0 09:11 ?        00:00:00 [watchdog/1]
root        11     2  0 09:11 ?        00:00:00 [events/0]
root        12     2  0 09:11 ?        00:00:00 [events/1]
root        13     2  0 09:11 ?        00:00:00 [cgroup]
root        14     2  0 09:11 ?        00:00:00 [khelper]
 more




to view particular service process id

root@linuxstorage:~#ps -ef |grep httpd
root      1871     1  0 09:11 ?        00:00:00 /usr/sbin/httpd
apache    2356  1871  1 10:26 ?        00:03:25 /usr/sbin/httpd
apache    2357  1871  0 10:26 ?        00:01:43 /usr/sbin/httpd
apache    2358  1871  0 10:26 ?        00:01:52 /usr/sbin/httpd
apache    2359  1871  0 10:26 ?        00:02:09 /usr/sbin/httpd
apache    2360  1871  0 10:26 ?        00:02:32 /usr/sbin/httpd
apache    2361  1871  0 10:26 ?        00:02:17 /usr/sbin/httpd
apache    2362  1871  0 10:26 ?        00:02:35 /usr/sbin/httpd
apache    2363  1871  0 10:26 ?        00:00:35 /usr/sbin/httpd
apache    3057  1871  0 12:47 ?        00:00:13 /usr/sbin/httpd

39. pgrep - pgrep is an acronym that stands for "Process-ID Global Regular Expressions Print".

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. pgrep is handy when all you want to know is the process id integer of a process.


root@linuxstorage:~#pgrep httpd
1871
2356
2357
2358
2359
2360
2361
2362
2363

40. kill - Use kill command to terminate a process.First get the process id using ps -ef command, then use kill -9 to kill the running Linux process as shown below. You can also use killall, pkill, xkill to terminate a unix process.

First find the process id using below command

root@linuxstorage:~#pgrep httpd
1871

now kill that process id

 root@linuxstorage:~#kill -9 1871

Written by

0 comments :

Post a Comment

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism