How to copy file preserving directory path in Linux?

The switch you need is –parents, e.g.: jim@prometheus:~$ cp –parents test/1/.moo test2/ jim@prometheus:~$ ls -la test2/ total 42 drwxr-xr-x 3 jim jim 72 2010-09-14 09:32 . drwxr-xr-x 356 jim jim 43136 2010-09-14 09:32 .. drwxr-xr-x 3 jim jim 72 2010-09-14 09:32 test jim@prometheus:~$ ls -la test2/test/1/.moo -rw-r–r– 1 jim jim 0 2010-09-14 09:32 test2/test/1/.moo

How can I kill all stopped jobs?

To quickly kill all the stopped jobs under the bash, enter: kill -9 `jobs -ps` jobs -ps lists the process IDs (-p) of the stopped (-s) jobs. kill -9 `jobs -ps` sends SIGKILL signals to all of them.

How can I monitor hard disk load on Linux?

You can get a pretty good measure of this using the iostat tool. % iostat -dx /dev/sda 5 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda 0.78 11.03 1.19 2.82 72.98 111.07 45.80 0.13 32.78 1.60 0.64 The disk utilisation is listed in the last column. This is defined as … Read more

List of files installed from apt package

Note: in the following commands, a command beginning with ‘root#’ means it needs to be run as root. To find which files were installed by a package, use dpkg -L: $ dpkg -L $package apt-file can tell you which files will be installed by a package before installing it: root# apt-get install apt-file root# apt-file … Read more

Colors in bash after piping through less?

Most likely your ls is aliased to ls –color=auto, which tells ls to only use colors when its output is a tty. If you do ls –color (which is morally equivalent to ls –color=always), that will force it to turn on colors. You could also change your alias to do that, but I wouldn’t really … Read more

Is it possible to make Nginx listen to different ports?

Yes, it is. What you probably want is multiple “server” stanzas, each with a different port, but possibly (probably?) the same server_name, serving the “different” content appropriately within each one, maybe with a different document root in each server. Full documentation is here: http://nginx.org/en/docs/http/server_names.html Example: server { listen 80; server_name example.org www.example.org; root /var/www/port80/ } … Read more

Why do we use a OS Base Image with Docker if containers have no Guest OS?

Since all Linux distributions run the same (yup, it’s a bit simplified) Linux kernel and differ only in userland software, it’s pretty easy to simulate a different distribution environment – by just installing that userland software and pretending it’s another distribution. Being specific, installing CentOS container inside Ubuntu OS will mean that you will get … Read more

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