Operating System
- How Do I Change the Password of a Linux OS User
- How Do I Upload or Download files on Linux
- How Do I Add the sudo Permission to a User
- How Do I Add Execution Permissions of Files for root Users
- How Do I Create a User with root Permissions
- How Do I Connect the Operating System Image to the Server
- How Do I Configure an IPv6 Address for an NIC
- How Do I Restore the Default Route
- How Do I Add the Static Routes
- How Do I Unlock a Common Linux User
- How Do I Resolve the Problem that the /tmp Directory Is Automatically Cleared
How Do I Change the Password of a Linux OS User
Question
How do I change the password for a Linux OS user?
Answer
- Log in to the Linux OS.
- To change the password for the root user, log in to the server as the root user.
- To change the password for a common Linux user, log in to the server as a common user.
- In the command-line interface (CLI), run the following command to modify the password.
# passwd root New password: Enter a new password. Confirm password: Enter the new password again.
How Do I Upload or Download files on Linux
Question
How do I upload or download files on Linux?
Answer
You are advised to upload or download files using SCP. This topic uses WinSCP as an example.
- On the PC or portable computer, double-click the shortcut icon of the WinSCP client to open the WinSCP tool.
You can visit https://winscp.net to download the latest version of the WinSCP tool. For more operation information on the WinSCP tool, see its online help or visit its official website to obtain technical support.
- Select the SCP protocol, enter the IP address, user name, password, and port number of the Linux server, and then log in. The port number is 22 by default.
If you use the operating system provided by iMaster NCE-Campus, you must log in as the sopuser user, and select the SCP protocol.
If you use a user-supplied operating system, make sure that the logged in user has remote access and the remote login function is enabled on the accessed node.
- The left side is the local directory, and the right side is the directory of the remote Linux system. Drag files between the two areas to upload or download files.
How Do I Add the sudo Permission to a User
Question
How do I add the sudo permission to a user?
After you add the sudo permission to a user, the user will have the permissions of the root user. This involves certain security risks. Therefore, exercise caution when performing this operation, and delete the user when the user is no longer necessary.
Answer
- Log in as the root user.
- Enter the file edit mode.
# visudo
Insert the following configuration item to root ALL=(ALL) ALL in the configuration file:
xxx ALL=(ALL) ALL xxx ALL=(ALL)NOPASSWD:ALL
Where xxx indicates the user name.
- Save the settings and exit.
- Remove the read and write permissions of the file.
#chmod u-w /etc/sudoers
How Do I Add Execution Permissions of Files for root Users
Question
When I log in to the Linux operating system as the root user, some files cannot be executed because of the limitation of execution permissions as shown in the following picture. How do I add execution permissions of files for root users?
Answer
- Run the following command to add execution permissions of files for root users.
# chmod -R a+x file path
If the path of the installation package is /opt/install, run the following command:
# chmod -R a+x /opt/install
How Do I Create a User with root Permissions
Question
How do I create a user with root permissions?
Answer
- Run the following command to create a user name.
# useradd -d /home/huawei -m huawei
/home/huawei is the user's home directory, and huawei is the user name.
- Modify the password of the huawei user.
- Run the following command to check the password policy.
# vi /etc/pam.d/common-password
The information is displayed as follows.
password requisite pam_pwcheck.so cracklib remember=5 minlen=14 enforce_for_root password required pam_cracklib.so retry=3 dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=14 reject_username password required pam_unix.so sha256 shadow use_authtok
The password shall conform to at least the following requirements.
- Does not contain the username.
- Contains at least 14 characters.
- Contains at least one special character, such as space !"#$%&'()*+,-./:\;<=>?@[]^`{_|}~.
- Contains at least one uppercase letter, one lowercase letter, and one digit.
- Run the following command to modify the password.
# passwd huawei
- Enter the new password as prompted.
Changing password for huawei New Password:
- Enter the new password again.
Reenter New Password
- Enter the new password again.
Retype new password
- Run the following command to check the password policy.
How Do I Connect the Operating System Image to the Server
Question
How do I connect the operating system image to the server?
Answer
- On the remote console, click the drive icon, choose Image File, and click Browse.
- Select the local image file, and click Connect.
How Do I Configure an IPv6 Address for an NIC
Question
How do I configure an IPv6 address for a NIC?
Answer
- Log in to the server as the root user.
- Set the values of the following configuration items to 0 in the /etc/sysctl.conf file.
If the following configuration items do not exist, add them.
vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=0 net.ipv6.conf.default.disable_ipv6=0 net.ipv6.conf.lo.disable_ipv6=0
- Run the following command for the settings to take effect.
sysctl -p
- Configure a global IPv6 address for a NIC.
Assume that you want to add the IP address fe80::1096/64 for eth1.
vi /etc/sysconfig/network-scripts/ifcfg-eth1
Add the following content to the end of the file.
IPV6INIT='yes' IPV6ADDR=fe80::1096/64 IPV6_DEFAULTGW=fe80::1024
- Edit the /etc/sysconfig/network-scripts/route6-eth1 file.
fe80::1096/64 via fe80::1024 dev eth1
- Restart the network for the settings to take effect.
service network restart
Run the ifconfig command to check the new IPv6 address.
How Do I Restore the Default Route
Question
What can I do if the default route is lost on the operating system?
Answer
- Log in to the server as the root user.
- Restart the network service.
service network restart
- Check whether the default route is restored.
route -n
How Do I Add the Static Routes
Question
The SetNicForEuler.sh script can be used to add only one route for a NIC. How to add multiple static routes for a NIC?
Answer
- Log on to the server with the root user.
- Add a static route to the NIC.
Take the example of adding a static route to eth1.
vi /etc/sysconfig/network-scripts/route-eth1
Add the following content:
ADDRESS1=192.168.20.0 NETMASK1=255.255.255.0 GATEWAY1='192.168.2.1'
If the NIC already has routing information, you need to increment the number of the route, such as ADDRESS1.
- Restart the network service.
service network restart
- Check the routing information.
route -n
Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth1 192.168.20.0 192.168.2.1 255.255.255.0 UG 0 0 0 eth1
How Do I Unlock a Common Linux User
Question
If a common Linux user (such as the ossuser user) gets locked after multiple wrong passwords, how do I unlock the user?
Answer
You can unlock a common user as the root user.
- Log in to the Linux OS as the root user.
- Run the following command to unlock the common user. In this example, the username is ossuser.
# pam_tally2 -u ossuser -r
After the account is unlocked, log in as the ossuser user. If you forget the ossuser user password, you can log in as the root user and run the following command to reset the password of the ossuser user.
# passwd ossuser
How Do I Resolve the Problem that the /tmp Directory Is Automatically Cleared
Question
The operating system has a cache reclamation mechanism. If the operating system is not used for a long time (for example, the system has not been logged in for more than 15 days), files in the /tmp directory may be deleted. As a result, the controller page is blank.
Answer
- Log in to the server as the sopuser user and switch to the root user.
- Check whether a clearing mechanism exists.
systemctl status systemd-tmpfiles-clean
If the following information is displayed, the clearing mechanism exists:
● systemd-tmpfiles-clean.service - Cleanup of Temporary Directories Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-clean.service; static; vendor preset: disabled) Active: inactive (dead) since Tue 2019-07-30 15:14:29 CST; 4h 44min ago Docs: man:tmpfiles.d(5) man:systemd-tmpfiles(8) Process: 35093 ExecStart=/usr/bin/systemd-tmpfiles --clean (code=exited, status=0/SUCCESS) Main PID: 35093 (code=exited, status=0/SUCCESS) Jul 30 15:14:29 ac01 systemd[1]: Starting Cleanup of Temporary Directories... Jul 30 15:14:29 ac01 systemd[1]: Started Cleanup of Temporary Directories.
- Comment out the deletion time.
vi /usr/lib/tmpfiles.d/tmp.conf
Comment out the following content:
#v /tmp 1777 root root 10d #v /var/tmp 1777 root root 30d
- Disable the clearing mechanism.
systemctl mask systemd-tmpfiles-clean
Created symlink from /etc/systemd/system/systemd-tmpfiles-clean.service to /dev/null.
- Check the clearing mechanism status.
systemctl status systemd-tmpfiles-clean
If the status is masked, the clearing mechanism has been disabled.
● systemd-tmpfiles-clean.service Loaded: masked (/dev/null; bad) Active: inactive (dead) since Tue 2019-07-30 15:14:29 CST; 4h 50min ago Main PID: 35093 (code=exited, status=0/SUCCESS) Jul 30 15:14:29 ac01 systemd[1]: Starting Cleanup of Temporary Directories... Jul 30 15:14:29 ac01 systemd[1]: Started Cleanup of Temporary Directories.
- How Do I Change the Password of a Linux OS User
- How Do I Upload or Download files on Linux
- How Do I Add the sudo Permission to a User
- How Do I Add Execution Permissions of Files for root Users
- How Do I Create a User with root Permissions
- How Do I Connect the Operating System Image to the Server
- How Do I Configure an IPv6 Address for an NIC
- How Do I Restore the Default Route
- How Do I Add the Static Routes
- How Do I Unlock a Common Linux User
- How Do I Resolve the Problem that the /tmp Directory Is Automatically Cleared