Hiển thị các bài đăng có nhãn CentOS. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn CentOS. Hiển thị tất cả bài đăng

Add User to wheel group in CentOS 7

 How to Add User to wheel group in CentOS 7 - e Learning (wsldp.com)

Add User to wheel group using usermod command

In usermod command -G option use to specify the group that user wants be added.(if -a options is not used user will be removed from other groups he is already a member of).

usermod -a -G wheel username

Example

usermod -a -G wheel jon

The above example will add the user jon to the CentOS 7 wheel group.

Add user to wheel group in CentOS 7 using gpasswd command

Command option -a use to add a user to group in gpasswd command.

gpasswd -a username wheel

Example

gpasswd -a admin wheel

Above Example will add user admin to the CentOS 7 wheel group.

Remove user from wheel group in CentOS 7

The gpasswd command also use to remove a user from the wheel group. To remove a user we use -d option.

Example

gpasswd -d admin wheel

Above Command will remove user admin from the wheel group.

CentOS 7 Filesystem Hierarchy

 CentOS 7 Filesystem Hierarchy - Understand the directory structure of Linux CentOS 7 (wsldp.com)

CentOS 7 Filesystem Hierarchy - Understand the directory structure of Linux CentOS 7

/

The system root directory(Not to be confused with /root folder which is the home folder of root user). This the top level directory of a any Linux filesystem. All other files and folders resides inside the / directory in the CentOS 7 filesystem hierarchy.

/boot

Contain the file needed to boot the system. Linux boot loader contain inside the /boot directory.

/etc

In CentOS 7 file system /etc directory contains the system configuration files. Most of the time theses files are cannot be accessed by the normal Linux users.

/proc

proc file system, also called as the virtual filesystem contains the detailed information about system hardware and any running processes in CentOS 7.  Inside the /proc you will see a directory for every running Linux process, named after the PID of that process. And unlike other directories, the proc file system does not exist on the hard disk, but in the system memory (RAM), This is why it is also called as the pseudo-filesystem.

/dev

Contains the device file used by by system to access the hardware. in Linux CentOS 7 all devices are represented by a file. these device files are can be found inside the /dev directory. When you plugged a hardware device on to the computer, you can find the file related to that hardware inside the /dev directory. Example hard disk drive, USB, CD Rom and etc…

/home

Users personal data and configuration file contains inside the /home directory. By default every Linux user has a home folder by their name inside the /home directory.

/root

This is the home directory of the root super user. /root directory cannot be accessed by other users without superuser privileges.

/var

Dynamic files including databases,cache directories and log files can be found inside /var directory. Files inside /var directory changes dynamically while the system is running.

/usr

Contained install softwares and programmes and shared libraries.

/usr/bin

Contains the Common programs and commands that are accessible by all users of the CentOS 7 system. For example, basic Linux commands like ls, cd, pwd, etc.. contains inside the /usr/bin directory. These programs are executable by both administrators and regular Linux users.

/usr/sbin

Contains the programs and commands use by the system administrators. Commands in /usr/sbin directory in CentOS 7 cannot be executed without administrative privileges.

/run

Inside the /run directory contains the runtime data for processes started since the last boot.

/tmp

/tmp directory use to store temporary files. files inside /tmp directory will be automatically deleted after certain days(Normally after 10 days)

/mnt

Use as a mount point when mounting devices manually.

/opt

Additional software and programs can be installed inside the /opt directory.

Add Users to a Group on CentOS 7

 How to Add a User to a Group on CentOS (linuxhint.com)

Now to add the user ash to the work group with the following command:

sudo usermod -aG work ash

CentOS: List groups/users

How To List Users and Groups on Linux – devconnected 

cat /etc/passwd


cat /etc/group



Using the groups command

The most memorable command to list all groups a user is a member of is the groups command. When executed without an argument the command will print a list of all groups the currently logged in user belongs to:

groups

The first group is the primary group.

john adm cdrom sudo dip plugdev lpadmin sambashare

To get a list of all groups a specific user belongs to, provide the username to the groups command as an argument:

groups linuxize

Certbot doesn't know how to automatically configure the web server on this system

 letsencrypt "Certbot doesn't know how to automatically configure the web server on this system" (repusic.com)


sudo yum install python-certbot-apache



How can I give write-access of a folder to all users in linux?

 permissions - How can I give write-access of a folder to all users in linux? - Super User

To best share with multiple users who should be able to write in /var/www, it should be assigned a common group. For example the default group for web content on Ubuntu and Debian is www-data. Make sure all the users who need write access to /var/www are in this group.

sudo usermod -a -G www-data <some_user>

Then set the correct permissions on /var/www.

sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www

Additionally, you should make the directory and all directories below it "set GID", so that all new files and directories created under /var/www are owned by the www-data group.

sudo find /var/www -type d -exec chmod 2775 {} \;    

Find all files in /var/www and add read and write permission for owner and group:

