Archives

List members of a group in Linux

In CentOS Linux, the group information is kept in the /etc/group file.

For example to find the users in the wheel group, use:

root@web [~]# cat /etc/group | grep wheel
wheel:x:11:administrator
root@web [~]#

To see the full content of the /etc/group, use:

root@web [~]# cat /etc/group
Share this post:

Monitor a server with Munin

cPanel offers you the possibility to install the Munin plugin. This plugin allows you to see various stats of your server resources and processes.

Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems. It is designed to be very plug and play. A default installation provides a lot of graphs with almost no work.

To install Munin with WHM:

  1. Log into WHM account
  2. Navigate to cPanel->Manage Plugins
  3. Click the Install “Munin for cPanel” button
    whm install munin
  4. Installation will start. You will see a message: Installation of “Munin for cPanel” is in progress. and at the end “Munin for cPanel” is now installed.
  5. Click on the WHM logo from the top left of the page (this is to refresh the page)
  6. Navigate to Plugins -> Munin Service Monitor
    munin plugin
  7. You will be able to see a lot of stats for your server – apache, disk, exim, mysql, network, processes, system etc stats.
    munin stats

Resources:
http://munin-monitoring.org/

Share this post:

Learn how to change permissions for files and folders

You may want to change permission for multiple files and folders. This can be done with the chmod shell command.
The syntax for the chmod command is:

root@web [/scripts]# chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
  or:  chmod [OPTION]... OCTAL-MODE FILE...
  or:  chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that of RFILE.

  -c, --changes          like verbose but report only when a change is made
  -f, --silent, --quiet  suppress most error messages
  -v, --verbose          output a diagnostic for every file processed
      --no-preserve-root  do not treat '/' specially (the default)
      --preserve-root    fail to operate recursively on '/'
      --reference=RFILE  use RFILE's mode instead of MODE values
  -R, --recursive        change files and directories recursively
      --help     display this help and exit
      --version  output version information and exit

To change permission for all files in /home/username/public_html to 600, use:

find /home/username/public_html -type f -exec chmod 600 {} \;

To change permission for all directories in /home/username/public_html to 755, use:

find /home/username/public_html -type d -exec chmod 755 {} \;

To change permission for all files and directories in /home/username/public_html to 600, use:

chmod 644 /home/username/public_html -R
In the above examples, use the desired value for permissions (like 600, 700 etc)
Share this post:

Learn how to copy files and folders from/to another server

You want to copy some files and folders from another server? We will show how to do this action. We will use now the scp command. For more information check the link from the bottom of the article.

scp uses SSH protocol for data transfer, and uses the same authentication and provides the same security as SSH.

The scp syntax to copy files/folders from a remote server to the local server:

scp username@remote_host:remote_file /local_directory
scp -r username@remote_host:remote_directory /local_directory

The scp syntax to copy files/folders from the local server to a remote server:

scp local_file username@remote_host:/remote_directory
scp -r /local_directory username@remote_host:/remote_directory

Example on how to copy a file from a remote server:

scp root@remote_host:/home/username/cpmove-username.gz /home/

Example on how to copy a whole directory from a remote destination:

scp -r root@remote_host:/home/username/public_html /transfer
remote_host can be an IP or a domain name.

 

Resources:
https://linux.die.net/man/1/scp

Share this post:

Disable direct root login on your server

To increase server security you can disable direct root login. We will create a wheel user. You will connect first with this user and then you will use the su command to switch to the root user.

The necessary steps are:

  1. Create a new CentOS user using the command:
    adduser username
  2. Set a password for the created user with:
    passwd username
  3. Add the user to the Wheel Group. For this, run the command:
    usermod -aG wheel username
  4. Edit the /etc/ssh/sshd_config file:
    nano /etc/ssh/sshd_config

    Add the line (or modify if it is PermitRootLogin yes)

    PermitRootLogin no

    Save the file and exit the file editor.

  5. Restart the SSH server:
    service sshd restart
Also check our KB post on how to Create and remove CentOS users
Share this post:
Page 2 of 6
1 2 3 4 6