SSH commands you use every day

PERMISSIONS

CHANGE TO ROOT USER FROM ANY OTHER

su root

CHANGE PERMISSION OF A DIRECTORY OR A FILE

chmod 644 mod

CHANGE PERMISSIONS TO THOSE WHO ARE FOLDERS

find foldername -type d -exec chmod 755 {} \;

CHANGE PERMISSIONS TO THOSE WHO ARE FILES

find foldername -type f -exec chmod 644 {} \;

CHANGE OWNER TO ALL INSIDE A FOLDER

chown -R user folder

LOOK FOR CONTENT INSIDE A COMPLETE FOLDER

grep -r “content” /path-or-location

or

grep -rl “Click here to start this course” /

MOVE CONTENT FROM ONE DIRECTORY TO ANOTHER

cp -pr from /directory/* to /directory

SERVICE STATUS

http://www.cyberciti.biz/faq/check-running-services-in-rhel-redhat-fedora-centoslinux/

 

RESTART PLESK

/etc/init.d/psa start

 

Creating A Backup

The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch.

If you want to back up a single database, you merely create the dump and send the output into a file, like so:

mysqldump database_name > database_name.sql

mysqldump -uuser -p database_name > database_name.sql

 

Multiple databases can be backed up at the same time:

mysqldump –databases database_one database_two > two_databases.sql

 

It is also simple to back up all of the databases on a server:

mysqldump –all-databases > all_databases.sql

Restoring a Backup

Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database.

mysql database_name < database_name.sql

If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this:

mysql –one-database database_name < all_databases.sql

 

Add cron to system:

Setup cron for instance created

 

This allow the activities and course completion to work properly.

 

Add a new cron, execute:

crontab -e

then at the end of the line (last cron) add:

For example if the user is myuser then:

*/5 * * * * php /home/myuser/public_html/admin/cli/cron.php >/dev/null

Make sure the username after /home/ is the one for the project needed.

To save the document, press key Esc then :wq

 

TRANSFER A FILE DIRECTLY FROM ANOTHER SERVER

on local server execute:

scp user@hostorip:/home/user/file.zip ./

 

To zip it with:

zip -r filename.zip foldername/ *

 

Check Size of folders within a directory

du –max-depth=1 /path/to/folder | sort -nk1

 

More documentation http://askubuntu.com/questions/1224/how-do-i-determine-the-total-size-of-a-directory-folder-from-the-command-line