1. How to log in to SSH?
2. Common commands for SSH operations: ls /* View the contents of a directory, or dir command cd mydir /* Enter the mydir directory*/ cd – /* Return to the previous directory*/ Use cd .. in the same way cd ~ /* Return to the root directory*/ rm -rf mydir /* delete mydir directory */ rm go.tar /* delete go.tar file */ mv tools tool /* Rename the tools directory to tool */ cp -a tool www /* Copy all files in the tool directory to the www directory pwd /* Display the current server path. Common operations with paths include: cd /home/ftp1 /* Enter the FTP1 directory cp -a /home/ftp1/22 /home/ftp2/ /*Copy the 22 directory under ftp1 to ftp2 3. SSH download, compression, decompression and other commands: Remote download operation on SSH: wget download command wget http://love8.org/1.rar /*SSH downloads the 1.rar package in the root directory of my site. Note: The server used to download very fast. As long as the bandwidth is sufficient, sometimes the test reaches 10M/s. You can often download source code and use it directly, such as downloading DZ, etc. nohup is the parameter. After closing the window, the transmission will continue until it is completed. After exiting SSH, continue to run. Some say to add it in front, such as nohup wget http://love8.org/1.rar Can be used for upload and download packaging, compression, and decompression operations in FTP: File Operations: ls View files in a directory ls -F View files in a directory ls -l displays detailed information about files and directories ls -a shows hidden files ls *[0-9]* Display file names and directory names containing numbers rm go.tar delete go.tar file find mt.cgi Find files named mt.cgi df ?h Check the remaining disk space find / -name xxx -print find xxx file compression and decompression: tar xvf wordpress.tar Unzip the tar format file tar -tvf myfile.tar View the files contained in the tar file tar cf toole.tar tool packages the tool directory into the toole.tar file tar cfz xwyme.tar.gz tool Package the tool directory and compress it into the xwyme.tar.gz file. Because .tar files are almost never compressed, the MT .tar.gz file is about 10MB after being decompressed into a .tar file. tar jcvf /var/bak/www.tar.bz2 /var/www/ creates a .tar.bz2 file with high compression ratio tar xjf www.tar.bz2 decompress tar.bz2 format gzip -d ge.tar.gz decompresses the .tar.gz file to a .tar file unzip phpbb.zip Unzip the zip file. It is a bit troublesome to compress a .tar.gz file under Windows. bunzip2 file1.bz2 decompresses a file called 'file1.bz2' bzip2 file1 compresses a file called 'file1' gunzip file1.gz decompresses a file called 'file1.gz' gzip file1 compresses a file called 'file1' gzip -9 file1 Maximum compression rar a file1.rar test_file creates a package called 'file1.rar' rar a file1.rar file1 file2 dir1 compress 'file1', 'file2' and directory 'dir1' at the same time rar x file1.rar Unzip rar package unrar x file1.rar decompress rar package tar -cvf archive.tar file1 creates an uncompressed tarball tar -cvf archive.tar file1 file2 dir1 creates an archive file containing 'file1', 'file2' and 'dir1' tar -tf archive.tar Display the contents of a package tar -xvf archive.tar releases a package tar -xvf archive.tar -C /tmp to release the compressed package to the /tmp directory tar -cvfj archive.tar.bz2 dir1 creates a compressed archive in bzip2 format tar -xvfj archive.tar.bz2 decompresses a compressed archive in bzip2 format tar -cvfz archive.tar.gz dir1 creates a compressed archive in gzip format tar -xvfz archive.tar.gz decompresses a gzip archive zip file1.zip file1 creates a compressed package in zip format zip -r file1.zip file1 file2 dir1 Compress several files and directories into a zip file unzip file1.zip decompress a zip file 4. SSH upload, FTP and other commands: Enter FTP: ftp love8.org /*Directly connect to love8.com via FTP Name: love8 /* Input FTP: love8 Password: /*Enter the FTP password. The password will not be displayed. Just enter it to enter FTP and upload: FTP>put love8.zip love8.zip /*put is the upload command, the first love8.zip is the local file name, and the second one is the remote file name. . /*It means to upload the local love8.zip to the remote FTP, mput is to upload the directory, upload the local service directory (and all files and subdirectories) to FTP. But the test was not successful (it seems to require lftp support) Download: FTP>get love8.zip love8.zip Download idc886.zip from FTP to the local server mget is to download a directory including all files and subdirectories from FTP, but it was not tested successfully (it seems to require lftp support) When logging into FTP, add the parameter i so that you will not be prompted for Y/N. For example: ftp -i love8.org or ftp>prompt The following are commonly used in FTP: (Note that the commands in lftp are different from FTP commands) TP>ls, list the directories and files in the current path on the remote Linux FTP server? FTP>dir, list the directories and files in the current path on the remote Linux FTP server (same as above)? FTP>mkdir, create a specified directory in the current path on the remote Linux FTP server? FTP>rmdir, delete the specified directory in the current path on the remote Linux FTP server? FTP>cd, change the working directory on the remote Linux FTP server? FTP>delete, delete the specified file on the remote Linux FTP server? FTP>rename, rename the specified file on the remote Linux FTP server? FTP>close, disconnect from the remote Linux FTP server but keep the FTP command parameter prompt? FTP>disconnect, disconnect from the remote Linux FTP server but keep the FTP command parameter prompt (same as above)? FTP>bye ends the connection with the remote Linux FTP server. FTP>quit, end the connection with the remote Linux FTP server (same as above). FTP>!, directly enter the local shell from the remote Linux FTP server? FTP>exit, (continued from the previous step) return from the local shell environment to the remote Linux FTP server environment? FTP>!ls, list the directories and files in the current path on the local machine? FTP>lcd, change the working directory of the local machine? FTP>?, display ftp command description? FTP>help, display ftp command description (same as above)? 5. Database backup and recovery in SSH: 1. Database backup command: mysqldump Parameters: mysqldump -u database user -p password -h database address database name> database file example: mysqldump -ulove8 -plove8 -h sql.love8com love8 > love8.sql 2. Database recovery command: mysql Parameters: mysql -u database user -p password -h database address database name < database file example: mysql -ulove8 -plove8 -h sql.love8.com love8 < love8.sql Note: If your database supports remote connections, you can back up the database on any server. 6. Common commands for server-related command operations: free /* Check the server's memory usage and remaining memory, etc. uptime /* View server uptime and load cat /proc/cpuinfo /* View CPU information top /*View server memory and CPU running data values uname -a /*View host information, version, etc. ps -A /*View all processes who /* View active users such as: SSH users cat /root/.bash_history /* View command history, such as operating under SSH cat /var/log/secure | grep ssh /* View the security log to see who has logged into the server through SSH dd if=/dev/zero of=test bs=64k count=4k oflag=dsync Hard disk performance test DH's 46.6M/S chmod -R 777 ddb /*Set the ddb directory attribute to 777, -R includes all the following file and directory attributes chmod +x ddb.sh /*Set ddb.sh to be executable to automatically execute Crontab usage: yum install vixie-cron crontabs //Install Crontab crontab -l View the task list crontab -e delete, add, edit tasks 5 */6 * * * /home/admin/ddb.sh Execute ddb.sh every 6 hours and 5 minutes 15 1 15,30 * * /home/admin/ddb.sh Execute ddb.sh at 1:15 on the 15th and 30th of every month 7. Server-related restart commands: Pay attention to the path, some installation services have different installation paths. But the command is the same. /usr/sbin/apachectl restart /*Restart apache /usr/sbin/apachectl stop /*Stop apache /usr/sbin/apachectl start /*Start apache /sbin/service mysqld restart Restart mysqld /etc/init.d/lighttpd restart Restart the lighttpd server /usr/sbin/service httpd restart service kloxo start Restart kloxo reboot Restart the VPS poweroff Shut down the VPS The above is a collection of some commonly used SSH operation commands, which will be added slowly in the future! |