sudo find /var/www -type f -exec chmod ug+rw {} \;

You might have to log out and log back in to be able to make changes if you're editing permission for your own account.

How to Remove (Delete) a User on CentOS 7

 How to Remove (Delete) a User on CentOS 7 | Liquid Web

Step 1: Delete the User

It’s just one simple command to delete a user. In this case, we’re removing a user called mynewuser:

userdel mynewuser

If you want to remove all the files for the user, then use -r:

userdel -r mynewuser

Step 2: Remove Root Privileges to the User

For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor

visudo

Find the following code:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
mynewuser ALL=(ALL) ALL

In this case, we’re removing root privileges from the user mynewuser . Remove the following:

mynewuser ALL=(ALL) ALL

Then exit vim by saving the file with the command with :wq .

Centos 7: Install nodejs

 

1. Install NVM (Node Version Manager)

To download the nvm install script run the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

The script will clone the nvm repository from Github to ~/.nvm and add the script Path to your Bash or ZSH profile.

=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

As the output above shows, you should either close and reopen your terminal or run the commands to add the path to nvm script to your current session.

To verify that nvm was properly installed type:

You can list available versions using ls-remote:

nvm ls-remote


To download, compile, and install the latest release of node, do this:

nvm install node # "node" is an alias for the latest version

To install a specific version of node:

nvm install 6.14.4 # or 10.10.0, 8.9.1, etc

The first version installed becomes the default. New shells will start with the default version of node (e.g., nvm alias default).

How to Install Apache on CentOS 7

 Install Apache on CentOS 7 | Liquid Web


  1. Install Apache:
    1. First, clean-up yum:
      sudo yum clean all
    2. As a matter of best practice we’ll update our packages:
      sudo yum -y update
    3. Installing Apache is as simple as running just one command:
      sudo yum -y install httpd
  2. Allow Apache Through the Firewall
    1. Allow the default HTTP and HTTPS port, ports 80 and 443, through firewalld:
      sudo firewall-cmd --permanent --add-port=80/tcpsudo firewall-cmd --permanent --add-port=443/tcp
    2. And reload the firewall:
      sudo firewall-cmd --reload
  1. Configure Apache to Start on Boot
    1. And then start Apache:
      sudo systemctl start httpd
    2. Be sure that Apache starts at boot:
      sudo systemctl enable httpd
  2. Other useful commands for Apache
    1. To check the status of Apache:
      sudo systemctl status httpd
    2. To stop Apache:
      sudo systemctl stop httpd

Difference between “chmod 775” and “chmod 2755”

 linux - Difference between "chmod 775" and "chmod 2755" - Unix & Linux Stack Exchange

from man chmod:

2000    (the setgid bit).  Executable files with this bit set will
        run with effective gid set to the gid of the file owner.

The 2 in front of 775 is the setgid or "group id".

What is setgid (set group ID) bit used for?

The setgid affects both files as well as directories.

  1. When setgid permission is applied to a directory, files that were created in this directory belong to the group to which the directory belongs. Any user who has write and execute permissions in the directory can create a file there. However, the file belongs to the group that owns the directory, not to the user's group ownership. Files in that directory will have the same group as the group of the parent directory.

  2. When used on a file, it executes with the privileges of the group of the user who owns it instead of executing with those of the group of the user who executed it.

Sources:

https://www.geeksforgeeks.org/setuid-setgid-and-sticky-bits-in-linux-file-permissions/ https://docs.oracle.com/cd/E19683-01/816-4883/secfile-69/index.html

More on group ids:

At login, the password file (/etc/passwd) looks up your login user ID and determines your numeric user ID and one initial group user ID. The group file (/etc/group) then assigns to you your other group IDs (if any). The system then starts up a shell that runs as your unique numeric user ID and also has the permissions of all your numeric group IDs (one or more).

Source: http://teaching.idallen.com/cst8207/13w/notes/500_permissions.html#users-one-user-id-and-multiple-group-ids

How to set a group id to a directory:

chmod 2775 /var/www

The 2 in front of 775 causes the group who is the owner of /var/www to be copied to all new files/folders created in that directory.

There are also other options then 2:

0: setuid, setgid, sticky bits are unset
1: sticky bit is in place
2: setgid bit is in place
3: setgid and sticky bits are in place
4: setuid bit is in place
5: setuid and sticky bits are in place
6: setuid and setgid bits are on
7: setuid, setgid, sticky bits are activated

Source: http://www.dba-oracle.com/t_linux_setuid_setgid_skicky_bit.htm

Group ids can be checked for a group name in the /etc/group file:

group_name:password:GROUP_ID

More on group passwords: https://unix.stackexchange.com/a/46518/205850

AH00035 permission denied

  sudo chmod 751 /home/ubuntu sudo chown -R ubuntu:www-data /home/ubuntu/genealogy-giapha sudo chmod -R 750 /home/ubuntu/genealogy...