Posts Tagged ‘command line’

Change ssh login folder

Tuesday, January 10th, 2012

After you ssh into server:
$ vi /etc/passwd

You should see something similar to
bloom:x:502:503::/var/www/vhosts:/bin/bash
devuser:x:48:505::/home/devuser:/bin/bash
bloomcom:x:503:506::/var/www/vhosts:/bin/bash

Just change the part where is says: /var/www/vhosts
to whatever folder you want

Get the current size of your hard drives

Saturday, January 7th, 2012
$ df -h ( hit enter )

Will return something similar to:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             128G   80G   47G  64% /
/dev/sda2             2.0G  264M  1.6G  15% /tmp
/dev/sda1              99M   23M   71M  25% /boot
tmpfs                  16G     0   16G   0% /dev/shm

Get the 50 largest files from your server

Saturday, January 7th, 2012
After logging in to your server via ssh:
 $ find / -type f -printf "%s %h/%f\n" | sort -rn -k1 | head -n 50 | awk '{ print $1/1048576 "MB" " " $2}' ( hit enter )

Magento log not working

Monday, December 19th, 2011

To fix your Magneto log: Mage::log() that is not logging you need to change the update the permissions for the magento var folder.

$ cd magento/location/on/server ( hit enter )

$ chmod -R 777 var/ ( hit enter )

That will prevent Magento from trying to use a default setting: /var/tmp//magento/var

Took me 2 hours, but hopefully this saves someone else from the same pain I had.

 

Count items in a folder

Thursday, December 15th, 2011

$ find folder/to/count/ -type f | wc -l ( hit enter )

Get a folder size via command line

Wednesday, December 14th, 2011

$ du -h /foldertogetsizeof ( hit enter )

To get the size of the folder you are in:
$ du -h ( hit enter )

ls command line

Monday, December 12th, 2011

To display the long listing in a human readable format that nicely summarizes the file sizes, use:

$ ls -lah slow-log
****************************
Example output
****************************
-rwxrwxrwx 1 bloom bloom 34K Dec 12 10:24 slow-log

Restart Redhat via command line

Tuesday, November 29th, 2011

$ /sbin/shutdown -r 0

MySQL process continual monitor

Friday, November 25th, 2011

From Terminal:
$ mysqladmin processlist ( hit enter )

MySQL Slow Query Logging

Thursday, November 24th, 2011

Edit my.cnf
$ sudo nano /etc/my.cnf

Search for slow and you should see:
# Slow Query Log Settings
# ———————–
#log-slow-queries=/var/log/mysqllogs/slow-log
#long_query_time=5
#log-queries-not-using-indexes

Remove the # and adjust the time if needed
save the changes and retart mysql
$ /etc/init.d/mysqld restart

The files are saved to:
/var/log/mysqllogs