How to make curl request pass the Squid proxy?

I use curl to send requests to remote servers like following command. curl –date-urlencode “data=hello” However, it is blocked by the network proxy squid in some networks with message like (some info anonymized with “…”): ERROR The requested URL could not be retrieved POST /… HTTP/1.1 Proxy-Authorization: Basic … User-Agent: Mozilla/4.0 (compatible;) Host: … […]

How to find a wireless network adapter’s speed in Linux?

How to find a wireless adapter‘s speed in Linux? ethtool does not show the speed of the wireless adapters. For finding the configured speed of wireless adpaters in Linux, you can use the iwconfig tool. iwconfig: configure a wireless network interface For example, to find the speed of the wireless adapter wlp8s0: # iwconfig wlp8s0 […]

How to sort all files recursively by modification time in a directory on Linux?

How to sort all the files in a directory and subdirectories recursively by modification time on Linux? You can make use of find (GNU find, or plus stat), sort and sed together to achieve recursively sort files by modification time: find . -type f -printf ‘%T@ %pn’ | sort -k 1 -n | sed ‘s/^[^ […]

How to find which program or process is listening on a certain port in Linux?

My program reports that the port is already used. How to find which program or process is listening on a certain port in Linux? You can use netstat to do this. netstat can print network connections. For example, to find which program is listing on port 9999 netstat -pln | grep 9999 You will need […]

How to move all the files under Users for a user to another drive on Windows?

Unfortunately, my C: drive is almost full. Most of the space are used by the user home under C:Users. How can I move the home directory to another drive while not affecting the user’s usage of Windows. On Linux/Unix, moving the directory to another drive/partition and then keeping a softlink is enough. But how to […]

How to redirect STDOUT of sudo command on Linux and write to file as root?

A try like the following command failed $ sudo echo “echo hello” > /usr/local/bin/hello with an message bash: /usr/local/bin/hello: Permission denied It seems the writing to the file is executed under the non-root user. How to redirect STDOUT of sudo command on Linux and write the content to the file (/usr/local/bin/hello here) as root? You […]

How to email admins automatically after a Linux server starts?

Managing a cluster of servers, I would like to notified when a server is started. How to make the Linux servers email me or other admins automatically after they are started? I did this by adding a crontab entry on each servers like @reboot date | mailx -S smtp=smtp:// -s “`hostname` started” -r […]

How to merge multiple PDF files to a PDF on Linux?

convert seems works not very well when merging PDFs. The quality is low. Any other better methods to merge multiple PDF files to a single PDF on Linux? ghostscript works the best for me on merging PDFs: gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf merges in{1..3}.pdf to out.pdf. Answered by Eric […]

How to avoid mounting failures blocking Linux booting?

Some entries in /etc/fstab may not not critical for booting Linux or even not available until Linux has booted. How to avoid the failures or unavailability of some mounting entries in /etc/fstab blocking the boot process of Linux? Please check the tutorial at Controlling Filesystem Mounting on Linux by Playing with /etc/fstab: Allow non-root users […]

How to set replication factors for HDFS directories?

Is it possible to set the replication factor for specific directory in HDFS to be one that is different from the default replication factor? This should set the existing files’ replication factors but also new files created in the specific directory. This can simplify the administration. We can set the replication factor of /tmp/ to […]

How to get files without certain strings in their files names (reverse of *string*) on Linux?

To get files with certain string in their file names, it is quite straightforward: ls *string* However, how to do the reverse one: how to get files without certain strings in their files names on Linux? You can get a list of file names by a combination of find and xargs as follows: find . […]