Pages

Monday, February 2, 2015

What the heck does SUDO mean in Linux?

sudo – short for “substitute user do” – is a command which allows users to run commands with other user’s rights (e.g. root).

Friday, November 1, 2013

Find Machine Name using an IP Address in Windows or Linux

Find Machine Name using an IP Address in Windows or Linux



C:\Users\Homer>nslookup 10.50.2.100
Server:  windc.ad.simpson.org
Address:  10.50.2.70
*** windc.ad.simpospn.org can't find 10.50.2.100: Non-existent domain

C:\Users\Homer>nbtstat -a 10.50.2.100
Local Area Connection:
Node IpAddress: [10.12.4.29] Scope Id: []
    Host not found.


MyLinux:/ # nslookup 10.50.2.100;
Server:         10.50.2.70
Address:        10.50.2.70#53
** server can't find 175.2.50.10.in-addr.arpa.: NXDOMAIN


MyLinux:/ # smbclient -L 10.50.2.100
Enter root's password: 
Connection to 10.50.2.100 failed (Error NT_STATUS_CONNECTION_REFUSED)


MyLinux:/ # host 10.50.2.100
Host 175.2.50.10.in-addr.arpa. not found: 3(NXDOMAIN)

Find largest files

Type the following command at the shell prompt to find out top 10 largest file/directories:
# du -a /var | sort -n -r | head -n 10

If you want more human readable output try:
$ cd /path/to/some/where
$ du -hsx * | sort -rh | head -10

Where,
  • du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
  • du command -s option : show only a total for each argument (summary).
  • du command -x option : skip directories on different file systems.
  • sort command -r option : reverse the result of comparisons.
  • sort command -h option : compare human readable numbers. This is GNU sort specific option only.
  • head command -10 OR -n 10 option : show the first 10 lines.
The above command will only work of GNU/sort is installed. Other Unix like operating system should use the following version (see comments below):
 
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
 

This is also a good one ... here this returns the top 40:
find  -type f -printf '%s %p\n'| sort -nr | head -40



also see: http://linuxcountry.blogspot.com/2013/05/find-and-sort-all-files-by-size-save.html

Wednesday, October 30, 2013

Using mysqldump - How to back up a MySQL database on Linux with the mysql dump command


You do not need to invoke the mysql command or log into your MySQL server..
From your linux shell command line type:

MyLinuxServer:/ # mysqldump -u root -p  databaseName > databaseBackupFileName.sql;

You will be prompted to enter the password next "Enter password:"

View all MySQL databases - SQL command to show databases on MySQL Linux

Once you log into MySql,

mysql> SHOW DATABASES;

Log into a MySQL server

Command:

MyLinuxServer:/ # mysql -u root -p


You will be prompted to enter the password "Enter password:"  next



Tuesday, October 22, 2013

Stop, Start, Restart, Status of MySQL server



I've tired many commands, I find these to work the best using the Sys-V init scripts located in /etc/init.d.

Start:
sudo /etc/init.d/mysql start
Stop:
sudo /etc/init.d/mysql stop
Restart / reload configs:
sudo /etc/init.d/mysql restart
Check run status:
sudo /etc/init.d/mysql status