Daily commands #9

Some general commands I’ve learned recently.

Set the correct timezone, run the following and follow the instructions

dpkg-reconfigure tzdata

Go to the end of file in Nano editor, useful on large files

[Alt] + /

Check directory size, get human readable size

du -sh [dir] 

Backup a file before making any changes

cp file.ext{,.bak}
cp oldfile.ext newfile.ext

Change directory owner/group

chown -R user:www-data .
chmod -R g+s .

Resource usage

Monit seems nice for server monitoring.

free -m
top

Restart server

sudo shutdown -r now

Restart services like mysql or ssh

service mysql restart

Repair MySQL database tables

mysqlcheck --repair --all-databases

Make WordPress friendly permalinks work on Nginx

location / { 
	try_files $uri $uri/ /index.php?q=$request_uri; 
}
Written on July 11, 2015