How to set up the driver for an HP all-in-one printer/scanner on CentOS 7 Linux? First, install these packages and it may ask you to download and install other plugins. Without these packages, my printer does work. # yum install hplip hplip-gui hpijs Second, install plugins for the HP printer. # hp-plugin Then you can
Read more
Author: Eric Ma
Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.How to detect whether a file is readable and writable in Python?
Posted onBefore reading or writing a file, access should be checked first. How to detect whether a file is readable and writable in Python? You can use the os.access(path, mode) library function https://docs.python.org/release/2.6.6/library/os.html#os.access like the Linux access library function for C. It returns True if access is allowed, False if not. For readable and writable, you
Read more
In Python, how to check whether a key already exists in a dict?
Posted onHow to check whether a key already exists in a dict in Python since version 2.6? If d is a dict(), you can directly test whether a key k is in d in Python by the in keyword like if k in d: ..
How to make a unique temporary file in Bash on Linux?
Posted onIt is common to make a unique temporary file. How to make a unique temporary file in Bash on Linux safely and quickly? You can use the mktemp program. In the simplest way, tmpfile=$(mktemp) The file will be like /tmp/tmp.j0wD39Mr3b if you do not prefer any meaningful names. You can set the file to your
Read more
How to handle spaces in paths with rsync on Linux?
Posted onThe common rsync commands seems not handle spaces well. For example, rsync -avxP file “user@server:/data/my dir” It reports: rsync: link_stat “/home/zma/file” failed: No such file or directory (2) How to make rsync handle spaces well? You can use the –protect-args option of rsync. $ rsync –protect-args -avxP file “user@server:/data/my dir” What does –protect-args do: -s,
Read more
How to install curlftpfs on CentOS 7?
Posted oncurtlftpfs is a nice tool to mount ftp to local. How to install curlftpfs on CentOS 7? The software package for curlftpfs is proved in EPEL. To install curlftpfs, first, enable EPEL following instructions here. Then, install curlftpfs by # yum install curlftpfs
How tinstall aria2 on CentOS 7?
Posted onHow tinstall aria2 on CentOS 7? aria2 is a great tool for downloading files from the Internet. The software package for aria2 is proved in EPEL. To install aria2, first, enable EPEL following instructions here. Then, install aria2 by # yum install aira2
How to install sshfs on CentOS 7?
Posted onsshfs is a nice tool. But it seems there is no support to it in a newly installed CentOS 7 Linux system: Not installed by default: # sshfs -bash: sshfs: command not found Seems not available from the repositories # yum install sshfs -y Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron?
Read more
How to install Flash Player plugin on CentOS 7?
Posted onFirefox on CentOS7 does not have Flash enabled by default. How to install Flash Player plugin on CentOS 7? You may follow this tutorials to build a freshwrapper based flash plugin for Firefox on CentOS 7. If you don’t want to build it by yourself, you may download the pre-built .so from from this repository.
How to make Ubuntu Linux boot to text mode?
Posted onMy Ubuntu boots to GUI mode by default. How to make Ubuntu Linux boot to text mode? If you are using Ubuntu older than 16 such as Ubuntu 14.04: Edit /etc/default/grub Change GRUB_CMDLINE_LINUX=… to GRUB_CMDLINE_LINUX=”text”. Backup your old grub config`$ sudo cp -n /etc/default/grub /etc/default/grub.bak-date +%s ` Update grub$ sudo update-grub If you are using
Read more
How to change CONFIG_HZ parameter for Linux Kernel
Posted onIf we want to change the tick time for Linux Kernel, we need to change CONFIG_HZ parameter in Linux Kernel. Do we have other better ways to change it rather than compiling Linux Kernel. Please ignore the way to add ‘divider=10’ in grub config file because it is limited only for RH/CentOS distros. Zhiqiang, please
Read more
How to add two static IPs for a Xen VM?
Posted onHello, I have installed Xen4Centos on Centos7, having single NIC card with bridge network and have two VMs on that. In one VM, I want to add two static IP one for webserver and one for mail server. So I have created IP alias in guest VM, it was created but it was not pinging
Read more
How to install aclocal on Fedora Linux?
Posted onI tried to build a project while it reports: # ./autogen.sh Can’t exec “aclocal”: No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326. autoreconf: failed to run aclocal: No such file or directory How should I handle this? How to install aclocal? yum install aclocal shows: No package aclocal available. Error: Unable to find a
Read more
rtl8192cu driver for CentOS 7
Posted onI find the rtl8192cu wireless adapter driver on CentOS 7 is quite unstable. After running a while, the connection will disappear. How to make it stable? There is a bug in some hardware where the device never wakes back up. You may try disabling the power management by putting a file 8192cu-disable-power-management.conf under /etc/modprobe.d/: #
Read more
Allowing root Access to NFS Directories
Posted onFor local filesystems, root usually has full access (read/write) to directories/files inside of it. But for NFS directory mounted from network, root usually has no permission to write to directories or files within the NFS directory. How to make root act similarly in an NFS directory to the behavior in local directories? The reason that
Read more
In Vim, are there shortcuts to set tab widths to 2 and 4?
Posted onTab widths may be different for different languages. Even with a common language, the tab width settings can be different for different projects. In Vim, are there shortcuts to set tab widths to 2 and 4? To quickly change the tab widths when changing projects. I am afraid no. But you create shortcuts for setting
Read more
How to install glibc, glibc-common and GD libraries independently?
Posted onI already have PHP and nginx installed and running on my on centOS 6.7. Please guide me, how can install glibc, glibc-common and GD libraries independently on my centOS 6.7 without crashing my system? I am not sure how you installed PHP and nginx. If they are installed from CentOS6.7’s Yum repository, you may install
Read more
Why I got message “invalid syntax, continuing…” when I execute “sysctl”?
Posted onWhen I tried to apply new configuration in /etc/sysctl.conf, I got following message. warning: /etc/sysctl.conf(44): invalid syntax, continuing… Sounds like your changed /etc/sysctl.conf has problem. You may post the content of your /etc/sysctl.conf here to let other have a check. net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1
Read more
Converting Error to String in Go Lang
Posted onIn Golang, fmt.Println(err) can print out the error err. But how to convert an error to a string explicitely? In Go, the error type is an interface type that has an interface type error interface { Error() string } An error variable represents any value that can describe itself as a string. Ref: https://golang.org/pkg/builtin/#error So,
Read more
In Golang, how to print string to STDERR?
Posted onIn Golang, the fmt.Println() is convenient to print to STDOUT. But how to print string to STDERR? In Go os package, “Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors.” So, you can use the WriteString function on File on os.Stderr to print string to
Read more