date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,625,864,176,000
Looking at the source of ssh-copy-id at openssh-portable/ssh-copy-id at master · openssh/openssh-portable · GitHub it looks like ssh-copy-id can copy the key to user specified authorized_keys files on the server, besides the default ~/.ssh/authorized_keys. However there doesn't seem to be a command line option for it,...
Looking at the source file you mentioned, the commands may be executed as a remote shell skript, that is built on the fly on the local host. This is only used when ssh-copy-id does not use SFTP and the remote version is not NetScreen. Then it could be possible if you change the environment variable AUTH_KEY_FILE.
Can ssh-copy-id be configured to save to a different authorized_keys file?
1,604,442,307,000
Lets say that I have a file /etc/ssh/sshd_config with RevokedKeys /etc/ssh/keys/cert.list What does revoke when I add a ssh certificate (not the public key) to /etc/ssh/keys/cert.list? I've found that what is really revoked is the public key which is based that certificate. I mean, if I issue a new certificate with th...
It depends on what you list As listed on ssh-keygen(1): The files may either contain a KRL specification (see below) or public keys, listed one per line. Plain public keys are revoked by listing their hash or contents in the KRL and certificates revoked by serial number or key ID (if the serial is zero or not availa...
Rationale behind revocation of ssh certificates
1,604,442,307,000
I use CentOS 7 and would like to know if it is possible to block login via ssh (sshd) for a certain period of time after a certain amount of attempts. EXAMPLE: After 3 wrong attempts the login is blocked for 15 minutes. Thanks! =D
As the comment above said, fail2ban should be worth looking at. It prevents bruteforce attempts and supports whitelisting, so it should fit to your criteria.
sshd - Block login via ssh (sshd) for a certain period of time
1,604,442,307,000
I have two machines A and B within the organization network. I have openssh-server installed and ssh running on both the machines. Both the machines have Ubuntu 16.04. I am able to ssh from A to B without any password. I tried setting up password-less ssh on B as well. ssh-copy-id does not work. Also, ssh B to A does ...
If the hosts are on the same network the most probable causes are: SSH service not started Traffic is blocked on the SSH server According to the comments the traffic was blocked by A, disallowing access from both B and C
SSH: A to B works, B to A does not
1,604,442,307,000
I am trying to figure out an issue I have been having. I am using a webpanel called TinyCP and there is a table for displaying failed login attemps via SSH. All SSH attempts, failed or successful, show that they are coming from my NAT. This then gives them all the same IP addresses and disabled me from using fail2ban...
No Performing network address translation (NAT) is conceptually very different from using a HTTP proxy server. There is no way to tell the remote's private local IPv4 address. It would defeat the very purpose of NAT (that is aggregating a network into a singl host). On a side note: FTP reveals the remote's address (an...
Ubuntu SSH Auth Log Shows Proxy IP
1,604,442,307,000
If there's a SSH setup like this: Host A -> Host B <- Host C Where Host C is behind a NAT/firewall an opens a reverse tunnel to Host B and Host A connects to Host C via Host B (ProxyCommand). Everything is IPv4 only. Is there a simple way to establish IP(v6) connectivity between Host A and Host C without requiring ex...
It looks like you are confusing SSH port forwarding with VPNs. These are very different concepts with different capabilities. SSH Port forwarding lets one server (ip and port) masquerade as another server (ip and port). From your diagram, this would let Host A think it was talking to Host B (port 1234) when it's act...
Using OpenSSH to create overlay IPv6 network [closed]
1,604,442,307,000
if i'd like to have another user be able to ssh into my ec2 instance, is there any pros/cons between generating an ssh key for that user in the ec2 instance, and then copying the private key to that user's local computer, versus the new user generating an ssh key on their local computer and copying the public key to t...
Before I outline any benefits to either method, I will point out that the industry standard for this type of thing is to generate the key-pair on the client system, not the server, largely because it provides a much better user experience. Now, for the advantages and disadvantages, they pretty much complement each oth...
pros/cons between generating ssh keys on client vs server
1,604,442,307,000
The server I am logging into does not allow setting up SSH keys, so I have to type in a password + a code generated from a device every time I do an ssh. What I used to be able to do on my Mac is that I would ssh to the machine, and it only asks me to type in the password the first time. After that, whenever I open a ...
Enable multiple sessions over a single connection in ~/.ssh/config host * controlmaster auto controlpath /tmp/ssh-%r@%h:%p ControlPersist yes
SSH without retyping password in new terminal window/tab
1,604,442,307,000
I have this weird situation: On a Centos 6.6 box, in my sshd_config, I have the line AllowGroups foo bar baz just like on all the other servers. However, when user baz (whose group is baz) tries to login on this one server, login is denied, In the logs I see May 17 16:27:03 myserver sshd[6172]: User baz from other.s...
Thanks to @Jakuje I checked the group membership with groups baz which showed that the effective group is not what I expecting from the entry in /etc/group. As we also have centrify installed, I looked at the config, which seems correct(baz was listed in /etc/centrifydc/groups.ignore). I restarted the agent (service c...
sshd AllowGroups group not granting access [closed]
1,604,442,307,000
How do you delete ssh if you suspect ra root administrating your macbook.. And are under a control by ssh remote?
How do you delete ssh if you suspect ra root administrating your macbook.. And are under a control by ssh remote? Deleting (literally) ssh won't help. You would need to delete / disable sshd. The ssh command is for out-going SSH sessions. You are dealing with incoming SSH sessions. But deleting / disabling sshd i...
Under remote (ssh) .. How do I remove all remotes and root logins [closed]
1,604,442,307,000
ssh is still asking for a password, even though I did everything by the book. I have included all output, right from the start. Any ideas? Thanks! Gary Generating public/private rsa key pair and checking permissions on local host Edit: => As it turned out, this was the problem. The key pair needed to be generated on...
(I'm wondering if the term "[email protected]" could cause any problems. Thats the name of the local host computer in the local network. fritz.box is the router's name) No, it is just comment. debug1: identity file /Users/name/.ssh/id_rsa type -1 [...] debug1: Trying private key: /Users/name/.ssh/id_rsa debug3: n...
SSH still asking for password even after I have tried everything (that I know of)
1,604,442,307,000
How do I set up a remote internet web server using CentOS 7 so that it is completely shielded by a VPN? Here is the use case: 1.) This means that ALL requests for ANY interaction with the web server would have to come through the VPN from a known user. Including http/https requests. 2.) Each server mi...
From what I know, you can't implement every feature you require without custom / commercial products to lock down everything. Here are some thoughts to keep in mind while elaborating on how to meet the required critera: Typical VPN-solutions add routes. For routes to be added, the user needs to have administrative rig...
CentOS 7 VPN server
1,604,442,307,000
When I open an SSH connection to our database server and leave it open for a longer time, the connection gets lost at some point. I don't know why or how, but this happens a lot. I still see the prompt, but can't enter anything. I usually kill the terminal and open a new one. If I wait much longer, I get an error mess...
You can implement ServerAliveInterval, ClientAliveInterval, and ClientAliveCountMax to solve your timeout issue. Please see this post
SSH connection gets lost, but not when logged in to MySQL
1,604,442,307,000
When booting my laptop today I found that ssh (openssh) simply refuses to accept my passphrase when reading my private key. My only idea of how that could've happened is if the HDD has somehow corrupted the key, but I figure that if that is the case I'd probably notice system instability in other ways too. This isn't...
Two ideas: First, try to import the key into the ssh-agent with ssh-add $keyfile to be sure it is really a problem with the keyfile and not something about the server. Second, fetch a copy of your private key from your backup and use something like cmp to check, whether the file really changed.
ssh private key stops accepting my passphrase
1,604,442,307,000
I am using docker ubuntu container to set up an SSH lab on my local machine. I have interactively started the container and installed open ssh on it with other tools. I ensured that I port forward container:22 to my localhost:2222 docker pull ubuntu docker run -it --name ubunut-ssh-lab -p 2222:22 ubuntu /bin/bash apt-...
When using a docker Ubuntu container, it is possible the image does not have the /root directory in it by default. In this situation, trying cd ~ in an interactive session with docker would give below: root@4e56fee1ea11:/# cd ~ bash: cd: /root: No such file or directory Therefore perform additional steps! mkdir /root...
Setting up a SSH Lab using docker on my local machine
1,604,442,307,000
I have a remote SSH server with several custom utilities for my work. However, there are times when I feel lazy and don't want to start a full SSH session just to execute a single command. This motivated me to create a multi-call script à la BusyBox that I could make symlinks to which would look at the name it was cal...
It looks like I needed to add another level of escaped quotes to make bash run the command properly. So far, this works exactly as I want it to. #!/bin/bash exec ssh -q -t eng-vm bash -l -c \""$(basename "$0") ${*@Q}"\"
How to make a script to forward commands to an SSH server?
1,679,570,278,000
On a remote server, I would like to access via ssh only with a pem key, which is password protected, but I'm being asked for the user account password as well I created the account which I want to use when log in from my host with the following command: sudo useradd -d /home/admin -m -G sudo admin Since my pem key is...
I resolved adding my public key in the public key to ~/.ssh/authorized_keys using VI instead Nano, perhaps Nano add some kind of formatting to the text that won't let the public key to be recognized.
Access to remote server via SSH via pem key and not be asked for user password as well
1,679,570,278,000
My config: debian 10.9 4.19.0-19-amd64 OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019 autossh 1.4g GNU bash, 5.0.3(1)-release (x86_64-pc-linux-gnu) I start a service in /etc/systemd/system/myshh.service ExecStart=/home/user/ssh_run starts my script ssh_run THIS ARE ONLY TWO OF A LOT EXAMPLES WITH SSH AND ...
If someone has the same problem, this post save my day now: How do I figure out why my systemctl service didn't start Add Type=forking to my service file /etc/systemd/system/myshh.service. Now i can execute a ssh/autossh remote port forwarding command inside a bash script and the -f option for the background execution...
Start a service and Run/load a script with ssh or autossh, remote port forwarding in the background "-f" to execute more/next commands in the script!
1,679,570,278,000
My goal is to increase my ssh connection timeout on my server, where I have limited permisssions. I do not have permission to even read /etc/ssh/sshd_config (nor append/write) and I do not have sudo. Locally on my PC, I already did in ~/.ssh/config: Host * ServerAliveInterval 300 ServerAliveCountMax 2 However...
You need to identify how long it takes for an idle session to get timed out. (If you're getting timeouts across sessions that are not idle then we're chasing the wrong type of solution.) For example, if it's one minute, then set the Keepalive to half that, i.e. 30 seconds. I'd recommend that you don't change the defau...
Increase SSH Connection timeout on server side without permissions
1,679,570,278,000
I have a custom command line script that I want the users to access over SSH. For example when the user logs in with ssh user@server the user should be able to interact with the command line application instead of directly accessing /bin/bash (or any other shell). Are there any configuration changes that should be don...
sshd_config's ForceCommand is what you're looking for. Also, caveat: you say it's a shell script, so no matter what you do, it will still be executed by a shell. This need not be problematic, but it certainly means you need to think about what you do with user input – e.g. eval'ing it should be out of the question.
Using ssh authentication with a custom application
1,679,570,278,000
Ssh connection failure from macbook. This stopped working after trying to migrate to Centos 8 MacBook-Pro:~ $ ssh -Y -vvv [email protected] -p 32 OpenSSH_8.6p1, LibreSSL 2.8.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files de...
152.3.36.72 port 32: Connection refused indicates that the host 152.3.36.72 doesn't have a ssh server running on port 32. As you were upgrading the system it is possible that the old ssh configuration with non-standard port 32 was overwritten with a new default configuration. Try connecting to the default port 22. Ano...
Centos 7.9 ssh connection failure from macbook
1,679,570,278,000
By example, when connect to ssh and execute /usr/libexec/openssh/sftp-server -d /opt/files can get / root directory from a sshfs connection. By example: have a test user and from authorized_keys have two access, one with all access and other with limited access, by example: restrict,command="/usr/libexec/openssh/sftp-...
Just having the -d option for sftp-server will not cause the session to be chrooted. sftp-server has no special privileges on its own, and the chroot() system call requires root privileges (or a specific CAP_SYS_CHROOT capability, if separate capabilities are being used). So it is actually impossible for sftp-server t...
openssh/sftp-server virtual chroot does not work
1,679,570,278,000
I am trying to ssh from an Ubuntu machine ( VM on Win 10) to a linux server using public keys (DSA). However the OpenSSH client on the Ubuntu does not try public keys as authentication method even though I have added below lines to /etc/ssh/ssh_config: PubkeyAuthentication yes PubkeyAcceptedKeyTypes +ssh-dss. The pe...
The issue was with related to my internet connection - it was not allowing publickey authentication on port 22. SSH publickey authentication works fine after switching to another connection.
ssh client not trying publickey authentication on port 22
1,592,395,739,000
I have a system with both a public (e.g server1.foo.bar) and privately-resolvable (e.g. server1.internal.foo.bar) DNS name. SSH connections are only possible via the private IP, but I always think of these hosts in terms of their public name. I would like to: connect to the right IP regardless of whether I remember t...
I figured out a working method. It's a bit ugly, but it does work. This leverages the ProxyCommand directive (see manpage) combined with a small bash helper script. Add sections like this to ~/.ssh/config — one for each domain you want remapped: Match final host="!*.corp.foo.com,*.foo.com" ProxyCommand ssh_ext2i...
How can I configure ~/.ssh/config such that `ssh foo.bar` results in a connection to `foo.internal.bar`?
1,592,395,739,000
I'm not really sure where or to whom I should ask this question, so hopefully you all can help me. I am working on a project that I would like to add data to the end of each packet before encryption on an SSH client, then take that data off the packet right after decryption on the SSH target. I'd like to do this with ...
An alternative is to leave ssh alone (meaning for example that you can also apply updates and security fixes without recompiling). You then do your out-of-bound communication with a wrapper, using port forwarding instead. That's already been done, check the -M flag in autossh.
Working with SSH/SSL
1,592,395,739,000
I am trying to create a homemade server. I'm running Ubuntu 18.04 and have an Xfinity router. I've forwarded port 22 to a reserved local IP for my server. The problem is that I can connect via a different network (using my iPhone hotstop), but only for about 3 minutes after my router starts up. At this time the xfini...
Update: the problem was the router’s firewall. Even on low security it blocked incoming traffic. Seems like kind of a gaping vulnerability for the firewall to take longer to start up than the router @xfinity (which is why I was able to ssh only for a few minutes after start up). Oh well, thanks everybody!
SSH only working shortly after router reboot
1,592,395,739,000
Presently I am using this for controlpath ControlPath /home/user/.ssh/sockets/ssh_mux_%h_%p_%r If i connect to a hostname 'redishost' it creates socket with redishost If i connect to same host 'redishost' with its ip address it creates socket with ip address Is it possible to use ip for all ssh connections inste...
after checking openssh documentation and source I found that openssh don't have any token for controlpath expression where ip address can be specified. In case if you want to use it you can use my repo which I edited source of openssh and added the token %x for ip address resolving. Now ControlPath becomes: Cont...
ssh ControlPath use ip address instead of hostame %h
1,592,395,739,000
I have the following set up in my ~/.ssh/config match host devbox compression yes user hari port 22 hostname 192.168.9.7 match originalhost devbox exec "~/.ssh/check_if_outside_home.sh" hostname devbox.harisund.com The idea is this - Always connect to 192.168.8.15 (this will work if I am already at th...
That's just as designed and documented in man 5 ssh_config: For each parameter, the first obtained value will be used. The configuration files contain sections separated by Host specifications, and that section is only applied for hosts that match one of the patterns given in the specification. The matched...
Changing hostname more than once via ~/.ssh/config
1,592,395,739,000
To set the specified sshd log file in ssh server pc this way. vim /etc/rsyslog.conf local0.* /var/log/sshd.log vim /etc/ssh/sshd_config SyslogFacility local0 To create the log file: touch /var/log/sshd.log To restart all services. systemctl restart rsyslog systemctl restart sshd To get all the ssh log in ssh c...
Do the following on the client: script logfile.log ssh into the machine do whatever you need exit from ssh exit from script It will log everything that happens inside the script session to the file specified at the beginning until you exit. Beware of commands that manipulate the whole screen (vi, top, etc...) as they...
How to set the specified ssh log file in ssh client pc?
1,592,395,739,000
So I have this server I log on with my sudoer account via SSH using a key. I have also created another, restricted, account so that I can give another user access to SFTP files into a specific folder. Now, when I try to connect using sftp, it´s still spitting invalid key back at me. I would like that specific user to...
In /etc/ssh/sshd_config Define the following exception in sshd by adding this block for each user name: Match User username ChrootDirectory %h ForceCommand internal-sftp PasswordAuthentication yes If you have multiple accounts, it's easier to have a group catch: Match Group sftp ChrootDirectory %h ForceComman...
Set up SFTP to not require private key [closed]
1,592,395,739,000
I have a openssh-server. On Ubuntu 14.04x behind a firewall (I have no admin rights to) I want to create a ssh tunnel from my Kali Linux rolling that is using a tether from mobile device that is behind a firewall I have no admin rights. Is this possible? I have chrome remote desktop which allows command line access to...
Ubuntu----Firewall1----Internet----Firewall2----Kali And you want to SSH to the ubuntu box from the kali box, with no access to either firewall. There are two things you need to have. 1) Some way for an inbound connection to pass through Firewall1 and get to the Ubuntu host. Which port is irrelevant, as long as so...
Ssh tunneling fron behind nat firewalls
1,446,135,488,000
When i log in to my raspberry pi it shows me this message, i like the fact that it shows the last login but the info is too long (also because i log in from mobile devices). Linux RaspberryPi 4.1.11+ #822 PREEMPT Fri Oct 23 16:14:56 BST 2015 armv6l The programs included with the Debian GNU/Linux system are free softw...
This message comes from the standard file /etc/motd where the administrator can put info for people logging in. Simply empty it, eg: sudo sh -c '>/etc/motd' You can get the ip address of a last login with last -i $USER | grep -v 'still logged' | head -1 From the comments below: PrintMotd no in /etc/ssh/sshd_config i...
Show only last login in the SSH welcome message
1,446,135,488,000
I'm new in Linux, but learning bits by bits.. So please give explanation too, instead of only the answer, to help me understand about why and how. Currently I want to build an android rom with Xubuntu OS. I already setup openSSH to connect remotely. my remote pc is win10, using putty for ssh. my question are: can I us...
You may want look into GNU screen or tmux. they both have the attach feature. typical workflow looks like this: Connect with SSH Start a screen/tmux session. Do your work. Disconnect. Next time you login, attach the last session and continue working.
can I use ssh to send build command for android building?
1,446,135,488,000
I have installed g++ package on Cygwin. so I see the following output in Cygwin: Input:$ which g++ Output: /cygdrive/c/mingw-w64/x86_64-6.2.0-posix-seh-rt_v5-rev1/mingw64/bin I have also installed openssh package on Cygwin and configured an ssh server. However, when I connect remotely to my Cygwin I have the followin...
put the change of PATH in your ~/.bashrc As reported in the code it will be set for # base-files version 4.1-1 # ~/.bashrc: executed by bash(1) for interactive shells.
Different bash profile files are loaded? For local and ssh-remote access to Cygwin
1,446,135,488,000
I am pretty new to unix, so please bare with me... when i try to connect to my server running ubuntu server through terminal on my ubuntu workstation I get this error: bash: 22: command not found the command I type in to connect is : ssh user@ip 22 then i get the response that asks for the user's pass, after i ente...
Port 22 is the standard port used to connect to sshd. It is used by default, so unless you have configured your remote host to listen on a non-standard port in your sshd_config, then all you need to do is ssh user@ip. If your remote host were listening on port 2222, for instance, the syntax for specifying that would ...
ssh error bash: 22: command not found
1,446,135,488,000
Why is 50-redhat.conf listed twice with different file sizes for this directory with this ls: ls -la /etc/ssh/ssh* -rw-r--r--. 1 root root 1921 Aug 2 02:58 /etc/ssh/ssh_config -rw-------. 1 root root 3667 Aug 2 02:58 /etc/ssh/sshd_config -rw-r-----. 1 root ssh_keys 480 May 20 02:38 /etc/ssh/ssh_...
The two files are different. The one occurring in ssh_config.d contains SSH client configuration. The one found in sshd_config.d contains SSH server configuration.
Why does ls show this file twice with different sizes?
1,446,135,488,000
I work in a government agency. We are running a sftp client and sftp-server on a DMZ system where we receive and send files over the internet. Our environment: OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 Linux version 3.10.0-1160.102.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) ...
Since you are already using REL, I would suggest staying with it although you should upgrade to version 8 or 9. As @tink has pointed out, REL backports security patches into their packages without changing the major/minor version numbers so your will be very safe there. If possible, you might want to enable FIPS 140-2...
What openssh version is best on Linux when it comes to stability and security ( sftp security )? [closed]
1,446,135,488,000
I was reading about OpenSSH and I have the following questions: What is the difference between ssh and slogin? What is the difference between scp and sftp? Does sshd (on server side) provide separate server processes to handle each client (ssh, slogin, sftp, scp) type requests or just one process for all client ty...
Since the questions are listed, I'll list the respective answers: slogin is an alias for ssh (they are the same) further reading scp and sftp do similar things in that they transfer files, but scp is a separate program that uses ssh to copy files. sftp is an extension of ssh itself that transfers files similar to FT...
Openssh Questions [closed]
1,446,135,488,000
I am setting up a Debian server through DigitalOcean, which I initialized with a SSH-key. Currently I can log onto the server as root or as a user. Normally when I do this type of configuration, I uncomment PermitRootLogin yes from /etc/ssh/ssh_config, and change it to PermitRootLogin no. This time, however, I saw a ...
The ssh_config file is the default configuration for SSH clients. The server configuration will be found in sshd_config. The PermitRootLogin is a server setting (it modifies the behaviour of the SSH server) that should go in the server configuration file.
Does OpenSSH no longer support the "PermitRootLogin" keyword? [closed]
1,446,135,488,000
I have a redhat server 7.5. I have a openssh installed on this server. The openssh is 7.4. I need to upgrade openssh 7.4 to 7.6 AS Nessus, vulnerability scanner scanned this vulnerability (Openssh <7.6) and thus need to upgrade to 7.6 or later.The details is found here, https://www.tenable.com/plugins/nessus/103781. ...
The issue linked to in the comments refers to CVE-2017-15906 (listed on the same page). Red Hat has documented this CVE along with its details, which is available here: https://access.redhat.com/security/cve/cve-2017-15906 According to the CVE page, an errata has been issued on this issue for RHEL 7 (RHSA-2018:0980). ...
install openssh 7.6 on red hat 7.5 [duplicate]
1,446,135,488,000
How can I communicate with a Linux computer from my Android phone with the help of SSH? I connected Android device from Linux computer vith SSH. How I communicate with a linux machine via SSH?
You need to make sure you have ssh acess on the account you are trying to connect to. open /etc/ssh/ssh_config and add: PermitRootLogin no AllowUsers username Replace username with the user you would like to ssh into. Restart ssh with either sudo service ssh reload or systemctl restart sshd
How can I communicate with a Linux device via SSH? [closed]
1,446,135,488,000
i want upgrade openssh, as i have error: error: Unsafe AuthorizedKeysCommand: bad ownership or modes for file /usr/bin/get_ldap_ssh_key.sh In sshd_config: AuthorizedKeysCommand /usr/bin/get_ldap_ssh_key.sh AuthorizedKeysCommandUser nobody Bureport say Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1 I ...
That's not a bug that upgrading will fix, but an error in your setup. The sshd_config(5) manpage says AuthorizedKeysCommand Specifies a program to be used to look up the user's public keys. The program must be owned by root, not writable by group or others and specified by an absolute path. You simpl...
How to upgrade openssh? [closed]
1,446,135,488,000
echo $SSH_CONNECTION does not display anything on the SSH server. I use my laptop to connect to my server using a key-less SSH setup. After SSHing to my server, if I run echo $SSH_CONNECTION in a terminal on the server from the machine itself I'm supposed to see the IP address and port numbers of my remote and local ...
The SSH_CONNECTION environment variable will be set in the SSH session. It will not be set for any other process on the SSH server than for those started from the SSH connection from the client. If you are logged in directly on the SSH server (on the physical machine, not through SSH), and type echo $SSH_CONNECTION, t...
$SSH_CONNECTION Does not display the IP addresses or port port numbers of ssh cnnections [closed]
1,283,455,842,000
I have written a script that runs fine when executed locally: ./sysMole -time Aug 18 18 The arguments "-time", "Aug", "18", and "18" are successfully passed on to the script. Now, this script is designed to be executed on a remote machine but, from a local directory on the local machine. Example: ssh root@remoteServe...
You were pretty close with your example. It works just fine when you use it with arguments such as these. Sample script: $ more ex.bash #!/bin/bash echo $1 $2 Example that works: $ ssh serverA "bash -s" < ./ex.bash "hi" "bye" hi bye But it fails for these types of arguments: $ ssh serverA "bash -s" < ./ex.bash "--...
How can I execute local script on remote machine and include arguments?
1,283,455,842,000
Currently I'm writing a Bash script which has the following requirements: it should run on a wide variety of Unix/Linux platforms it should support both short and (GNU) long options I know that getopts would be the preferred way in terms of portability but AFAIK it doesn't support long options. getopt supports long ...
If it has to be portable to a range of Unices, you'd have to stick to POSIX sh. And AFAIU there you just have no choice but rolling argument handling by hand.
getopt, getopts or manual parsing - what to use when I want to support both short and long options?
1,283,455,842,000
Problem When copying files with cp -H or cp -L, I get the same results: $ ls -l fileA fileA -> fileB $ cp fileA somewhere/ -H $ ls -l somewhere/ fileA # fileA is a copy of fileB, only renamed, with same properties! This answer here describes both options as similar UNLESS used in combination with -R. Not for ...
With symlinks, tools have two things they can do: Treat the symlink as a symlink ("preserving its nature"), or Treat the symlink as the type of file that it points to. Saying that -H "preserves its nature" is not a contradiction. Consider the alternative. If you use -L, any symlinks cp finds will be opened, and th...
cp -L vs. cp -H
1,283,455,842,000
By reading this question, I have discovered that GNU grep has a -X option which expects an argument. Strangely, it is mentioned neither in the man page nor in the info page. Looking at the source code, there is that comment right in the middle of the --help output: /* -X is deliberately undocumented. */ Looking furt...
Its purpose is to provide access to the various matchers implemented in GNU grep in one form or another, in particular AWK matchers which aren’t available otherwise, probably for testing purposes (see bug 16481 which discusses adding the gawk and posixawk matchers). However it is currently buggy, which is the reason w...
What is the actual purpose of GNU grep's -X option and why is it undocumented?
1,283,455,842,000
Where did the convention of using single dashes for letters and doubles dashes for words come from and why is continued to be used? For example if I type in ls --help, you see: -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author ...
In The Art of Unix Programming Eric Steven Raymond describes how this practice evolved: In the original Unix tradition, command-line options are single letters preceded by a single hyphen... The original Unix style evolved on slow ASR-33 teletypes that made terseness a virtue; thus the single-letter options. Holding d...
Single dashes `-` for single-character options, but double dashes `--` for words?
1,283,455,842,000
when specifying ls --directory a* it should list only directories starting with a* BUT it lists files AND directories starting with a Questions: where might I find some documentation on this, other than man and info where I think I thoroughly looked? does this work in BASH only?
The a* and *a* syntax is implemented by the shell, not by the ls command. When you type ls a* at your shell prompt, the shell expands a* to a list of existing all files in the current directory whose names start with a. For example, it might expand a* to the sequence a1 a2 a3, and pass those as arguments to ls. The l...
why does ls -d also list files, and where is it documented?
1,283,455,842,000
I usually use grep when developing, and there are some extensions that I always want to exclude (like *.pyc). Is it possible to create a ~/.egreprc or something like that, and add filtering to exclude pyc files from all results? Is this possible, or will I have to create an alias for using grep in this manner, and cal...
No, there's no rc file for grep. GNU grep 2.4 through 2.21 applied options from the environment variable GREP_OPTIONS, but more recent versions no longer honor it. For interactive use, define an alias in your shell initialization file (.bashrc or .zshrc). I use a variant of the following: alias regrep='grep -Er --exc...
Is there a 'rc' configuration file for grep/egrep? (~/.egreprc?)
1,283,455,842,000
cd - can switch between current dir and previous dir. It seems that I have seen - used as arguments to other commands before, though I don't remember if - means the same as with cd. I found that - doesn't work with ls. Is - used only with cd?
The POSIX utility syntax guidelines (specifically #13) specify that for utilities that expect a file name to read from, - means standard input, and for utilities that expect a file name to write to, - means standard output. For example, cat somefile - copies the content of somefile to its standard output, followed by ...
Is `-` used only with cd?
1,283,455,842,000
The Arch Wiki on fstab specifies the options of / to be defaults,noatime, but on my installation the default fstab is created with the options of rw,relatime. The Arch Wiki covers the atime issues. What I am curious about is the defaults option. The man page for mount says: defaults Use the default options: rw, suid,...
You only need defaults if the field would otherwise be empty. You can leave out the options field altogether if it's empty, unless the 5th or 6th fields are present. Field 5 is the dump frequency, rarely used nowadays. Field 6 fsck order, should be 1 for /, 2 for other filesystems mounted on boot and 0 otherwise. Fiel...
Do you need to specify the "defaults" option in fstab?
1,283,455,842,000
Just using kubectl as an example, I note that kubectl run --image nginx ... and kubectl run --image=nginx ... both work. For command-line programs in general, is there a rule about whether an equals sign is allowed/required between the option name and the value?
In general, the implementation of how command-line arguments are interpreted is left completely at the discretion of the programmer. That said, in many cases, the value of a "long" option (such as is introduced with --option_name) is specified with an = between the option name and the value (i.e. --option_name=value),...
Do command line options take an equals sign between option name and value?
1,283,455,842,000
If I want to know the meaning of wget -b, I see the manual by man wget, then search the -b option. -b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log. I want to get the result by a command like man wget -b. (Of course t...
You could redirect the manpage to awk and extact the part: man wget | awk '/^ *-b *.*$/,/^$/{print}' -b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log. That part is everything that is between a -b and an em...
Is there way to see `man` document only for specified option of a command
1,283,455,842,000
Apparently, running: perl -n -e 'some perl code' * Or find . ... -exec perl -n -e '...' {} + (same with -p instead of -n) Or perl -e 'some code using <>' * often found in one-liners posted on this site, has security implications. What's the deal? How to avoid it?
What's the problem First, like for many utilities, you'll have an issue with file names starting with -. While in: sh -c 'inline sh script here' other args The other args are passed to the inline sh script; with the perl equivalent, perl -e 'inline perl script here' other args The other args are scanned for more opt...
Security implications of running perl -ne '...' *
1,283,455,842,000
What's the difference between du -sh * and du -sh ./* ? Note: What interests me is the * and ./* parts.
$ touch ./-c $'a\n12\tb' foo $ du -hs * 0 a 12 b 0 foo 0 total As you can see, the -c file was taken as an option to du and is not reported (and you see the total line because of du -c). Also, the file called a\n12\tb is making us think that there are files called a and b. $ du -hs -- * 0 ...
What is the difference between "du -sh *" and "du -sh ./*"?
1,283,455,842,000
I have learned to use tar without '-' for options, like tar cvfz dir.tar.gz Directory/ but I recently came accross the slightly different tar -czvf syntax (I think the 'f' must be the last option in this case). Both work on linux and Mac OS. Is there a recommended syntax, with or without '-', which is more portable ac...
tar is one of those ancient commands from the days when option syntax hadn't been standardized. Because all useful invocations of tar require specifying an operation before providing any file name, most tar implementations interpret their first argument as an option even if it doesn't begin with a -. Most current impl...
tar cvf or tar -cvf?
1,283,455,842,000
Are there some built-in tools that will recognize -x and --xxxx as switches (flags or "boolean options", rather than "ordinary arguments"), or do you have to go through all the arguments, test for dashes, and then parse the rest thereafter?
Use getopts. It is fairly portable as it is in the POSIX spec. Unfortunately it doesn't support long options. See also: the Small getopts tutorial (in the Bash Hackers wiki) another question on StackOverflow. If you only need short options, typical usage pattern for getopts (using non-silent error reporting) is: # ...
How do I handle switches in a shell script?
1,283,455,842,000
Recently I got to know of -- that is double-hyphen which is used to tell a command that the option list has ended and what follows should not be considered as a option. So, grep -- 'search_word' * would search for the given search_word. But you could see a unexpected behavior if you remove -- and if there is a sing...
The -- is working for tools which use getopt(3) to process command line arguments and many API that parse POSIX style options. From the manual page of getopt(3): The interpretation of options in the argument list may be cancelled by the option `--' (double dash) which causes getopt() to signal the end of argument pro...
What is `--` called?
1,283,455,842,000
I have this code - #getoptDemo.sh usage() { echo "usage: <command> options:<w|l|h>" } while getopts wlh: option do case $option in (w) name='1';; (l) name='2';; (h) name='3';; (*) u...
When you run this script without any options, getopt will return false, so it won't enter the loop at all. It will just drop down to the print - is this ksh/zsh? If you must have an option, you're best bet is to test $name after the loop. if [ -z "$name" ] then usage exit fi But make sure $name was empty before...
How can I detect that no options were passed with getopts?
1,283,455,842,000
Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck. The second most voted answer in this question recommends doing the following to get rid of the last line in a file: head -n -1 foo.txt > temp.txt However, when I...
You can remove the first 12 lines with: tail -n +13 (That means print from the 13th line.) Some implementations of head like GNU head support: head -n -12 but that's not standard. tail -r file | tail -n +13 | tail -r would work on those systems that have tail -r (see also GNU tac) but is sub-optimal. Where n is 1: ...
Negative arguments to head / tail
1,283,455,842,000
By reading the GNU coreutils man page for rm, one of the options is -f, which according to the manual, -f, --force ignore nonexistent files and arguments, never prompt Now, I made some tests and show that indeed if I use something like rm -f /nonexisting/directory/ it won't complain. What can someone reall...
I find that the man page lacks a little detail in this case. The -f option of rm actually has quite a few use cases: To avoid an error exit code To avoid being prompted To bypass permission checks You are right that it's pointless to remove a non-existent file, but in scripts it's really convenient to be able to say...
What's the real point of the -f option on rm?
1,283,455,842,000
ls --hide and ls --ignore provides the possibility leave out files defined through regular expressions set after the --ignore= part. The latter makes sure that this option isn't turned off via -a, -A. The command's man and info page mention Regular Expressions. Question: Which wildcards or Regular Expressions are supp...
From the manual: -I pattern, --ignore=pattern In directories, ignore files whose names match the shell pattern (not regular expression) pattern. As in the shell, an initial . in a file name does not match a wildcard at the start of pattern. Sometimes it is useful to give this option several times. For example, $...
syntax of ls --hide= and ls --ignore=
1,283,455,842,000
It's said that compiling GNU tools and Linux kernel with -O3 gcc optimization option will produce weird and funky bugs. Is it true? Has anyone tried it or is it just a hoax?
It's used in Gentoo, and I didn't notice anything unusual.
Compiling GNU/Linux with -O3 optimization
1,283,455,842,000
I know that rm -f file1 will forcefully remove file1 without prompting me. I also know that rm -i file1 will first prompt me before removing file1 Now if you execute rm -if file1, this will also forcefully remove file1 without prompting me. However, if you execute rm -fi file1, it will prompt me before removing file1....
When using rm with both -i and -f options, the first one will be ignored. This is documented in the POSIX standard: -f Do not prompt for confirmation. Do not write diagnostic messages or modify the exit status in the case of nonexistent operands. Any previous occurrences of the -i option shal...
The precedence of command options?
1,283,455,842,000
I read about that I should quote variables in bash, e.g. "$foo" instead of $foo. However, while writing a script, I found an a case where it works without quotes but not with them: wget_options='--mirror --no-host-directories' local_root="$1" # ./testdir recieved from command line remote_root="$2" # ftp://XXX recieved...
Basically, you should double quote variable expansions to protect them from word splitting (and filename generation). However, in your example, wget_options='--mirror --no-host-directories' wget $wget_options --directory_prefix="$local_root" "$remote_root$relative_path" word splitting is exactly what you want. With ...
Why do options in a quoted variable fail, but work when unquoted?
1,283,455,842,000
If I run the following .sh file: #!/bin/sh -a echo "a" | sed -e 's/[\d001-\d008]//g' The result is an error: sed: -e expression #1, char 18: Invalid range end But if I run the following .sh file: #!/bin/sh set -a echo "a" | sed -e 's/[\d001-\d008]//g' It runs without error. Isn't the second code supposed to be equ...
When bash is called with the name sh, it does this: if (shell_name[0] == 's' && shell_name[1] == 'h' && shell_name[2] == '\0') act_like_sh++; and then later sets the POSIXLY_CORRECT shell variable to y: if (act_like_sh) { bind_variable ("POSIXLY_CORRECT", "y", 0); sv_strict_posix ("POSIXLY_CORRECT"); ...
Why does -a in "#!/bin/sh -a" affect sed and "set -a" doesn't?
1,283,455,842,000
For example: xargs -n 1 is the same as xargs -n1 But if you look at the man page, the option is listed as -n max-args, which means the space is supposed to be preserved. There is nothing about the abbreviated form -nmax-args. This also happens with many other Linux utilities. What is this called in Linux? Do all ut...
When you write the command line parsing bit of your code, you specify what options take arguments and which ones do not. For example, in a shell script accepting an -h option (for help for example) and an -a option that should take an argument, you do opt_h=0 # default value opt_a="" while getopts 'a:h' opt; do ...
Why can spaces between options and parameters be omitted?
1,283,455,842,000
I'm curious - is there a difference between ls -l and ls -lllllllllllllllllllllllllllll? The output appears to be the same and I'm confused on why ls allows duplicate switches. Is this a standard practice among most commands?
Short answer: Because it's programmed to ignore multiple uses of a flag. Long answer: As you can see in the source code of ls, there is a part with the function getopt_long() and a huge switch case: 1648 int c = getopt_long (argc, argv, 1649 "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1...
Why does ls accept duplicate switches?
1,283,455,842,000
I am trying to find files containing a specific word using grep. There are many files in the directory (> 500) Command I run $ grep 'delete' * Output validate_data_stage1:0 validate_data_stage2:0 validate_data_stage3:0 validate_data_stage4:0 validate_data_stage5:0 validate_input_stage1:0 validate_input_stage2:0 valid...
That's the behavior exhibited by grep -c. Probably you have a file whose name starts with - and contains a c character and you're using GNU grep without setting the POSIXLY_CORRECT environment variable. Use: grep -- delete * or better: grep delete ./* -- marks the end of options so that that filename will not be con...
grep how to suppress display of non-matched file?
1,283,455,842,000
In below code when I give option r then getopts requires one arguments: while getopts ":hr::l:" opt; do case $opt in r ) echo "Run Numbers - argument = $OPTARG " ;; l ) echo "Latency range - argument = $OPTARG" ;; h ) helptext graceful_exit ;; * ) usage clean...
You cannot pass two arguments with single option using getopts. I recommend the following alternatives: Put quotes around multiple arguments In this case getopts will treat them as one argument, but you will be able to split it later on. You can even put all arguments in the array at once: #!/bin/bash while getopt...
Provide two arguments to one option using getopts
1,283,455,842,000
If I have a list of URLs separated by \n, are there any options I can pass to wget to download all the URLs and save them to the current directory, but only if the files don't already exist?
There is a -nc (--no-clobber) option for wget.
Download list of files if they don't already exist
1,283,455,842,000
I was reading the man page for rm when I came across this option: -P Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted. I guess -P is meant for thoroughly deleting a file, but wou...
There is a technique called residual information retrieval that can read data that was deleted based on the idea that when the drive is magnetized in order to store data other parts that are close to the data is also affected by this and it should be possible to re-read data this way ... this is though a costly techni...
What's the purpose of `rm -P`?
1,283,455,842,000
When I grep the man page of the find command for matches to type it returns a lot of search results that I don't want. Instead I want to use a command that returns only the search results for -type. The command man find | grep -type doesn't work. It returns: grep: invalid option -- 't'
If you want to grep for a pattern beginning with a hyphen, use -- before the pattern you specify. man find | grep -- -type If you want more info, for example the entire section describing an option, you could try using Sed: $ man find | sed -n '/-mindepth/,/^$/p' -mindepth levels Do not apply any tests ...
grep the man page of a command for hyphenated options
1,283,455,842,000
I am looking for the Linux command and option combination to display the contents of a given file byte by byte with the character and its numerical representation. I was under the impression that in order to do this, I would use the following: od -c [file] However, I have been told this is incorrect.
The key is the character and its numerical representation so -c only gives you half of that. One solution is od -c -b file but of course there are lots of different number representations to choose from.
Linux command to display the contents of a given file byte by byte with the character and its numerical representation displayed for each byte [closed]
1,283,455,842,000
I want to create a .tgz from the content of a directory. I also want to strip the leading "./" from the tar'ed content. I had done this as follows: cd /path/to/files/ && find . -type f | cut -c 3- | xargs czf /path/to/tgz/myTgz.tgz I learned recently that using xargs may not be the best way to pull this off because x...
It is a common convention to interpret - to mean standard input where an input file name is expected, and to mean standard output where an output file name is expected. Because this is a common convention, the short help summary in the GNU tar man page does not mention it, but the complete manual (usually available lo...
Portable way to invoke tar with a list of files from stdin
1,283,455,842,000
sort -o seems superfluous. What is the point of using it when we can use sort >? Is it sometimes impossible to use shell redirection?
Sort a file in-place: sort -o file file Using sort file >file would start by truncating the file called file to zero size, then calling sort with that empty file, resulting in an empty output file no matter what the original file's contents was. Also, in situations where commands or lists of options are automatically...
Why does sort have an --output= option?
1,283,455,842,000
I am trying to understand info who but completly fail at the term "non-option argument". Can someone please explain this term to me in simple words or an example? UPDATE: from info who : If given no non-option arguments, who prints the following information for each user currently logged on: login name, terminal line...
The terminology is not completely fixed, so different documentation uses different terms, or worse, the same terms with different meanings. The terminology in the man page you're reading is a common one. It is the one used in the POSIX standard. In a nutshell, each word after the command is an argument, and the argume...
What is a "non-option argument"?
1,283,455,842,000
The following works: git -C ~/dotfiles status But this fails: git status -C ~/dotfiles Why is this?
This is because -C is a global option, and doesn't "belong" to the status action. This is a common pattern, resulting in synopses like the one below: command [global options] action [action-specific options] git --help lists Git's global options, and man git goes into more detail.
Why does position of -C matter in git commands?
1,283,455,842,000
My nice is from GNU coreutils 9.1. I observed that nice -15 is equivalent to nice -n 15: nice # prints 0 for me, the base niceness is 0 nice -n 15 nice # prints 15, this is expected sudo nice -n -15 nice # prints -15, this is expected nice -15 nice # prints 15 -15 is a negative ...
The portable syntax requires -n if you want to specify an increment. When in doubt, use nice -n. In nice -15 the argument is not really a negative number. It is a dash concatenated with a positive number. The leading dash indicates it is an option. Compare this e.g. to kill -15 which is equivalent to kill -s 15. Simil...
Why does `nice` with a negative argument (e.g. `nice -15`) increment niceness?
1,283,455,842,000
I have the following situation: $ ls 0.txt aaa.txt a-.txt a.txt b.txt ddd.txt -hello.txt libs -.txt ,.txt !.txt ].txt \.txt $ ls [-a]*.txt ls: opzione non valida -- "e" Try 'ls --help' for more information. $ ls [a-]*.txt ls: opzione non valida -- "e" Try 'ls --help' for more information. The dash (-) cr...
Use -- to indicate end of options for ls: ls -- -* or do the following to explicitly indicate the argument on current directory with ./ ls ./-* If you want to input more options for ls, put them before -- or ./ e.g. ls -l -- -* ls -l ./-*
Finding a file starting with '-' dash [duplicate]
1,283,455,842,000
Question very similar to How to append multiple lines to a file with bash but I want to start the file with --, and also append to the file, if possible. printf "--no-color\n--format-doc\n--no-profile\n" >> ~/.rspec-test The issue is starting the file with "--" gives me a: -bash: printf: --: invalid option printf: us...
Most commands that accept --foo as an option also accept -- by itself as an "end of options, start of arguments" marker - so you could do: printf -- "--no-color\n--format-doc\n--no-profile\n" >> ~/.rspec-test But the more specific answer to your exact example is that the first argument to printf is a format specifier...
How to append multiple lines to a file with bash, with "--" in front of string
1,283,455,842,000
I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
As I can see you don't need to remove your dir , only files inside. So you can recreate it rm -r /path/to/dir && mkdir /path/to/dir or even delete only files inside find /path/to/dir -type f -delete afair first one works faster. UPD. Note that way with find might be not optimal from space consumption point of view, ...
Remove many many many files from a folder
1,283,455,842,000
java -cp FILE.jar FILE.Main inputfile What does the -cp option mean? For that matter, what a negative sign in front mean? I've searched everywhere and couldn't find the answer.
The example you finally gave, -cp is a parameter to the command, which is java. Parameters are generally program-specific, in this case cp stands for Class Path, which is another location java will search to find the class files as they are needed by the program.
The -cp option to the java command [closed]
1,393,281,409,000
I was trying out tar command to make archive with .tar extension. please have a look at the following series of commands I tried: $ ls abc.jpg hello.jpg xjf.jpg $ tar -cfv test.tar *.jpg tar: test.tar: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors $ ls abc.jpg hello....
As @jcbermu said, for most programs and in most cases, the order of command line flags is not important. However, some flags expect a value. Specifically, tar's -f flag is: -f, --file ARCHIVE use archive file or device ARCHIVE So, tar expects -f to have a value and that value will be the name of the tarfile...
Why does the specific sequence of options matter for tar command?
1,393,281,409,000
I have seen that people use ls -alh in the Linux terminal. However, when I see the manual, I don't see -alh (i.e. when I type man ls). Why do I not have it in the manual? Can someone explain what it does?
ls -alh is the same as ls -a -l -h. Multiple short options can be combined like this. Here are the meanings of those options from man ls: -a, --all do not ignore entries starting with . -l use a long listing format -h, --human-readable with -l, print sizes in human readable format (e.g., 1K 234M 2G)
What does ls -alh mean? [duplicate]
1,393,281,409,000
I'm having a problem where grep gets confused when the directory contains a file starting with dashes. For example, I have a file named "------.js" . When I do something like grep somestring * I get the error: grep: unrecognized option '------.js' Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep --help' for more in...
As an addition to Romeo's answer, note that grep pattern --whatever is required by POSIX to look for pattern in the --whatever file. That's because no options should be recognised after non-option arguments (here pattern). GNU grep in that instance is not POSIX compliant. It can be made compliant by passing the POSIX...
grep getting confused by filenames with dashes
1,393,281,409,000
man su says: You can use the -- argument to separate su options from the arguments supplied to the shell. man bash says: -- A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments. An argument of - is eq...
What is happening is that the first argument you supply to the shell is the $0 parameter, (usually this would be the name of the shell). It is not included when you do echo $* since $* is every argument apart from $0. Example: # su - graeme -c 'echo "\$0 - $0"; echo "\$* - $*"' -- sh 1 2 3 $0 - sh $* - 1 2 3 Update D...
Passing arguments to su-provided shell
1,393,281,409,000
I often find myself writing shell functions or shell scripts that are meant to be wrappers around other commands. It is also frequent that I want such a wrapper to support a few flags/options. The idea is that the wrapper should cull from the command-line arguments all the flags/options it supports (along with their ...
A common method for tasks like this is to use -- as a separator between options to be handled by the wrapper script and options to be passed on verbatim to the program being executed by the wrapper, e.g. ./my-wrapper -a -b -c -- -d -e -f -- marks the end of options for my-wrapper. All other arguments, and all option...
Looking for a more permissive alternative to GNU getopt for wrapper script
1,393,281,409,000
When I type in the command nmap –Pn –sT -sV –p0-65535 192.168.1.100, my terminal responds: Starting Nmap 7.60 ( https://nmap.org ) at 2018-01-29 11:24 PST Failed to resolve "–Pn". Failed to resolve "–sT". Failed to resolve "–p0-65535". Nmap scan report for 192.168.1.100 Host is up (0.0075s latency). Not shown: 999 clo...
nmap did not recognize those options because they start with a unicode EN DASH (342 200 223, –) instead of a hyphen or regular dash (-). As a result, nmap interprets those "options" as names to resolve.
Nmap unable to resolve flags
1,393,281,409,000
In Firefox we have two options at Firefox->Preferences->Preferences->Fonts and colors->Colors menu, Use system colors and Sites can use other colors. I would like keep the first one checked (and this is ok) and change the second on a quick way. A quick way could be pressing a shortcut on keyboard, running a terminal c...
I had found a solution... I asked on mozilla forum and they returned a answer to me. The solution is: Install a extension called PrefBar. With this extension we can put a checkbox on mozilla that will change the property browser.display.use_document_colors. We can set a shorcut too (for example, F1). With this extensi...
How to change a firefox option on a quick way (via shortcuts, command line,..)?
1,393,281,409,000
GNU tar offers the option --checkpoint where a message should be printed each checkpointreached. Question:: In what does --checkpoint measure? My best guess is Bytes. I wasn't able to find a hint in the man nor the info nor in GNU's documentation on tar. The OS is Linux, I use Bash and I use tar (GNU tar) 1.26
From info tar: The checkpoint facility is enabled using the following option: --checkpoint[=N]: Schedule checkpoints before writing or reading each Nth record. The default value for N is 10. So the default value for N is 10 records. But what is a record anyway? In truth, the meaning of record above is not easily dis...
in which units does tar --checkpoint measure?
1,393,281,409,000
I read many tutorials about the use of kill command, mostly 3 approaches kill -15 <pid> kill -SIGTERM <pid> kill -TERM <pid> For scripts purposes and for portability with macos too, the code numbers are not going to be used. Because kill -l in macos is different than Linux. So here enter in play the signal names. Que...
The most portable variant is kill -s TERM -- … That’s the form specified in POSIX with no extensions: -s followed by the signal’s name, as defined in signal.h, with no SIG prefix, or 0 for the “null” signal (used to check for the existence of a process with a given identifier). SIGTERM is the default signal, so sendi...
What is correct or suggested approach to send the signal name through 'kill' command?
1,393,281,409,000
I'm preparing for the LPIC-1, exam 102, and was wondering what is the difference between these two commands with respect to options -G and -aG: usermod -G projectA, projectB jsmith usermod -aG projectA, projectB jsmith The user jsmith has its own default group, which is not listed above among the groups/projects. As...
usermod -G sets the user’s supplementary groups to only the groups specified; so after running usermod -G projectA,projectB jsmith the jsmith user will belong to projectA, projectB, and its “primary” group. usermod -aG adds the specified groups to the user’s supplementary groups; so after running usermod -aG projectA...
Difference between "usermod -aG" and "usermod -G" options
1,393,281,409,000
Is it possible to change this value in runtime without rebooting? I don't always have this problem, when I suspend right now I'm getting a failure and Suspending console(s) (use no_console_suspend to debug) I would like to debug now, without having to reboot and recreate the problem.
Yes: echo N | sudo tee /sys/module/printk/parameters/console_suspend
Can no_console_suspend be set in runtime?
1,393,281,409,000
With curl is possible do curl http://somedomain.com/originalfilename.tar.gz -o newfilename.tar.gz curl http://somedomain.com/originalfilename.tar.gz -o /other/path/newfilename.tar.gz Therefore with -o is possible rename the filename to download and even define other path directort to download Now if I want keep the s...
You may specify the path to a directory where the document(s) you are fetching should be written using the --output-dir option. That is, curl -O --output-dir /some/path "$URL" From the curl manual: --output-dir <dir> This option specifies the directory in which files should be stored, when --remote-nam...
curl: download file with the same name with "-O" but defining a specific path directory
1,393,281,409,000
I am looking for an explanation how grep --label=LABEL works: Maybe somebody can give me an example [or two] on what --label= is for. I understand what grep and zgrep are supposed to do – the latter is mentioned in the entry on --label= in the info page: ... especially useful when implementing tools like `zgrep' 98...
This feature makes reading the output of grep easier. If you want to check data that grep cannot read directly then you may end up using a pipe to feed grep instead of creating a temporary file which grep can read. If you don't want a temporary file (e.g. because it would be huge) then without --label you would have t...
Understanding grep --label=
1,393,281,409,000
From man tar: -f, --file ARCHIVE use archive file or device ARCHIVE Please consider: tar -zxvf myFile.tar.gz As far as I understand, z means "gzipped tarball", x means "extract", v means "verbose output" but about f I am not sure. If we already give the file name myFile.tar.gz, why is the f argument needed?
It's the option you use to specify the actual pathname of the archive you would want to work with, either for extracting from or for creating or appending to, etc. If you don't use -f archivename, different implementations of tar will behave differently (some may try to use a default device under /dev, the standard in...
What is the rationale for using -f in tar [duplicate]
1,393,281,409,000
I know the -v switch can be used to awk on the command line to set the value for a variable. Is there any way to set values for awk associative array elements on the command line? Something like: awk -v myarray[index]=value -v myarray["index two"]="value two" 'BEGIN {...}'
No. It is not possible to assign non-scalar variables like this on the command line. But it is not too hard to make it. If you can accept a fixed array name: awk -F= ' FNR==NR { a[$1]=$2; next} { print a[$1] } ' <(echo $'index=value\nindex two=value two') <(echo index two) If you have a file containing the awk s...
Set awk array on command line?
1,393,281,409,000
I'm using getopts for all of my scripts that require advanced option parsing, and It's worked great with dash. I'm familiar with the standard basic getopts usage, consisting of [-x] and [-x OPTION]. Is it possible to parse options like this? dash_script.sh FILE -x -z -o OPTION ## Or the inverse? dash_script.sh -...
Script arguments usually come after options. Take a look at any other commands such as cp or ls and you will see that this is the case. So, to handle: dash_script.sh -x -z -o OPTION FILE you can use getopts as shown below: while getopts xzo: option do case "$option" in x) echo "x";; z) echo "z";; ...
Getopts option processing, Is it possible to add a non hyphenated [FILE]?