Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

Option 1: nohup
The best way is often the simplest.
***
nohup long-running-command &
***
It was made specifically for this, it even logs stdout to nohup.log.
***
man nohup
***
Option 2: bg + disown
***
ctrl+z
bg
disown -h
***
3 years ago
Use this:
***
sudo apt update # Fetches the list of available updates
sudo apt upgrade # Installs some updates; does not remove packages
sudo apt full-upgrade # Installs updates; may also remove some packages, if needed
sudo apt autoremove # Removes any old packages that are no longer needed
***
Documentation about each apt option can be found in the the manpages for apt. These are also available by running man apt in your terminal.

Use of both upgrade and full-upgrade together is usually not needed, but it may help in some cases
3 years ago
To extract an archive to a directory different from the current, use the -C, or --directory, tar option, as in
***
tar -xf archive.tar -C /target/directory
***
Note that the target directory has to exist before running that command (it can be created by mkdir /target/directory).
3 years ago
PEM on it's own isn't a certificate, it's just a way of encoding data. X.509 certificates are one type of data that is commonly encoded using PEM.

PEM is a X.509 certificate (whose structure is defined using ASN.1), encoded using the ASN.1 DER (distinguished encoding rules), then run through Base64 encoding and stuck between plain-text anchor lines (BEGIN CERTIFICATE and END CERTIFICATE).

You can represent the same data using the PKCS#7 or PKCS#12 representations, and the openssl command line utility can be used to do this.

The obvious benefits of PEM is that it's safe to paste into the body of an email message because it has anchor lines and is 7-bit clean.

RFC1422 has more details about the PEM standard as it related to keys and certificates.
3 years ago
As of GNU coreutils 7.5 released in August 2009, sort allows a -h parameter, which allows numeric suffixes of the kind produced by du -h:
***
du -hs * | sort -h
***
If you are using a sort that does not support -h, you can install GNU Coreutils. E.g. on an older Mac OS X:
***
brew install coreutils
du -hs * | gsort -h
***
From sort manual:
***
-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)
***
3 years ago
This will return true if a variable is unset or set to the empty string ("").
***
if [ -z "${VAR}" ];
***
3 years ago
You can't ping ports, as Ping is using ICMP which doesn't have the concept of ports. Ports belong to the transport layer protocols like TCP and UDP. However, you could use nmap to see whether ports are open or not
***
nmap -p 80 example.com
***
Edit: As flokra mentioned, nmap is more than just a ping-for-ports-thingy. It's the security auditers and hackers best friend and comes with tons of cool options. Check the doc for all possible flags.
3 years ago
Yup, use -r:

scp -rp sourcedirectory user@dest:/path
-r means recursive
-p preserves modification times, access times, and modes from the original file.
Note: This creates the sourcedirectory inside /path thus the files will be in /path/sourcedirectory
3 years ago
I've had success with Sysinternals Process Explorer. With this, you can search to find what process(es) have a file open, and you can use it to close the handle(s) if you want. Of course, it is safer to close the whole process. Exercise caution and judgement.

To find a specific file, use the menu option Find->Find Handle or DLL... Type in part of the path to the file. The list of processes will appear below.

If you prefer command line, Sysinternals suite includes command line tool Handle, that lists open handles.

Examples

c:\Program Files\SysinternalsSuite>handle.exe |findstr /i "e:\" (finds all files opened from drive e:\"
c:\Program Files\SysinternalsSuite>handle.exe |findstr /i "file-or-path-in-question"
3 years ago
Don't use a password. Generate a passphraseless SSH key and push it to your VM.

If you already have an SSH key, you can skip this step… Just hit Enter for the key and both passphrases:
***
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
***
Copy your keys to the target server:
***
$ ssh-copy-id id@server
id@server's password:
***
Now try logging into the machine, with ssh 'id@server', and check in:
***
.ssh/authorized_keys
***
to make sure we haven’t added extra keys that you weren’t expecting.

Finally check logging in…
***
$ ssh id@server

id@server:~$
***
You may also want to look into using ssh-agent if you want to try keeping your keys protected with a passphrase.
3 years ago
here is the correct code:
***
server {
listen 80;
server_name my.domain.com;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name my.domain.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000" always;

[....]
}
***
3 years ago
Using the built-in SSH client shipped with Git for Windows, you need to set up the HOME environment variable so that the Git SSH client can find the key.

For example, on a Windows Vista installation, this would be done by issuing setx HOME c:\Users\admin\ on the command line.

It made my day and fixed the issue with Git provided that your private key is not password protected. If you want to use ssh-agent, then you can probably run ssh-agent cmd.exe (although I've never done that) and the ssh-add as usual.

Note that all Git/SSH tools are supposed to be run from a cmd.exe in order not to blink a window.

If this does not work correctly, using plink can probably be achieved by tweaking GIT_SSH. Refer to all the SVN + ssh tutorials; this is basically the same plumbing you need to setup.
3 years ago