Very often, for those approaching Linux servers for the first time, there is a bit of embarrassment. There is no graphical interface, but only a text-based command shell. So here is a list of CentOS commands useful for those who want to approach Linux servers, CentOS distribution.
First, to access the server command shell, you can do it in two ways:
- directly from the server keyboard (even virtual)
- via SSH by means of ExtraPuTTY type clients
How to juggle the command shell
To access the CentOS server, I much prefer to do it via SSH clients, such as ExtraPuTTY. To get access you need to know the address of the server, use port 22, know username (typically root) and your password.
After gaining access, you can start using the first useful CentOS commands.
Copy/Paste. ExtraPuTTY for Windows allows you to paste commands already present in the clipboard, simply by pressing the right mouse button. This is a nice convenience.
Clean the screen: type Ctrl+L.
Manage folders and files in CentOS
To manage the files, I recommend using specific software, such as WinSCP, which allows you to access via SSH to the CentOS server and handle the files like a normal file explorer. Alternatively, you can use the following commands.
Determine the current folder
pwd
Change the current folder
cd sottocartella cd /cartella
List of files in the current folder
ls
List files with size, date, time, and properties
ls -lh
List of subfolders of the current folder
ls -d */
Available space on the disks
df -h
List of subfolders of the current folder, with their size
du -kscxh */
Find a file in the current folder or subfolders
find . -name nome_file_esatto.ext find . -name "*nome_con_wildcards*"
Use quotation marks if you don't know the exact name and want to use the asterisk*.
Find a file all over the hard drive
find / -name nome_file_esatto.ext find / -name "*nome_con_wildcards*"
Download a file from the internet
wget http://www.indirizzo.it/nome_file.ext
Take ownership of a folder and all files and subfolders contained in it
chown -R nome_utente /cartella
CentOS server update
Updates are periodically released for packages that are installed on the server. Then type the following command to update all installed packages:
yum update
When the list of packages to be updated appears, press Y to confirm, n to cancel. To confirm the update without having to press Y, you can use the following command:
yum update -y
The update procedure is generally quite safe. If a package is corrupted, the update may also be canceled for the other packages. In this chaste, you must exclude the package that is having problems from the update, with the following command:
yum --exclude=pacchetto_da_escludere* update
If you know the exact name, you can omit the asterisk *, alternatively, type part of the name and use the asterisk to complete a yum the name of the package to exclude.
Add or remove software
Add a package
yum install nome_del_pacchetto
In order to install a package, you must have the repository installed in /etc/yum.repos.d/
Remove a package
yum remove nome_del_pacchetto
Other useful CentOS commands: exim (mail transfer agent)
This list of CentOS commands is useful for understanding the status of exim (mail transfer agent).
Message queue list
exim -bp
Message queue count
exim -bp | exiqsumm
Number of messages in the queue
exim -bpc
What is exim doing now?
exiwhat
List of all configuration parameters
exim -bP
View a specific configuration parameter (e.g. queue_run_max)
exim -bP queue_run_max
Other useful CentOS commands: php
View the version of php
php -v