What does ‘set -e’ do, and why might it be considered dangerous?

set -e causes the shell to exit if any subcommand or pipeline returns a non-zero status. The answer the interviewer was probably looking for is: It would be dangerous to use “set -e” when creating init.d scripts: From http://www.debian.org/doc/debian-policy/ch-opersys.html 9.3.2 — Be careful of using set -e in init.d scripts. Writing correct init.d scripts requires … Read more

What does Virtual memory size in top mean?

Virtual memory isn’t even necessarily memory. For example, if a process memory-maps a large file, the file is actually stored on disk, but it still takes up “address space” in the process. Address space (ie. virtual memory in the process list) doesn’t cost anything; it’s not real. What’s real is the RSS (RES) column, which … Read more

How do I sleep for a millisecond in bash or ksh

Bash has a “loadable” sleep which supports fractional seconds, and eliminates overheads of an external command: $ cd bash-3.2.48/examples/loadables $ make sleep && mv sleep sleep.so $ enable -f sleep.so sleep Then: $ which sleep /usr/bin/sleep $ builtin sleep sleep: usage: sleep seconds[.fraction] $ time (for f in `seq 1 10`; do builtin sleep 0.1; … Read more

SSL Certificate Location on UNIX/Linux

For system-wide use, OpenSSL should provide you /etc/ssl/certs and /etc/ssl/private. The latter of which will be restricted 700 to root:root. If you have an application that doesn’t perform initial privilege separation from root, then it might suit you to locate them somewhere local to the application with the relevantly restricted ownership and permissions.

Difference in sites-available vs sites-enabled vs conf.d directories (Nginx)?

The sites-* folders are managed by nginx_ensite and nginx_dissite. For Apache httpd users who find this with a search, the equivalents is a2ensite/a2dissite. The sites-available folder is for storing all of your vhost configurations, whether or not they’re currently enabled. The sites-enabled folder contains symlinks to files in the sites-available folder. This allows you to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)