To learn Unix isn’t too simple idea, so let’s consider the most important unix commands:
- cd - Change directory, example:
cd /etc/
- ls - List directory, example:
ls /etc, use ls -l /etc to see more detail
- 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
- mv - Move a file, example:
mv source dest
- 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
- cat - Concatenate, or output a file
cat /var/log/messages
- 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.
- 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!.
- man - Show manual for a command, example:
man ls hit q to exit the man page.
- 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.
- 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: Unix,
mysql import,
mysqldump,
unix,
unix commands