80 votes

How to check if an RSA public / private key pair match

Depending on where you get the public key file you are testing, the accepted answer may give false positive results. This is because of the behavior described in the comment by @drewbenn. Specifically,...
twildfarmer's user avatar
57 votes

SSH authorized_keys command option: multiple commands?

You can have only one command per key, because the command is “forced”. But you can use a wrapper script. The called command gets the original command line as environment variable $...
hfs's user avatar
  • 845
53 votes
Accepted

Return only a HTTP status code from curl command

You can use the -w parameter to define the format curl outputs. To get the status code and nothing else, use something like this: $ curl -s -o /dev/null -w "%{http_code}" http://xxx.xxx.xxx The ...
Miuku's user avatar
  • 840
32 votes
Accepted

How to print the last line of a gz compressed file in the command line?

If you want lines from the tail-end of a file rather than the head-end, use tail instead of head: $ zcat /var/log/syslog.2.gz | tail -1 Aug 24 07:09:02 myhost rsyslogd: [origin software="rsyslogd" ...
Dave Sherohman's user avatar
15 votes

SSH authorized_keys command option: multiple commands?

In the great SSH, The Secure Shell: The Definitive Guide book by O'Reilly, in chapter eight, there is a nice example given using a script like the following: #!/bin/sh /bin/echo "Welcome! Your ...
gxx's user avatar
  • 5,651
14 votes

How to check if an RSA public / private key pair match

The easiest is to compare fingerprints as the public and private keys have the same. Visual comparison is pretty easy by putting the two commands on same line: ssh-keygen -l -f PRIVATE_KEY; ssh-keygen ...
Oliver's user avatar
  • 250
13 votes
Accepted

What is difference between */5 and 5 for minute value in crontabs?

5 * * * * means it runs once per hour at five minutes past the hour. */5 * * * * means it runs once every five minutes. The later construct behaves slightly unintuitive if the number does not divide ...
kasperd's user avatar
  • 30.7k
11 votes
Accepted

SSH authorized_keys command option: multiple commands?

No. It is not "allowed" command, but "forced" command (as ForceCommand option). The only possibility is to use different keys for different commands or read parameters from stdin.
Jakuje's user avatar
  • 10k
10 votes

How to print the last line of a gz compressed file in the command line?

FWIW: I've developed a command line tool which can make a tail (-t) or even a continuous tail of a gzip file (-T) as it grows. (Many other options available): https://github.com/circulosmeos/gztool ...
circulosmeos's user avatar
9 votes
Accepted

How to check that all ZFS snapshots within a pool are without holds before destroying that pool

Not sure about how this looked back in 2012 but now you can check the userrefs property: zfs get userrefs To list all holds in all pools: zfs get -Ht snapshot userrefs | grep -v $'\t'0 | cut -d $'\...
dermetfan's user avatar
  • 206
6 votes

What is the function in Windows similar to Inode in Linux?

In NTFS file metadata is stored in the MFT records, which is the analog of inode in Windows. Each record has its own unique ID which is the equivalent to inode number. You can check this with fsutil ...
phuclv's user avatar
  • 179
6 votes

Ansible command ignore creates

One very basic solution. In your task: - name: Do command optionally ignoring create option command: cmd: touch /tmp/toto.txt creates: "{{ ignore_creates | default(false) | bool | ...
Zeitounator's user avatar
  • 1,293
5 votes

Nginx enable site command

NGINX If you're using one of the official upstream packages of nginx from http://nginx.org/packages/, the best way is to navigate to the /etc/nginx/conf.d directory, and rename the affected file from ...
cnst's user avatar
  • 14.3k
5 votes
Accepted

One liner to check if specific port(s) is/are open

for port in 6379 16379 26379;do nc -zv 127.0.0.1 $port;done Ofcause, you should use another server to check your firewall from the outside and not from the localhost to be sure that apps are blocked.
Alexander  Makarenko's user avatar
5 votes
Accepted

ping: Warning: time of day goes back (-203647us), taking countermeasures

This has happened to me on AMD type processors before, where the clocksource wasn't shared between CPUs (it was set to jiffies for me). One of the CPU's was a few jiffies ahead of the other causing ...
Matthew Ife's user avatar
  • 23.6k
4 votes

What is /usr/bin/[?

As others pointed out, [ is the shell's condition evaluation utility - test. In fact, there is a manual page for that! $ man [ should give you more details about the opening square bracket. ...
Devy's user avatar
  • 169
4 votes
Accepted

Continuously tailing a rotating log file with date and time in filename

You can create a script to tail the most recent log file in the background and then check regularly for a new log file. If there is a new log file, kill the old process and start tailing the new file. ...
NZD's user avatar
  • 246
3 votes
Accepted

How to find the ip address of the pc that sent a shutdown command?

Converting my comments/thoughts into an answer. It appears that you have given all of the students: Administrative control over all the computers. Anonymity by allowing them to all share the same ...
Ryan Ries's user avatar
  • 55.9k
3 votes

Is there a global, persistent CMD history?

Yes, it's possible If all you want to do is save your command line history at the end of every session, here's a simple way to do it: As other answers indicated, doskey allows you to list the command ...
pbarney's user avatar
  • 131
3 votes

Nginx enable site command

Link with full path: ln -s /etc/nginx/sites-available/site_1.conf /etc/nginx/sites-enabled/ service nginx reload
Marcelo Guedes's user avatar
3 votes
Accepted

fdisk with a a single command fail in the second execution

After creating a partition, you're moving on to setting the partition type: echo t;. Then, to the next prompt, you're outputting the desired partition type number... but that is not what fdisk is ...
telcoM's user avatar
  • 4,598
3 votes
Accepted

Azure App Service Plan - Specify App Size with PowerShell

The PowerShell command for this is confusing for two reasons: The docs are missing the property you need for this, "WorkerSize" The values for this property don't line up with the actual ...
Sam Cogan's user avatar
  • 39k
3 votes
Accepted

Retrieving Active Directory Users with no Email address from a certain group in powershell

Start from the group and get a members list; get the AD user object for each group member; check whether the user has an email address. Get-ADGroupMember $yourgroup | Get-ADUser -Properties mail | ...
Massimo's user avatar
  • 71.3k
2 votes

Nginx enable site command

Compact ngensite/ngdisite shell scripts After reading the replies here while setting up a new Debian server, then going off to do some research, I made a couple of readable shell scripts to help me ...
Dave Everitt's user avatar
2 votes

Is there a global, persistent CMD history?

I propose using Cygwin with Windows Terminal. It may not be exactly what you want but it works quite well for me. It also probably has some issues that I haven't discovered just yet. You can integrate ...
Vinayak's user avatar
  • 141
2 votes

Remove "Cc: " from mailx command

Change the command sending the email like this: mail "$To" -s "$Subject" < /dev/null It will do it for you. If you later decide that you need a Cc: recipient, simply add it with -c switch to the ...
13dimitar's user avatar
  • 2,546
2 votes
Accepted

find command with type and max date age

Read the manual ! See -mtime -2 to get the modifications in the last two days and only concerning the files with -type f http://man7.org/linux/man-pages/man1/find.1.html
Dom's user avatar
  • 6,793
2 votes

SSH authorized_keys command option: multiple commands?

Other approaches use e.g. a restricted shell for the given user or use a wrapper which restrains commands to al files/scripts found in a specific directory, thus allowing to augment the list of ...
Georg Lehner's user avatar
2 votes
Accepted

Trouble using powershell output as a variable in batch file

In the FOR command you need escape not only the parenthesis, but the mod (percent) as well. The parens are escaped with ^, the percent by %. Note that this will only work within a batch file, not the ...
jscott's user avatar
  • 24.7k
2 votes

How to cp files from sources to destination without using alias or non-alias and without getting confirmation/prompts?

Command Without Alias Any unix command can be prefixed with \ to get the non-alias version. With Alias #-(0) :: /dev/shm/test2 > ls total 0 -rw-------. 1 root 0 Feb 24 16:29 a -rw-------. 1 root ...
Aaron's user avatar
  • 2,859

Only top scored, non community-wiki answers of a minimum length are eligible