SSH Commands
At the request of several customers of plans to VPS , we decided to create this article with the most commonly used commands SSH terminal to the administration of a Linux server running CentOS 4.x/5.x
Commands for Monitoring Server
Command: top
Description: The top command is used to list all running processes on the server, and statistics for CPU usage, memory, I / O, and load average etc ... In the example below, we are indicating to the top command that it should be updated every 1 second:
Example: top d 1
Command: ps
Description: Similar to the top command, it serves to list the running processes on the server. The example below followed aux option is to list all processes and of any user.
Example: ps aux
Command: kill -9
Description: The kill is used to kill a process server by his PID. You can find out the PID of a process running the command pidof-x followed by the name of the process.
Example: kill -9 1234
Command: free
Description: This command is used to display the data server's physical memory. Use it with the-m option so that the data are displayed in megabytes.
Example: free-m
Command: df
Description: This command is used to list the server partitions and their respective spaces / mount points. Use it followed the Pic-h so that the spaces are listed so that you can understand (in kilobytes, megabytes, gigabytes, etc. ...)
Example: df-h
Command: w
Description: This command can be used to list the users connected to the server through SSH service, besides the load average and uptime.
Example: w
Commands for File Handling
Command: cd
Description: This command is used to browse directories. Use it with no option to go to the root directory, followed by the command to be accessed or 2 points followed by a return to that level.
Example 1: cd
Example 2: cd / usr
Example 3: cd ..
Command: cp
Description: This command is used to copy directories and / or files. Use it followed by the option-R to be copied all subdirectories of a directory.
Example 1: cp test.txt teste_final.txt
Example 2: cp-R / home / directory / root
Command: ls
Description: This command is used to list files, directories, etc ... in a directory for example. Use the-l option followed by data that are listed on a single line.
Example: ls-l
Command: rm
Description: This command is used to remove files and directories. Use it followed by the option-R to be removed from all files in a directory.
Example 1: rm test.txt
Example 2: rm-R / home / directory
Command: mv
Description: This command is used to move files and directories to other locations or to rename them.
Example 1: mv test.txt novo_teste.txt
Example 2: mv / home / directory / root
Command: mkdir
Description: This command is used to create directories.
Example: mkdir test
Command: chmod
Description: This command is used to change the permissions of files and folders. Use it followed the desired permission.
Example: chmod 777 test.txt
Command: vi or pico (or nano)
Description: These three commands are used to edit files, they are text editors.
Example: vi test.txt
Example: pico test.txt
Example: nano test.txt
Command: tar
Description: This command is used to compress / decompress files ending in. Tar,. Tar.gz
Example (compress) tar-test.txt zcvf filename.tar.gz directory1 diretorio2
Example (unpack): tar-zxvf filename.tar.gz
Command: zip
Description: This command is used to compress files with. Zip
Example: zip zip file test.txt directory1 diretorio2
Command: unzip
Description: This command is used to decompress files ending in. Zip
Example: unzip zip file
Command: du
Description: This command is used to calculate the total space of a directory or file. Use it followed by the-h option to display the space megabyte
Example 1: du-h
Example 2: du-h test.txt
Search Commands
Command: find
Description: This command is used to find files and directories.
Example 1: find-name test.txt
Example 2: find / home / directory-name \ *. txt
Command: locate
Description: This command is used to find files and directories.
Example: locate test.txt
Command: grep
Description: This command is used to search for a phrase within a file.
Example: grep test.txt word
Installing packages (programs)
Command: yum
Description: This command is used to install packages (programs) on the server. Use it followed by the option and install the package name to install. It can also be used to update the packages already installed on the server as the kernel and others.
Example (install): yum install package-name
Example (update): yum update package-name
Example (update all): yum update
Several commands
Command: exit
Description: This command is used to logout / terminal session where you are logged.
Example: exit
Command: reboot
Description: This command is used to restart the server.
Example: reboot
Command: shutdown
Description: This command is used to restart / shut down the server. Use it followed by the option-r now to reboot or shutdown-h now to the server.
Example (reboot) shutdown-r now
Example (off): shutdown-h now
Quick Commands
Command: cat / proc / cpuinfo | grep 'model name'
Description: Use it to find out the model of the processor
Command: echo 'Memory Usage'; free-m | grep Mem | awk '{print "Total:" $ 2 "\ nUsado:" $ 3 "\ nLivre:" $ 4}'
Description: Use it to display the usage statistics of physical memory.
Command: ps aux | grep name
Description: Use it to list only those processes that contain the name you specify ahead of the command.
Command: service-name service restart
Description: Use it to restart a service like mysql for example. You can also use the restart instead of start or stop to start, stop a service respectively.
Command: wget http://www.site.com/arquivo.zip
Description: Use it to download files into the server.
Command: wall post
Description: Use it to send a message to another user logged on the server via SSH. Place the message you want to send to the front of the command.


