Monday 26 August 2013

LINUX COMMANDS FOR DBA's

1) Less :
Helps in viewing the content of files page by page.
ex)
# less country12_100812.sql

2) More :
It is also equivalent to less. It shows the percent of the file viewed so far.
ex)
# more country12_100812.sql

3) cat :
It shows the contents of the file as a whole. But not page by page. Useful for small files.
ex)
# cat anaconda-ks.cfg

4) ls :
List the files present in the current directory or the path.
ex)
# ls
alldatabase_030812.sql alldb100812.sql alldb.sql Country090812.sql
country12_100812.sql lost+found mysql_030812 Prabhu.sql world.sql

5) pwd :
It shows the path of your working directory .
ex) # pwd
/home/karthik/Desktop

6) df
Displays the partitions present and the server . It also provide its disk usage and Size Used Avail Use% Mounted on
3.9G 2.0G 1.9G 52% /
495M 420K 494M 1% /dev/shm
194M 55M 130M 30% /boot
6.2G 1.5G 4.5G 25% /data
2.0G 202M 1.7G 11% /logs
485M 11M 449M 3% /tmp
3.9G 3.3G 411M 90% /usr
2.0G 976M 893M 53% /var

7) du
Retrieve the disk usage of a folder or a file.
ex)
# du -sh
963M

8) ifconfig :
Displays the IP address assigned to the server and also its other network requistics.
ex) # ifconfig
eth1
Link encap:Ethernet HWaddr 00:1D:7D:80:C1:37
inet addr:10.10.25.98 Bcast:10.10.25.255 Mask:255.255.255.0
inet6 addr: fe80::21d:7dff:fe80:c137/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:906 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:47394 (46.2 KiB)
Interrupt:21 Base address:0xa000

9) Traceroute & tracepath :
They help in finding the network delay in reaching a server from remote host.
ex)
#tracepath google.com
#tracepath 10.10.25.98

10) Ping :
Examines whether the server is reachable or not . Helps in trouble shooting the packet
losses.
ex) ping 127.0.0.1

11) netstat :
Displays the active internet connections of the servers and the port opened for the
process.

12) crontab :
Scheduler for scheduling the automated jobs like backup and other maintenance scripts.

13) Free :
Displays the total ram present in the system and their utility.
# free -m

14) Top :
It is similar to the Task manager in Windows . It displays all the process running
and their resource usage.

15) uptime :
Displays the total time after the server is booted, It also shows the load average.
ex)
# uptime
00:56:09 up 57 min, 2 users, load average: 0.00, 0.05, 0.03

16) ps :
It makes list of the current processes running on the system.

17) chmod :
Changes the permission of the files . Read , write and execute.

18) chown :
Changes the ownership of the file to some other user. We must have root permission to
change the ownership of files.

19) mkdir and rmdir:
Mkdir : Creates a directory (folder )
Rmdir : removes the directory (folder )

20) cd :
Change the active directory to required directory.

21) head :
Displays only the first 10 lines of the file as a default.

22) tail :
Displays the last 10 lines of the files as a default.

23) mv :
Move the contents from one directory to other. It is also helpful in renaming the files.

24) wc :
Displays the number of lines, word and character present in a file.

25)grep :
Search a word or a phrase in a file
ex)
#grep -i “mysql” grep_test.txt

26) find :
Search for a file with a pattern . It returns the file name.

27) locate:
Search for a file with a pattern. It returns file with a full path.

28) echo :
Prints the content given inside the quotes.
ex)
# echo "mysql is a database"
mysql is a database

29) gzip :
Compress the files with .gz as extension . Can be extracted using gunzip command.
Ex )
compress
# gzip alldb100812.sql
extract
# gunzip alldb100812.sql.gz

30 ) tar
Tape Archive file. It is a compression format used mostly in binary installation files.
It has extension of .tar

31) kill :
To terminate a running process by the pid (process id)
Ex) Kill 528412

32) who :
List the user logged into the server and their duration

33) whoami :
Displays the user name of current session.

34) sort :
Arranges the content of the files in the ascending or descending order.

35) Vi :
The editor command used to make changes in existing file . It is used widely in
scripting too as “Vim”

36) man :
Shows the manual page of a command . It gives the complete info about the
command.

37) useradd :
To add a linux user for any new process like mysql. Requires root access

38) groupadd:
To add a group in the linux. Requires root access.

39) passwd :
To change or assign password foe a user.

40 ) uname ;
It displays the system information like the OS ,kernel and processor.
# uname -a
Linux remotemysqldba.com 2.6.32-279.2.1.el6.x86_64 #1 SMP Fri Jul 20 01:55:29 UTC
2012 x86_64 x86_64 x86_64 GNU/Linux

41) scp :
Copy the files to a remote server.
ex)
scp mysql.sql root@10.101.150.21:

42) ssh:
It is to connect the remote shell .
ex)
ssh root@10.101.150.21

43 ) telnet :
It is also used to connect the remote host. But it used for checking port opening.
ex)
telnet 10.101.150.21 22


MySQL InternalsMySQL HighAvailabilityMySQL Performance TuningMySQL Query OptimizationMySQL performanceMySQL FabricMySQL HAMySQL InstallationMySQL UpgradeInnoDB Performance TuningInnoDB Buffer Pool SizeMySQL Performance TuningMySQL ClusterMySQL Latest NewsNews and EventsMySQL Customers 

No comments:

Post a Comment