西维蜀黍

【Linux】命令 - ulimit

Demo

# Get the properties of all the user limits:
$ ulimit -a 

# Get hard limit for the number of simultaneously opened files:
$ ulimit -H -n

# Get soft limit for the number of simultaneously opened files:
$ ulimit -S -n

# Set max per-user process limit:
$ ulimit -u 30
  ...


【Linux】Too Many Open Files

System Level - FD Limits

file-max is the maximum file descriptors (FD) enforced on a kernel level, which cannot be surpassed by all processes.

Use the following command command to display maximum number of open file descriptors:

$ cat /proc/sys/fs/file-max
9223372036854775807
# or
$ sysctl fs.file-max
fs.file-max = 9223372036854775807

9223372036854775807 files normal user can have open in single login session.

To change the general value for the system /proc/sys/fs/file-max, change the fs.file-max value in /etc/sysctl.conf:

$ fs.file-max = 100000

And apply it:

$ sysctl -p

  ...


【Linux】命令 - rsync

Install

macOS

$ brew install rsync

Ubuntu

$ sudo apt-get install rsync

Configuration of the rsync Daemon

The rsync daemon is an alternative to SSH for remote backups. Although more difficult to configure, it does provide some benefits. For example, using SSH to make a remote backup of an entire system requires that the SSH daemon allow root login, which is considered a security risk. Using the rsync daemon allows for root login via SSH to be disabled.

Edit the file /etc/default/rsync to start rsync as daemon using xinetd. The entry listed below, should be changed from false to inetd.

RSYNC_ENABLE=inetd

Install xinetd because it’s not installed by default.

$ sudo apt-get -y install xinetd

Create the file /etc/xinetd.d/rsync to launch rsync via xinetd. It should contain the following lines of text.

service rsync
{
    disable = no
    socket_type = stream
    wait = no
    user = root
    server = /usr/bin/rsync
    server_args = --daemon
    log_on_failure += USERID
    flags = IPv6
}

Create the file /etc/rsyncd.conf configuration for rsync in daemon mode. The file should contain the following. In the file, user should be replaced with the name of user on the remote machine being logged into.

max connections = 2
log file = /var/log/rsync.log
timeout = 300

[share]
comment = Public Share
path = /home/share
read only = no
list = yes
uid = nobody
gid = nogroup
auth users = user
  ...


【Engineering】Coupling

Coupling

In software engineering, coupling is the degree of interdependence between software modules; a measure of how closely connected two routines or modules are;[1] the strength of the relationships between modules.

Coupling and cohesion Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. Low coupling is often thought to be a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.

  ...


【Linux】命令 - su

To confirm that the user is changed, use the whoami command:

$ whoami
# Switch to superuser (requires the root password):
$ su

# Switch to a given user (requires the user's password):
$ su username

# Switch to a given user and simulate a full login shell:
$ su - username

# Execute a command as another user:
$ su - username -c "command"
  ...