Archive for the 'Unix' Category

The top of most important Unix commands…

To learn Unix isn’t too simple idea, so let’s consider the most important unix commands:

  1. cd - Change directory, example: cd /etc/
  2. ls - List directory, example: ls /etc, use ls -l /etc to see more detail
  3. cp - Copy a file or directory, example: cp source dest if you want to copy a directory use the -R option for recursive: cp -R /source /dest
  4. mv - Move a file, example: mv source dest
  5. rm - Remove a file, example: rm somefile to remove a directory you may need the -R option, you can also use the -f option which tells it not to confirm each file: rm -rf /dir
  6. cat - Concatenate, or output a file cat /var/log/messages
  7. tar - Archiver. Usage example:
    gunzip -d archive.tar.gz - makes from archive.tar.gz => archive.tar
    tar xvf archive.tar - this will extract archive.tar to current directory.
  8. vi - Text editor, example: vi ./file.txt
    To edit a line press Esc i then to save changes and exit use Esc wq, or to quit without saving use Esc q!.
  9. man - Show manual for a command, example: man ls hit q to exit the man page.
  10. top - This command provides a good overview of things including CPU and memory utilization, and a list of the top consumers of CPU. If you want to kill some process press “K” and enter id of process.
  11. wget - Download something frm other server. Example: wget http://www.shopzz.org/robots.txt

How to make backup of MySQL?

mysqldump -u<username> -h<hostname> -p<password> dbname | gzip -9 > dump-db.sql.gz

To import MySQL dump use this:

mysql -u<username> -p<password> dbname < dump-db.sql


Tags: , , , ,