How to get the CPU temperatur in command linux on Linux?

Posted on

Most modern servers or computers have sensors to detect the temperature of various components. On Linux, how to get the CPU core temperatur in command linux? First, make sure the package “lm-sensors” is installed on your Linux and the command sensors works for you. Then, you can use this piece of script to get the
Read more

How to test whether PATH has a specific directory in it in Bash on Linux?

Posted on

How to test whether PATH has a specific directory in it in Bash on Linux? For example, how to test whether /usr/local/mytool/bin is in $PATH? Directories in the $PATH variable are separated by :. So you can use a regular expression to test whether the $PATH contains a directory. The code for your specific example
Read more

How to make the rpcbind.service auto start in systemd on Linux?

Posted on

The command systemctl enable rpcbind.service seems not work. The rpcbind.service does not start after rebooting. How to make/force the rpcbind.service auto start in systemd on Linux? You an force the rpcbind.service to start by making it be “wanted” by the target such as multi-user: # systemctl add-wants multi-user rpcbind.service This will force rpcbind.service to start.

How to make lftp to use key for authentication for sftp on Linux?

Posted on

I have successfully enabled password-less ssh login to a remote server, say example.com with username user. But when I use lftp to log on the sftp by lftp sftp://user@example.com it still asks my password. How it make lftp use my private key to logon the remote lftp server? There is a little trick to make
Read more

How to test a file or directory exists in Python?

Posted on

In Bash, the [ -f ] and [ -d ] tests can test whether a file or a directory exist. What are the corresponding python method for these tests? For -f: **os.path.isfile(path)** Return True if path is an existing regular file. This follows symbolic links. For -d: **os.path.isdir(path)** Return True if path is an existing
Read more

How to get a user’s home directory from the username in a variables in Bash?

Posted on

In Bash, ~username gives the username user’s home. However, this does not work for situations where username is in a variable such as ~$user How to get the home directory from the user name in a variable in Bash? You can use this Bash script snippet: userhome=$(eval echo ~$user) Here, $user get evaluated to its
Read more

How do I force Linux to unmount a filesystem?

Posted on

Some time, Linux fails to unmount a filesystem reporting “device is busy”. I understand that this helps avoid data lost by disallowing unmouting a filesystem when it is being used. But for some situations, I am sure there is something wrong happened or I care not data lost, such as a NFS mounting while the
Read more

Linux boots failed with “sulogin: can not open password database” while the /etc/passwd and /etc/shadow files look fine

Posted on

Linux boots failed with “sulogin: can not open password database” while the /etc/passwd and /etc/shadow files look fine. How to fix this? The OS is Fedora 22. You may try this trick Step 1: boot Linux with rw init=/bin/bash following this tutorial. Step 2: after Linux booted, disable SELinux following this tutorial. Reboot. If it
Read more

How to debug media print view of Web page in Firefox?

Posted on

How to debug the media print view set by @media print {} in CSS of Web pages in Firefox? In firefox, after opening the Web page, First, hit “Shift + F2” to open the “Developer Toolbar” at the bottom. Second, in the “Developer Toobar”, input media emulate print and Firefox will show the print view
Read more