date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,431,168,210,000 |
We're busy setting up smartmontools on our various Linux based servers and although it works, we want to streamline the process a bit. As I understand, we can enable automatic testing which should perform a test each 4 hours, but it does not indicate exactly what test is completed?
Is this test the same as running a s... |
The short answer is no, these are not equivalent. Automatic testing is just data collection; the short test is an actual test.
This is discussed (at length) in the smartctl manpage, in the section describing the --offlineauto settings:
The second category of testing is called "offline" testing. This type of test ca... | smartmontools - Is the automatic test the same as running a short test? |
1,431,168,210,000 |
How much time can I expect this disk (1 TB) to function? I have already made a backup of my important data. But I will be unable to buy a new HDD until February. Is there any way I can extend its life? Perhaps by formatting the disk or something else?
|
There is no precise time, it could be a minute from now or a month from now. But if it's bound to happen it will and you can't really prolong the disk's life, so make sure you backed up all and stop relying on it.
| Disk is likely to fail soon [closed] |
1,431,168,210,000 |
I'm confused about this smartctl output. It says SMART status is not supported, but then it says it PASSED.
# sudo smartctl -H -d megaraid,24 /dev/sdb
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1160.59.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== ... |
With a hardware RAID controller like that, smartctl is querying the RAID controller, and the controller firmware is making the actual SMART queries to the physical disks.
The message:
SMART Status not supported: ATA return descriptor not supported by controller firmware
SMART overall-health self-assessment test result... | Does my disk support SMART? |
1,431,168,210,000 |
Do smartd need the database?
or
smartctl needs the database?
I saw smart tool github keep updating database:
https://github.com/smartmontools/smartmontools/labels/drivedb
In my understanding, smartd will scan all disks then why does it need a database? what's the function/purpose to use a database in smartd/smartctl?
|
The smartmontools drive database can be seen here. Its purpose is to provide additional command-line flags to both smartctl and smartd for drives where the default settings (which are themselves defined in the database) aren’t sufficient, and/or to provide warnings about the drive.
Many drives have specific counters, ... | Why smartd need database? |
1,431,168,210,000 |
On my debian wheezy server I use a software raid 1 with two harddisks dev/sda3 and dev/sdb3 connected into dev/md2:
mdadm --detail /dev/md2
Number Major Minor RaidDevice State
0 8 3 0 active sync /dev/sda3
1 8 19 1 active sync /dev/sdb3
The raid seems t... |
If S.M.A.R.T. cannot be enabled, not even in rescue mode, this means that the harddisk isn't working correct anymore and should be replaced.
| Cannot get smartctl working |
1,533,152,431,000 |
When I install sshpass on alpine linux it will install and the doc will show up if you run it without arguments, but using any argument (valid or invalid) returns sshpass: Failed to run command: No such file or directory.
It's pathed and even when using an absolute path it has the same behavior. I want to use this wit... |
SSHpass was working fine, but the alpine container python:3.6-alpine doesn't have openssh installed.
This errormessage is confusing as it doesn't mention that the ssh component is failing.
This can be fixed by running apk add --update openssh.
This was resolved by changing the line in the Dockerfile from RUN apk add -... | sshpass not functioning in alpine linux |
1,533,152,431,000 |
I configured key pairs for SSH connection.
It works but of course asks for the passphrase.
ssh [email protected]
So now I try to login with sshpass which I have installed. I tried with -p property but also and with -f property and nothing works - it just hangs.
verbose gives these info on the client side
sshpass -v -... |
ssh prompts for and reads password (or passphrase) using the terminal (/dev/tty), not its stdin. This way you can pipe/redirect data to/from ssh and still be able to provide a password when asked. But to provide a password not via the terminal, one needs to present a "fake" terminal to ssh. This is what sshpass does.
... | "ssh" works but "sshpass" doesn't - how is this possible? |
1,533,152,431,000 |
According to this RedHat SSH password automation guide I'm following the Example 4: GPG one, and following the steps in that guide I create my pass_file using my own passphrase. Then, I got this:
gpg -d -q myappserver23.sshpasswd.gpg > pass_file && sshpass -fpass_file ssh [email protected]
Note the lack of a space be... |
@KamilMaciorowski comment lend me into the right direction. According to this useful answer at ServerFault, Windows is taking its own OpenSSH implementation. To solve this, openssh has to be installed in Cygwin in order to use this one instead.
This solves the errors and now I can do this:
$ gpg -d -q myappserver23.ss... | Using sshpass in Cygwin, ssh stills prompts for password |
1,533,152,431,000 |
I am using an application that uses /usr/bin/ssh and requires passwordless authentication. Meanwhile I want to use this with a server that requires both publickey and password authentication at the same time. Just using sshpass is a good solution in most circumstances (given that my secret password is safe and that I ... |
Given that the application that I'm using is a CLI program that searches for ssh in $PATH, it is possible to modify PATH to include a special ssh command that is actually a sshpass wrapper.
Wrap sshpass into a executable called ssh:
/path/to/bin/ssh:
#!/usr/bin/env bash
sshpass -f /path/to/passwordfile ssh "$@"
Then ... | sshpass through regular ssh client |
1,533,152,431,000 |
I have a bash script that will execute a script of my choosing against a server over ssh. My problem is that I also want to use an input file with common variables so I don't have to change them in each script. So far my attempts at getting it to source the two files have resulted in it trying to find one of them on ... |
It's a bit difficult to understand what you're really trying to do.
If you want to concatenate the content of $sourcelist and $tools/$2 and execute it in Bash, you can use cat with those two files and pipe to ssh like this:
cat "$sourcelist" "$tools/$2" | sshpass -e ssh $usrconn@$ipconn
| How can I pass two files through ssh? |
1,533,152,431,000 |
I'm trying to use sshpass to login automatically, however, it seems to have problem with /dev/tty
echo password | ./sshpass ssh root@xxxx
...
debug1: read_passphrase: can't open /dev/tty: No such device or address
...
Permission denied (publickey,gssapi-with-mic,password).
Any ideas? I can login directly without sshp... |
sshpass is used different way:
./sshpass -p password ssh root@xxxx
as explained in the manual page synopsis:
sshpass [-ffilename|-dnum|-ppassword|-e] [options] command arguments
| sshpass no longer works? |
1,533,152,431,000 |
I have setup a simple script like the below:
sshpass -p $password ssh -T $username@$ip_address -p 30007 <<- EOF > $save_file.pcap
sh
tcpdump -i eth5.1 -s 0 -n -v -U -w -
EOF
sed -i '1d' $save_file.pcap
The purpose of this script is so that I can run a tcpdump on a remote device, yet save the output into a fi... |
I suggest some improvements for your remote capturing traffic script:
preventing CTRC+C from killing your script:
This can be done using a trap to capture SIGINT. You usually place it at the beginning of your script. See this example:
trap "pkill ssh" INT
Obviously, the filter to get the only the ssh you want can be... | Stop CTRL+C Exiting Local Script Which is Running tcpdump in Remote Machine |
1,533,152,431,000 |
These are standard sshpass commands to read password from file or as argument.
user@linux:~$ sshpass -f pwd.txt ssh admin@server
admin@server:~$
user@linux:~$ sshpass -p P@55 ssh admin@server
admin@server:~$
Is it possible to write the same program/script in shell if expect not available?
Public/private key is not t... |
You can script(1) as a mini-expect, provided that you can cope with adjusting arbitrary timeouts, which is of course quite kludgy:
{ sleep 1; echo PASSWD; } | script -q /dev/null -c 'ssh user@host CMD'
or with the syntax of BSD's script(1):
{ sleep 1; echo PASSWD; } | script -q /dev/null ssh user@host CMD
The sleep ... | sshpass alternative in linux shell/bash code |
1,533,152,431,000 |
I'm using rsync to copy a file to a device:
sshpass -p <password> rsync -avzP <file> <user>@<IP address>:<folder>
This has worked fine in the past but I was trying to copy to a new device and got:
Host key verification failed.
rsync error: unexplained error (code 255) at rsync.c(703) [sender=3.2.3]
I removed sshpass... |
If StrictHostKeyChecking is set to accept-new or no, new hosts are automatically added to the ~/.ssh/known_hosts file. The default is to ask.
If a host key changes, you will get a warning message that begins like this
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION ... | Using sshpass with rsync to accept a fingerprint |
1,533,152,431,000 |
I need to perform an operation on a list of server, through SSH.
I am using sshpass, and that operation might fail, however it's supposed to happen a few time, and the script should still continue.
#!/bin/bash
while read address; do
echo -n "$address "
sshpass -p password ssh -o StrictHostKeyChecking=no user@... |
ssh will inherit the standard input stream from the loop and read as much as possible from it, meaning it will read read the remaining lines from your address-list file. Since ssh is reading the remaining lines from the file, the loop will only ever do a single iteration. Technically, the script does not terminate p... | Bash script exit on command failure (sshpass) |
1,533,152,431,000 |
The following is a part of my script where I want to echo some text to the local terminal if the condition fails in ssh.
/usr/bin/sshpass -p $PASSWORD /usr/bin/ssh -t -o "StrictHostKeyChecking no" root@$IP -p $PORT '
cd $PATH;
[ ! -d temp ] && mkdir temp;
for new_file in '${NEW_FILE[@]}'
do
[ ... |
To selectively display an individual command as well as its output, you can use something like
sh -vc 'echo \"Some text\"'
although the nested quoting can start getting on your nerves pretty quickly.
| SSH remote - display echo on local terminal |
1,533,152,431,000 |
BACKGROUND:
I am developing a Kickstart file to install Rocky (8.5), and I have included EPEL as a repo in order to install Ansible. Yesterday, when trying to install from my Kickstart file, I received a message that "nothing provides sshpass needed by ansible-2.9.27-1.el8.noarch"
A quick search yielded this page: ht... |
Old versions of EPEL are still available so you can try to use the 8.5 archived version:
https://dl.fedoraproject.org/pub/archive/epel/8.5.2022-05-10/Everything/x86_64/
| Rocky 8.5 - Alternate repo for sshpass, removed from EPEL |
1,533,152,431,000 |
I am using sshpass command like this:
sshpass -p 'my_password' ssh user@server
The full syntax, according to the man page is
sshpass [-ffilename|-dnum|-ppassword|-e] [options] command arguments
At the moment, zsh does not have any completion rules for sshpass. How can I create simple completion rules, so that as soo... |
You can take inspiration from commands with similar syntax, such as sudo which also takes options followed by a command name and its options. See also Dynamic zsh autocomplete for custom commands for an introduction on writing zsh completions.
Put the following code in a file called _sshpass on your $fpath. (See How t... | zsh completion for sshpass |
1,533,152,431,000 |
sshpass -p '1234567*' ssh -L 1080:192.168.0.1:2222 [email protected] -p 4422 -f -C -N
The above code works on macOS (creating a 1080 tunnel to 192.168.0.1:2222 via gateway.com:4422 with username admin and password 1234567*).\
It doesn't work on Linux - the process seems to run and terminate immediately.
|
The problem with sshpass + ssh is that ssh first authenticates the user, forks a child to handle the connection and then exits. But sshpass will pull the rug from under the child as soon as the parent ssh has exited, before the child had any chance to detach itself from the terminal (the pseudo-tty created by sshpass)... | How to keep sshpass process in the background? |
1,533,152,431,000 |
I am trying to run below script on remote machine, I am facing two issues here
The while loop defined in here doc is running endless
read enter key does not work on remote host
Without the sshpass command script is working fine on local host.
Can someone look into this and help.
1 #!/bin/bash
2 #read -p ... |
When you're using here-document, the text is written to the Standard Input (STDIN) of the process, in this case - to the STDIN of your ssh process. Since you're redirecting the here-document to the STDIN of your ssh, it cannot read your keyboard.
Instead of providing those commands in the STDIN of your ssh, assign it ... | Running a while loop on remote server using heredoc |
1,533,152,431,000 |
I would like to connect to a server using ssh and after logging in I would like to automatically execute
screen -R
My script looks as follows:
sshpass -p password ssh -t [email protected] 'screen -R; bash -l'
It is important that I would like to be able to control from the outside which commands are executed after l... |
ssh -tt user@server 'screen -ls 2>/dev/null | grep -i detached && screen -r || echo "No screen detached sessions found"'
This would work provided you have one screen detached.
| Login to ssh session and afterwards automatically look for and access existing screen session? |
1,533,152,431,000 |
I have a simple for loop one liner I use to check for things across a number of servers that have the same password set. I want to develop this one liner into a script that logs into a cluster of servers via IP address, prompts for a password and performs a command. Such as restarting a service. This is what I use:
... |
for i in {1..253}
do
ip=192.168.1.${i}
echo "Enter password for: $ip"
read pswd
case "$pswd" in
*) password=$pswd;;
esac
sshpass -p "$password" ssh -o StrictHostKeyChecking=no username@$ip 'hostname
echo "Checking if foo.log exists: `ls -lh /var/log/foo.log | wc -l`"
echo "Chec... | Bash For Loop - prompt for IP range and password |
1,533,152,431,000 |
I have created a shell script to connect to a list of servers using sshpass and run a list of about 30 commands. An extract of the script is below.
The script will wget a new config file, but then I am stuck trying to replace a variable in the config file with the server hostname.
I've had no luck getting the remote ... |
You need to escape the $ before the $HOSTNAME variable (or $(hostname) command), so that it is expanded/run on the remote machine rather than the local machine:
#!/bin/bash
while read PASSWORD SERVER;do
sshpass -p "$PASSWORD" ssh -t -p 1234 $SERVER << EOF
wget -N https://example.com/file.conf 2>&1 | grep -i "fai... | Output remote hostname in sshpass session |
1,533,152,431,000 |
In my script I need to access a remote server using ssh. On the remote I want to gather some data from log files. I have my script set up and the code works, but my problem is when I run the script it will get to the ssh and log onto the remote server, but it wont run the next command. It waits for a keyboard input bu... |
Issue was the pipe between the ADDR | tail
//old code
value = `sshpass -p $PASSWORD ssh $USERNAME@$REMOTE_IP_ADDR | tail -F /tmp/file.txt | awk '{ print $16 }'`
//edited code (working)
value = `sshpass -p $PASSWORD ssh $USERNAME@$REMOTE_IP_ADDR tail -F /tmp/file.txt | awk '{ print $16 }'
Thanks for the help ct... | run command in script after an ssh |
1,533,152,431,000 |
Try as I might, I am unable to execute the lpstat and lp commands of CUPS remotely using sshpass in my script. I am able to execute all of the lines involving these commands when using an interactive terminal on the server running CUPS. Any help would be greatly appreciated.
Input:
./cups_print_job.sh printer ./file.... |
Thanks to @UlrichSchwarz for pointing me in the right direction. After learning that without quotes around the initiating EOF the heredoc body is processed locally, I added the quotes and the script runs as expected.
The correction:
sshpass -p $password ssh -o StrictHostKeyChecking=no $server /bin/bash << "EOF"
| Executables specified with absolute path not found when using sshpass |
1,451,679,960,000 |
When using ss with -p option, user/pid/fd column jumps underneath the particular line. For instance this is it what I'm actually seeing:
# ss -nulp4
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 ... |
As for why etc.
ss, part of the iproute2 utility collection in the Linux kernel, uses an ioctl() request to get the current width of terminal.
However; the entire width is used for the «other» fields and the process field get squeezed onto next line.
You can view this by for example (when having a limited with on term... | ss - linux socket statistics utility output format |
1,451,679,960,000 |
I want to observe a socket status periodically, so I need to check the socket status by command.
Currently I list all listening sockets by ss and filter them by grep.
ss -l | grep -q /run/php/php7.0-fpm.sock
Is there better way to check socket's status?
|
You can get some information by trying to connect, pass nothing and accept nothing before disconnecting.
socat -u OPEN:/dev/null UNIX-CONNECT:/run/php/php7.0-fpm.sock
There are at least four possible outcomes:
If the socket does not exist then the error will be No such file or directory and the exit status will be 1... | How to check whether a socket is listening or not? |
1,451,679,960,000 |
I would want to know the meaning of some items in the ss command output. Eg:
# sudo ss -iepn '( dport = :3443 )'
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 0 192.168.43.39:45486 190.0.2.... |
Meaning of some of these fields can be deduced from source code of
ss and
Linux kernel. Information you see is printed by tcp_show_info()
function in iproute2/misc/ss.c.
advmss:
In ss.c:
s.advmss = info->tcpi_advmss;
(...)
if (s->advmss)
out(" advmss:%d", s->advmss);
In linux/include/linux/tcp.h:
u16... | Detailed output of ss command |
1,451,679,960,000 |
Hi I feel like this is an obvious question but I haven't been able to get a good answer so far. Given the name of the service (which I know running on localhost) is there any networking command line tool like (netstat/ss) which will tell me what port that service is running at? Ideally something like:
$ some-program -... |
There are two standard library calls; getservbyname(3) and getservbyport(3). These allow programs to convert a name (e.g. telnet) to a port (23), or from a port back to a name.
The typical implementation uses /etc/services as the authoritative source, but this can be changed by the services entry in nsswitch.conf.
Th... | Given a service name, get its port number? |
1,451,679,960,000 |
From that article, I realized that:
a UNIX domain socket is bound to a file path.
So, I need to sniff DGRAM Unix socket through the socat as mentioned here. But when I try to retrieve the path for this purpose, I find that the target application uses a socket without file path.
The ss -apex command shows results bot... |
Question #1
Q1: From the ss man page I can't find out, what does it mean e.g. * 8567674 without file path.
From the docs it explains the Address:Port column like so:
excerpt
The format and semantics of ADDRESS_PATTERN depends on address family.
inet - ADDRESS_PATTERN consists of IP prefix, optionally followed by c... | How can I sniff unix dgram socket without having file path? |
1,451,679,960,000 |
I run this command
ss -tulpnoea|grep -i water|grep -v 127
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
... |
You have your redirection at the wrong point in the pipeline. Presumably the error comes from the ss command, so that is where you should hide the error output. Or you can group the output and redirect from the command as a whole.
Here are some possible solutions to suppress any errors:
Redirect the standard error of ... | How can I remove this annoying message: "Failed to find cgroup2 mount"? |
1,451,679,960,000 |
I read some tutorials,they say that netstat is deprecated. I tried ss command. THis is the output
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
icmp6 UNCONN 0 0... |
224.0.0.251 is Multicast DNS, and it use the port 5353 (as you noticed). Many operating systems use it to discover new devices/printers/routers with zero or nearly zero configuration. E.g. if you want to send a page to be print to your printer, with e.g. the address my-printer.local, your operating system uses such po... | What does address 224.0.0.251:5353 represent? |
1,451,679,960,000 |
I have a debian VM, here the info:
las@Client:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
When I type ss -nte I expect to see the uid of the process that uses the socket because of the -e option, but it doesn't appear and I can't figure... |
The ss command (any version) will display an uid only if it's not zero. Here's the source for the Debian 8 jessie version:
if (show_details) {
if (s.uid)
printf(" uid:%u", (unsigned)s.uid);
printf(" ino:%u", s.ino);
printf(" sk:%llx", s.sk);
if (opt[0])
print... | Why ss -e doesn't show uid? |
1,451,679,960,000 |
The ss command (from the iproute2 set of tools which comes as a newer alternative to netstat) has in its --help the following options
-0, --packet display PACKET sockets
-t, --tcp display only TCP sockets
-S, --sctp display only SCTP sockets
-u, --udp display only UDP so... |
A raw socket is a network socket (AF_INET or AF_INET6 usually). It can be used to create raw IP packages which can be used for troubleshooting or to implement your own TCP implementation without using SOCK_STREAM:
Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends th... | ss command: difference between raw and unix sockets |
1,451,679,960,000 |
I am struggling with Node.js app deployment because of some CORS and port issues.
ss-t output
ESTAB 0 0 [::1]:33366 [::1]:3031
ESTAB 0 ... |
Each TCP communication is identified, at each end, by these four values:
origin IP - origin port - destination IP - destination port
In your case, you have a connection from the host to itself, so you get to see the two endpoints, with their origin and destination ports swapped in the second one.
You can find more in... | How to decipher ss -t command output? |
1,451,679,960,000 |
I want to know which user launched the process that is using a TCP socket.
I tried with ss -nte, but it only shows the uid, not the user's name. Is there a way to make ss show the user's name?
Here the output of ss -nte
lucio@debian:~$ ss -nte
State Recv-Q Send-Q Local Addr... |
Hacky attempt to bring in perl to help. See how it replaces the uid:1001 with user:bob.
# ss -ntel
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 10 0.0.0.0:12345 0.0.... | How to make ss show the user who is using the socket? |
1,451,679,960,000 |
I install atop on Debian 9. It runs as a monitoring daemon.
Why is it listening on a raw socket? Raw sockets are used to generate arbitrary IPv4 packets or capture all packets read all packets for a given IP sub-protocol! But I don't think my atop and its logs show any information from reading packets. I don't eve... |
The raw socket is opened only to read information like statistics from the netatop kernel module, using getsockopt() (eww). There is no code to read or write raw packets with this socket.
https://github.com/Atoptool/atop/blob/v2.3.0/netatopif.c
| Why does atop open a raw socket? |
1,451,679,960,000 |
Is it normal behavior, or a bug, that when I run ss -nltp, I only see the process/pid information if the user I am running ss -nltp as is the same user as the listening process?
$ docker run -it --rm tianon/network-toolbox
root@bc058746626a:/# apt update
...
root@bc058746626a:/# apt install gosu
...
root@bc058746626a:... |
For a normal user that's normal behavior. To be able to associate the socket to a process, at some point, /proc/<pid>/fd/ must be read by ss. Only the same user or a privileged process (including running as root) has access to this.
Here's an strace excerpt about what is happening outside of Docker.
# runuser -u test ... | iproute2 ss - not showing process/pid information if user is not the same user as listening process? |
1,451,679,960,000 |
My loacl server IP is 192.168.122.100, and remote server IP is 192.168.122.50. I need to kill all processes which connect to 192.168.122.50:56666. By executing ss comand, I found there are three TCP connections has been established. But I don't konw which process are using these sockets. How can I find out the PID of... |
Using lsof command. Usage:
sudo lsof -ni tcp | grep <port>
And the 2nd column is PID.
| How can I confirm which process is connect to remote port? |
1,451,679,960,000 |
I get the following line from ss -lun:
udp UNCONN 0 0 0.0.0.0%virbr0:67 0.0.0.0:* users:(("dnsmasq",pid=950,fd=3))
I wonder what 0.0.0.0%virbr0 means here. No trace of it in man, hard to find in search engines.
|
That would be for sockets that are bound to a particular interface in addition to that IPv4 wildcard address using the SO_BINDTODEVICE socket option. From socket(7):
SO_BINDTODEVICE
Bind this socket to a particular device like “eth0”, as
specified in the passed interface name. If the name is an
empty string or the o... | What is 0.0.0.0%virbr0? |
1,451,679,960,000 |
ss -o shows TCP timer in the following format:
timer:(<timer_name>,<expire_time>,<retrans>)
What do <expire_time> and <retrans> mean?
I found <expire_time> counts down to zero and then restart counting from some number again. Its starting value differs from TCP socket to TCP socket.
<retrans> seems always zero for al... |
expire_time is the time left until the timer expires. The TCP stack in the Linux kernel supports a number of timers, and they all have an expiration time.
retrans is the number of retransmissions which have occurred. TCP implementations retransmit packets they believe have been lost; they counts these retransmissions... | What do `<expire_time>` and `<retrans>` mean in the output of `ss -o`? |
1,451,679,960,000 |
often I take a look at listening sockets with ss -nlptu, this list often includes few/dozen socket bound on either an ipv4 or ipv6 loopback address. As we know there are a few valid ipv4 loopback addresses to bind to, so I would rather not use something like grep to exclude the most common ones if I can avoid it.
Is t... |
ss has a built-in filter language, alas it's almost undocumented in the man page. The last remnents of this documentation are in iproute2 version v4.13.0 and were removed with this commit:
doc: remove outdated ss documentation
The current version is
well documented on man page. The latex documentation is very old and... | iproute2 ss - exclude sockets bound to loopback addresses |
1,451,679,960,000 |
What does ss mean by *:ipproto-255, in the local address/port column?
$ sudo ss -ap | grep -vE "^(nl |u_)"
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
p_raw UNCONN 0 0 *:eth0 * users:(("lldpd",pid=742,fd=11))
raw UNCONN 0 0 *:icm... |
255 is the value of IPPROTO_RAW. It means this socket allows sending all types of IPv4 packets. (It cannot receive packets). The program has to provide a full IPv4 header.
For comparison, the raw socket with *:icmp allows sending and receiving IPv4 packets which use the ICMP protocol.
These details are specific to ... | ss shows a raw socket. What does it mean that it is listening on "*:ipproto-255"? |
1,451,679,960,000 |
I run a python code inside docker container performing the following calls
import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM);
s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1.bind(("0.0.0.0",9001));s1.listen(1);c,a=s1.accept();
I'm trying to get info using ss and see the open sockets, but can't... |
You have to switch to the correct network namespace first, because socket state is per namespace (namely per network namespace). For example by using nsenter. sudo has to be moved first, because nsenter also requires privileges. In one line (and using ss's own filtering features) this becomes:
sudo nsenter -t $(docker... | ss doesn't display socket info related to the process opening SOL_SOCKET |
1,451,679,960,000 |
when we perform the following cli on our rhel machine we get more then 600 CLOSE_WAIT lines
lsof -i tcp:8088 | grep CLOSE_WAIT
java 31100 yarn 385u IPv4 208022048 0t0 TCP master02.hgti.com:radan-http->master02.hgti.com:56504 (CLOSE_WAIT)
java 31100 yarn 407u IPv4 208210692 0t0 TCP master02.hgti.c... |
I think it might a bug in your application, maybe you can keep it under control if you restart the application before running out of the maximum number of open files / sockets, or increase any artificial limits set by ulimit.
Try looking for a bug report, for example:
https://issues.apache.org/jira/browse/YARN-9336
h... | rhel + any best practice to minimize the CLOSE_WAIT sessions from linux side |
1,451,679,960,000 |
ss --info returns information about tcp connections. It produces a line simliar to the following (some fields removed for formatting)
tcp ESTAB 0 0 192.168.1.177:60236 54.70.141.88:https
cubic wscale:7,7 rto:204 rtt:0.918/0.419 reordering:59
What exactly does the reordering number mean in this exa... |
From TCP Variables:
The tcp_reordering variable tells the kernel how much a TCP packet may
be reordered in a stream without assuming that the packet was lost
somewhere on the way.
tcp_reordering may be changed via net.ipv4.tcp_reordering variable of sysctl. By default this value is 3.
If you change net.ipv4.tcp_... | What does the reordering field of ss --info mean? |
1,451,679,960,000 |
When I use ss (socket statistics) to show the usages of port 5432 I get:
$ sudo ss -ln | grep -E 'State|5432'
Netid State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
u_str LISTEN 0 244 /var/run/postgresql/.s.PGSQL.5432 54481 * 0
tcp LISTEN 0 244 ... |
It turned out it was after all a problem on my machine. I had another instance of WSL running side to side that I forgot of and that one had a Postgres server running and listening to that port. I wrongly assumed they were running in isolation from each other while instead they are not. Uninstalling Postgres from that... | Why ss show a port is in use but lsof doesn't? |
1,451,679,960,000 |
I am running a Debian GNU/Linux 9.5 (stretch) with kernel: 4.9.0-7-amd64.
I have found the culprit of a memory consumption problem I am facing to be an in-app mechanism for sending logs to FluentD daemon, so I am trying to figure out the TCP memory usage.
According to the following outputs
/proc/net/sockstat:
sockets:... |
After a lot of searching around, I finally came to a conclusion.
My understanding of how to calculate TCP memory usage is correct.
For every socket add socket_memory = rmem_alloc + wmem_alloc + fwd_alloc + wmem_queued + opt_mem + back_log (the r,t, f, w, bl, o fields in skmem)
The reason that my total captured sockets... | Calculate TCP memory usage (does not add up) |
1,451,679,960,000 |
I want to see the state "syn_sent" of socket in realtime during the connection process
ss or netstat or any command
I have tried those commands, but all fail
watch netstat -tnaop|grep -i syn
ss -4 state syn
|
Solution found: this command works perfect
watch "ss -o state syn-sent '( dport = :https or sport = :https )'
this command also works fine
while true;do sleep 2s && netstat -napotep|grep SYN_SENT; done
| How to show the "syn_sent" socket state on Linux in realtime? |
1,451,679,960,000 |
With ss -tuiOp we can view extended stats for an outbound process, e.g.:
tcp ESTAB 0 0 192.168.68.108:32862 52.86.220.33:https
users:(("chrome",pid=13907,fd=44)) cubic wscale:12,7 rto:292 rtt:91.131/1.147 ato:40 mss:1288 pmtu:1500 ... |
The listening socket isn't the one transporting data! the moment a listening socket gets a connection request, the accept() system call can create a new connected socket. the listening socket doesn't transport any data, it just waits for connection requests. the listening socket and the data-transporting sockets are t... | View extended stats for listening ports (using ss?) |
1,451,679,960,000 |
On machine B, I remote access machine C
$ ssh -X t@C
$ echo $DISPLAY
localhost:10.0
How can I find/verify the mapping of $DISPLAY on C to $DISPLAY on B? Can it be done by the following command on C?
$ netstat -a | grep 6010
tcp 0 0 localhost:6010 0.0.0.0:* LISTEN
tcp6 ... |
"the mapping of $DISPLAY on C to $DISPLAY on B" what does that mean?
Clearly you grep out of something on C, so you only see sockets on C which involves "port num=6010". Other connection or listening socket on C are grep out.
You didn't see any connection before because there hasn't been any X client running and conn... | How can I find the mapping on `$DISPLAY` after `ssh -X`? |
1,451,679,960,000 |
In linux we can run ss -x or lsof -U +E and we can see what type unix socket has. But in macOS there is no ss or we can run lsof -U which only shows TYPE - unix, but I would like to know with some utility what exactly so_type a unix socket has.
|
MacOS appears to support the 'netstat' command. Netstat has long been deprecated for linux due to the interface it used. 'ss' is a syntactically similar command for linux.
| How can I find out what so_type an existing unix socket has in macOS? |
1,451,679,960,000 |
I know lsof and ss provide metadata about connections. Where do they get it from?
For example, this represents a connection:
ls -al /proc/102922/fd/98
lrwx------ 1 me me 64 dic 21 06:06 /proc/102922/fd/74 -> 'socket:[3803248]'
With ss I can see more info:
tcp ESTAB 0 0 192.168.68.108:33966 ... |
trick: such things can often be figured out with a run of strace -o logfile.txt programname; in your case, you'd find out that ss creates an AF_NETLINK socket, and sends and receives messages via that.
Netlink is an logical interface of the kernel designed to give access to internals of the networking stack.
Using ldd... | Where in the filesystem can I get metadata about a socket? |
1,451,679,960,000 |
with the following command I want to get which are the IP's that connected on my machine with port 8088
18.23.292.9 is machine that resource manager service is running on with port 8088
ss -tanp | grep 8088 | grep ESTAB
ESTAB 0 0 18.23.292.9:8088 118.2.291.2:52874 users:(("ja... |
I would do it the other way round.
I assume
you can connect to remote hosts,
and remote hosts is unix.
just run
ss -tanp | awk '$5 == "18.23.292.9:8088"'
on remote hosts.
assuming also that no NAT is set
| how to know what the process that connected to my machine VIA specific port |
1,451,679,960,000 |
When trying to see port clashes within my system, many websites online recommend using /etc/services or ss -tunl to see port info
I am noticing /etc/services is providing different information to -ss on most occasions.
Output comparison examples
sudo cat /etc/services
ftp 21/udp
ftp 21/s... |
The file /etc/services only provides number to name mapping for ports, and has nothing to do with what ports ss lists. Additionally, the names in this file are common uses for the ports, not what the port is actually used for on your system, as any program (with sufficent permissions) can open any port for any purpos... | Where does ss command gather its data for ports etc |
1,491,570,622,000 |
I need to allow to a user to run passwordless sudo without tty.
I have a file under /etc/sudoers.d/ with the special commands and settings I need, since I don't fancy editing directly the sudoers file. In that file I have the following:
# My list of commands that the user can run passwordless
myUser ALL=(ALL) NOPASSWD... |
The grammar for the Defaults is this (see man sudoers):
Default_Type ::= 'Defaults' |
'Defaults' '@' Host_List |
'Defaults' ':' User_List |
'Defaults' '!' Cmnd_List |
'Defaults' '>' Runas_List
User_List ::= User |
User ',' User_List
So... | sudoers and defaults |
1,491,570,622,000 |
Why it is recommended to edit /etc/sudoers file with the visudo command?
Here is a sample of the file:
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which ... |
Because visudo checks the syntax and make sure it is valid configuration file; otherwise you may edit the file, make an error and sudo won't be useable anymore just because of your syntax error.
| This file must be edited with the 'visudo' command.? [duplicate] |
1,491,570,622,000 |
I used sudoedit to create a file:
$ sudoedit /etc/systemd/system/apache2.service
but when I went to save the file, it wrote it in a temporary directory (/var/temp/blahblah). What is going on? Why is it not saving it to the system directory?
|
The point of sudoedit is to allow users to edit files they wouldn’t otherwise be allowed to, while running an unprivileged editor. To make this happen, sudoedit copies the file to be edited to a temporary location, makes it writable by the requesting user, and opens it in the configured editor. That’s why the editor s... | Why is sudoedit writing to a temporary directory? |
1,491,570,622,000 |
Why can't I edit files owned by root but being e.g. somewhere deep in my personal directory, it says:
sudoedit: existingFile: editing files in a writable directory is not permitted
While I have the following function defined:
function sunano {
export SUDO_EDITOR='/usr/local/bin/nano'
sudoedit "$@"
}
And I ... |
The manpage says
Files located in a directory that is writable by the invoking user may not be edited unless that user is root (version 1.8.16 and higher).
If you can write to the directory containing the file, then you can edit it in practice without needing sudoedit (although you may not be able to read its curren... | sudoedit root owned file in a non-root directory |
1,491,570,622,000 |
Is there a key difference between sudo -e and sudo vim. I have set up the sudoers file so that vim is my default editor. Is there a key difference between the two?
Plus, should I switch from vim to rvim? I tried it but I had some problems with my config file
|
The big difference is who is editing what file.
With sudo vim (assuming successful authentication), the root user invokes vim and edits the file in place (with root's environment and vim swap files parallel to the file being edited).
With sudo -e or sudoedit the user who invoked sudo edits a temporary copy of the file... | Difference between sudo -e and sudo vim? |
1,491,570,622,000 |
System: Linux Mint 18.1 64-bit Cinnamon.
Objective: To define Bash aliases to launch various CLI and GUI text editors while opening a file in root mode from gnome-terminal emulator.
Progress
For example, the following aliases seem to work as expected:
For CLI, in this example I used Nano (official website):
alias su... |
You shouldn’t run an editor as root unless absolutely necessary; you should use sudoedit or sudo -e or sudo --edit, or your desktop environment’s administrative features.
sudoedit
Once sudoedit is set up appropriately, you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit will check th... | How to properly edit system files (as root) in GUI (and CLI) in Gnu/Linux? |
1,491,570,622,000 |
I'm doing some scripting with Vim and I've just started using sudoedit.
Problem is, when I :w it writes to the temp file, so any testing of the script can't happen unless I quit the editor.
How can I force an update of the original, or am I missing the point of sudoedit?
|
sudoedit allows you to edit a file with an editor running on your own user id. It copies the file to a temporary file which your editor can then write into. As soon as the editor is closed, the edited file is copied back.
There is no built-in possibility to automatically write changes back while the editor is still ru... | Sudoedit Vim force write (update) without quit |
1,491,570,622,000 |
I've started using sudoedit <file> instead of sudo vim <file>. One of the advantages is that it uses my local ~/.vimrc. However, when using sudo crontab -e, it uses /root/.vimrc instead. Is there a way to make sudo crontab -e use my local ~/.vimrc?
Here is a related question, about using sudoedit with vimdiff. However... |
Assuming that you want to be editing root's crontab, sudo must give you root authority. After it does so, crontab will invoke ${VISUAL:-${EDITOR:-vi}} (it'll use $VISUAL unless it doesn't exist; in that case it'll use $EDITOR unless it doesn't exist; in that case it'll use vi).
You have a few possible solutions. The... | How can I make `sudo crontab -e` use my `sudoedit` environment? |
1,491,570,622,000 |
I have read this answer but don't know how to add the following line into my sudoers file.
matthew ALL=(ALL) NOPASSWD: /usr/sbin/service fancontrol start
I ran "sudo visudo", and a "/etc/sudoers.tmp" window popped up. Is "/etc/sudoers.tmp" the correct file into which the line should be added? If so, under which line ... |
visudo is a command provided for editing the sudoers file in a safe way. To quote its manual page:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
visudo locks the sudoers file against multiple simultaneous edits,
provides basic sanity checks, and checks for parse errors.
The /etc/sudoers.... | How can I add lines into my sudoers file? |
1,491,570,622,000 |
Is it a bad practice to run a command which requires sudo in ~/.profile?
If really want to do that, how can I make the command run at rebooting Ubuntu?
make the command running with sudo and under my user account not require password, by editing /etc/sudoers?
provide my password in the command with sudo in ~/.profil... |
If you put the command in your ~/.profile, it will run every time you launch a login shell. Some terminal emulators allow you to use a login shell for each terminal window. Do you want your command running that often?
If you want to be allowed to use sudo for that command without entering a password, use the visudo co... | How do you run a command with sudo in `~/.profile`? |
1,491,570,622,000 |
I am using Kubuntu 20.04.
When I run sudoedit /etc/fstab, VS Code opens to a blank document and the CLI immediately returns (see details below).
If I run export SUDO_EDITOR=nano, the document opens in the nano editor with the contents of /etc/fstab as expected.
If I run export SUDO_EDITOR=/snap/bin/code, it once again... |
You need to tell the editor to wait:
SUDO_EDITOR="/snap/bin/code --wait" sudoedit /etc/fstab
Without that option, VS Code forks, or notifies an already-running instance, and control immediately returns to sudoedit. The latter sees that nothing has changed and deletes the temporary copy that is used for editing purpos... | Using Visual Studio Code as EDITOR e.g. with sudoedit |
1,491,570,622,000 |
When I want to vimdiff root files, I use the following alias, as per this suggestion.
alias sudovimdiff='SUDO_EDITOR=vimdiff sudoedit'
I can then use the following command.
$ sudovimdiff /root/a /root/b
However, if one of the files is writable by my user, the command fails.
$ sudovimdiff /root/a /tmp/b
sudoedit: /tm... |
May be useful related to that sudoedit error message:
sudoedit: ... editing files in a writable directory is not
permitted
Please try a modification to sudoers file using sudo visudo, add a line:
Defaults !sudoedit_checkdir
More here.
| Can I sudoedit a file in a writable directory when using vimdiff? |
1,491,570,622,000 |
Is it possible to use gvim --remote-silent and similar as an editor for visudo and sudoedit? Actually, I don't think this is related to the --remote option. Even if I set Defaults editor = "/usr/bin/gvim", the tmpfile gvim loads is blank and editing it has no effect.
|
gvim returns almost immediately. When sudoedit notices that the editor has returned it will finish reporting no changes. To get sudoedit to work correctly you need to get it to wait until you are finished editing. I normally use -f switch to do this. I have not tried it but the manual seems to support the use of --rem... | visudo/sudoedit and gvim --remote-silent |
1,491,570,622,000 |
I'm currently running Mac OS Sierra. I don't know exactly how, but somehow I've altered some permissions and think it'd be a good idea to reset them, but I do not know how. Each time I execute sudo, I am met with this warning: sudo: /var/db/sudo/ts is group writable
The command executes fine, but it seems to be a good... |
The following command will remove write permission from group on file /var/db/sudo/ts
sudo chmod g-w /var/db/sudo/ts
| Accidentally set write permission on sudoers? |
1,491,570,622,000 |
I'm looking to modify a file from a script. I can sudoedit the file as the bob user by doing
sudoedit -u bob /foo/bar.conf
but don't have rights to do anything else as bob.
I came across http://shadow-file.blogspot.com.au/2009/01/how-to-sudoedit-non-interactively.html which might work, but seems complicated.
Is there... |
Based on the tips above about using ed (and this example), I came up with the following
ED="/bin/ed"
CONTENT_TO_APPEND="Yay, config!"
##### Set editor #####
OLD_EDITOR=$EDITOR
export EDITOR=$ED;
##### Append using ed #####
echo "a
$CONTENT_TO_APPEND
.
w
q" | sudoedit -u bob /foo/bar.conf
##### Clean up #####
export... | Using sudoedit in a script (non-interactively) |
1,491,570,622,000 |
What is the syntax for using NOPASSWD and sudoedit at the same time in /etc/sudoers? I tried this:
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
but I still get prompted for a password.
|
sudoers file
You should be able to do any of these.
Such as this:
john ALL=(ALL) NOPASSWD: sudoedit
or this:
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
Lastly you could do it like this too:
Cmnd_Alias SOMECMD = sudoedit /path/to/file
john ALL=(ALL) NOPASSWD: SOMECMD
Once you have one of these definitions in ... | sudoers - How to use NOPASSWD and sudoedit at the same time? |
1,491,570,622,000 |
I want to give access domain admins group to sudoers access.
I have come across with many commands but nun of works for me.
fname.lname ALL=(ALL) ALL
With this command i can give access to a particular user, But i want to give access to all the members of the domain admin group.
%DOMAINNAME\\domain\ admins ALL=(ALL... |
I have worked a lot on it,
And after so many tries and searching I got this working
Type the command below and press Enter to safely open the /etc/sudoers file for editing:
$ sudo visudo
On a new line, insert the text below:
%domain\ admins ALL=(ALL) ALL
Since I was having DOMAIN name as two words I have to use: do... | Add "domain admins" group in sudo users [duplicate] |
1,491,570,622,000 |
I'm Using Centos version:
[sysadmin@backup-srv ~]$ cat /etc/redhat-release
CentOS release 6.4 (Final)
I'm using this sudo version:
[sysadmin@backup-srv ~]$ sudo -V
Sudo version 1.8.6p3
Sudoers policy plugin version 1.8.6p3
Sudoers file grammar version 42
Sudoers I/O plugin version 1.8.6p3
I tried to setup notificat... |
The problem is not in your line 121, but in your next line, with your line mailfrom "[email protected]. You forgot the closing double apostrophe. The good version were:
mailfrom "[email protected]"
The ground, why it was as a syntax error in line 121, and not in 122, is because the syntax analyser of the sudo and you... | Sudo email notification setup error |
1,491,570,622,000 |
Here is my original /etc/sudoers.d/www file:
Cmnd_Alias WWWCMDS = /home/xxx/shop/update.sh
www-data ALL=(ALL) NOPASSWD: WWWCMDS
I simply want to add two additional commands so I RTFM and saw that you just have to comma-separate them.
Cmnd_Alias WWWCMDS = /home/xxx/shop/update.sh,geoipupdate,service memcached restart... |
I just needed to provide the full path for the two additional commands.
Cmnd_Alias WWWCMDS = /home/xxx/shop/update.sh,/usr/local/bin/geoipupdate,/usr/sbin/service memcached
www-data ALL=(ALL) NOPASSWD: WWWCMDS
and it worked fine.
| sudoers syntax error after adding a simple comma [duplicate] |
1,491,570,622,000 |
The goal is to let the www-data user execute sudo -u postgres -H osm2pgsql [some options here] without being asked for a password (as this will be part of a script wich runs automatically).
I thought I could do it with the following line in sudoers file
www-data ALL=NOPASSWD: /usr/bin/sudo -u postgres -H osm2pgsql *
... |
The syntax you need is
Defaults:www-data !requiretty
www-data ALL=(postgres) NOPASSWD: /usr/bin/osm2pgsql
where /usr/bin/osm2pgsql should be replaced by the actual path of osm2pgsql. The !requiretty line allows the sudo from a script without a terminal. This allows the command sudo -u postgres -H osm2pgsql with any ... | Enable user to execute one command as another user |
1,491,570,622,000 |
I am using IBM z/OS390 and I am using the OMVS shell.
I don't have "vi" installed at all so I use "oedit".
If I try to initialize the app.jar straigh from OMVS shell it Works perfectly. I mean, if I reach the java directory and start the app from there with the two commands below, it Works 100%.
cd /WebSphere/was85/my... |
The cd should not be required. The following line should do the same.
/WebSphere/was85/mycel/mynode/AppServer/java_1.7_64/bin/java -cp \
/usr/my.jar com/com.my_comapny_witt_entire_name/myMain
I broke the command line into two lines by using backslash continuation. There must be no characters between the back... | how to make a large command line broke in two lines be executed as a single line inside of a script |
1,491,570,622,000 |
I'm administrating an Arch Linux server.
How can I securely add emacs to my /etc/sudoers editor variable? Currently I have "emacs" but that allows M-x shell. Basically, I want something like rvim, but for emacs.
|
You probably can't do that.
Emacs is a Lisp Interpreter that runs an editor (which is written in emacs lisp),
so every time you use emacs, you have access to the the lisp interpreter itself.
That interpreter can do all kinds of things: create/remove files or directories, change access rights etc... Basically, once you... | How can I run emacs with no shell? |
1,491,570,622,000 |
I'm trying to get into the habit of editing root-owned files with sudoedit, instead of sudo vim. This has a few advantages, one of which is that it uses my user's ~/.vimrc.
Is there an equivalent, instead of using sudo vimdiff?
What I've tried
Instead of using vimdiff directly, one can open two files in vertical spli... |
To determine what editor to run, sudo checks three environment variables (in order): SUDO_EDITOR, VISUAL, and EDITOR, and uses the first editor it finds. (If it doesn't find one, it falls back to a default.)
So you can make it run vimdiff instead of vim as follows:
$ VISUAL=vimdiff sudoedit file1 file2
If your sudoe... | Is there a sudoedit equivalent for vimdiff? |
1,491,570,622,000 |
Here are my personal aliases for editing root owned files:
# CLI superuser nano; compiled; version 2.8.0
function sunano {
export SUDO_EDITOR='/usr/local/bin/nano'
sudoedit "$@"
}
# GUI superuser xed; packaged; version 1.2.2
function suxed {
export SUDO_EDITOR='/usr/bin/xed'
sudoedit "$@"
}
# GUI... |
The issue here is that sudoedit copies the file to a temporary file before opening it in the editor. When the file has an extension, the temporary file is created with the same extension, and filename-based syntax highlighting modes are selected appropriately (e.g. for C files). When the file doesn’t have an extension... | Nano through Sudoedit = No colors |
1,491,570,622,000 |
Alright, I know the question title sucks, but it's the same with the situation itself.
What I am trying to do is this:
Create a file with sudoers configuration locally
Use Ansible to ubload that file with the template module
Use the validate feature of the template module to make sure the configuration works
So far,... |
Your file is likely missing its end-of-file newline. sudo expects that, and visudo will fail to validate a file missing it. Opening a file in Vi and saving it will add a newline at the end if necessary, fixing the file from sudo’s perspective.
| Uploading sudoers.d file through ansible gives syntax error but opening and saving in vi fixes it |
1,491,570,622,000 |
I'm in Ubuntu 18.04LTS and I want to change the sudoers file to execute sudo shutdown -h now without the need of password (for my_username). The steps I take were:
With my user my_username open terminal:
sudo visudo
The line I added:
my_username ALL=(ALL) NOPASSWD: /sbin/shutdown
Where there is only one tab in the... |
in sudoers man page (man 5 sudoers) has been mentioned
When multiple entries match for a user, they are applied in order.
Where there are multiple matches, the last match is used (which is not
necessarily the most specific match).
So no matter if your config is specific.
Also consider if you have sudoers group (... | sudoers file change not working? [duplicate] |
1,491,570,622,000 |
RHEL 5.10
When I do visudo I get this error:
chuck 75->visudo
visudo: /etc/sudoers: Permission denied
visudo: /etc/sudoers: Permission denied
Listing of sudo exe file and /etc/sudoers:
chuck 76->ls -l /etc/sudo*
-r--r----- 1 root root 3540 May 9 11:44 /etc/sudoers
-r--r----- 1 root root 3401 Aug 12 2014 /etc/sudo... |
Per man visudo, section "Diagnostics":
/etc/sudoers.tmp: Permission denied
You didn’t run visudo as root.
I see nothing in your post to indicate that you did run it as root.
Try sudo visudo.
Also it looks like you may be getting errors related to sudo itself. Can you sudo ls ~root successfully?
You may al... | Now visudo won't work at all |
1,491,570,622,000 |
Using sudo visudo I add the line username ALL=(ALL) NOPASSWD: /home/user/script.sh in sudoers but the script.sh does not run on double click.
If I add the line username ALL=(ALL) NOPASSWD:ALL in sudoers then the script.sh runs and works when double clicked. How can do it?
Thanks.
|
Setting my comment as an answer. Add this line as the first executable statement in your script
[[ $UID -ne 0 ]] && exec sudo $0 "$@"
This checks to see if you're running as root and restarted the script under sudo with the same arguments. Normal precautions and warnings apply in configuring sudo and with running thi... | How to run a bash script by double clicking by entering the path in sudoers? |
1,491,570,622,000 |
My user (tom) is mapped to user_u user , user_r role and user_t domain via semanage
[tom@localhost ~]$ id -Z
user_u:user_r:user_t:s0
[tom@localhost ~]$
because I have made the "default" as "user_u"
[tom@localhos ~]$ sudo semanage login -l
Login Name SELinux User MLS/MCS Range Service
__def... |
Use sudo visudo and comment the offending line. Just make very sure that there is some way to get root privileges on this machine before you save the changes
| My user (tom) has user_u , user_r and user_t via semanage but it still can perform sudo |
1,491,570,622,000 |
I have visudo-edited /etc/sudoers this way:
User_Alias APACHE = www-data
Cmnd_Alias FIREWALL = /sbin/iptables, /sbin/ifconfig, /sbin/route
APACHE ALL = (ALL) NOPASSWD: FIREWALL
(To allow php running iptables cmd).
Is there a way to achieve the same, purely with terminal/tty/cmdline AND/OR root shell script ?
|
Sure. You can just drop files into /etc/sudoers.d instead of editing the sudoers file itself:
cat > /etc/sudoers.d/apache <<EOF
User_Alias APACHE = www-data
Cmnd_Alias FIREWALL = /sbin/iptables, /sbin/ifconfig, /sbin/route
APACHE ALL = (ALL) NOPASSWD: FIREWALL
EOF
chmod 440 /etc/sudoers.d/apache
And I guess if yo... | Sudo Apache, with command line ? (not visudo) |
1,470,620,934,000 |
After searching plenty through plenty a post, Youtube video, and "documentation" on the matter of systemd, I'm still at a loss.
The link (https://wiki.archlinux.org/index.php/systemd#Create_custom_target) seemed promising, but was a bit vague (to me).
Question
How would one go about creating a custom systemd target (I... |
Reading through man 5 systemd.unit and man 5 systemd.target tells us that unit files are used to define targets as well as everything else systemd. There is no documentation specifically on how to create a target, so it's hard to determine the how it should be done, but it is not too different from creating a service.... | How to create a systemd target? |
1,470,620,934,000 |
Is it possible to interactively skip the 90s timeout in systemd? For example, when it is waiting for a disk to become available or user to log out? I know it will fail eventually, so can I just make it fail now? I hate just staring at the screen helplessly.
|
It is not possible. Systemd is noninteractive.
In 2023, Fedora 38 shortened the default timeout duration to 45s.
| How do I skip the 90s timeout in systemd |
1,470,620,934,000 |
Using Fedora 24, I had configured in /etc/fstab an external usb drive:
UUID=6826692e-79f4-4423-8467-cef4d5e840c5 /backup/external ext4 defaults 0 0
When I unplugged the usb disk and reboot, it does not boot
That is the error message:
[ TIME ] Timed out waiting for device dev-disk-by\x2duuid-6826692e\x2d79f4\... |
Using the nofail mount option will ignore missing drives during boot. See man pages fstab(5) and mount(8).
nofail Do not report errors for this device if it does not exist.
So your fstab line should instead look like:
UUID=6826692e-79f4-4423-8467-cef4d5e840c5 /backup/external ext4 defaults,nofail 0 0
| Cannot boot because missing external disk |
1,470,620,934,000 |
I've followed the classic procedure to install Windows and Linux in dual boot. First I installed Windows in UEFI mode, then I use a bootable PopOS key to resize the main Windows partition; I created a Linux partition as well as a 500MB /boot/efi partition in the remaining space.
My problem is, systemd-boot can't seem ... |
Install rEFInd
After some further research, I've found this reddit thread from someone with an identical problem. Multiple posters in this and other threads recommended installing rEFInd instead.
rEFInd was straightforward to install and immediately detected my Windows partition.
I followed these Youtube tutorials, wh... | Pop OS: systemd-boot can't detect Windows |
1,470,620,934,000 |
Recently, after I've done something to my multiboot system, when I boot NixOS with systemd-boot, boot menu does not show up anymore even though the timeout is still set to 2 seconds in /loader/loader.conf (on the ESP):
# /loader/loader.conf on the ESP
timeout 2
default nixos-generation-380
Here is what I have in my /... |
After reading comment #6 on "systemd-boot, no timeout, no select menu - LoaderEntryDefault" and looking at "systemd-boot sets efivar LoaderEntryDefault, which overrides default in /boot/loader/loader.conf" nixpkgs issue on GitHub, I've figured out that the issue was probably caused by EFI variables which somehow got s... | systemd-boot skips boot menu and ignores settings in /loader/loader.conf |
1,470,620,934,000 |
I have a custom systemd service that runs during the first boot.
If the user has no bootsplash I would like to write to the console and give some info on what's going on. Is there a way to do that from my service?
Here's my systemd service:
[Unit]
Description=Prepare operator after installation
[email protected] [emai... |
In man systemd.directives, you can search for "output" and find that StandardOutput= is documented in in man systemd.exec. There you can find options including journal+console to send output to the systemd Journal and the system console. You might also try kmsg+console. According to the docs kmsg "connects standard o... | How do I write output to screen from systemd service during boot? |
1,470,620,934,000 |
I have installed Arch Linux for the first time, I have attempted to setup my UEFI boot process but must have failed somewhere, on bootup I do see the boot menu with the Arch Linux option but when I select it, I get a message /vmlinuz-linux:Not Found i.e. it can't find the kernel to boot. I've followed the instructions... |
Boot from your bootable USB Arch-linux , mount all your partitions and chroot into the system.
As montioned jasonwryan :
You need to mount your ESP to /boot
First create the efi folder:
mkdir /boot/efi
mount the esp partition
mount /dev/sda1 /boot/efi
Verify your /etc/fstab , the esp mount point need to be added t... | installed Arch Linux but cannot boot |
1,470,620,934,000 |
I'm running Arch Linux with systemd boot. In /boot/loader/entries/arch.conf I currently specify the luks crypto device with a line like this:
options rw cryptdevice=/dev/sda1:ABC root=/dev/mapper/ABC
I know I can also use UUID instead of /dev/sda1. In that case the kernel options line would look like this:
opt... |
If you're already using the new LUKS2 format, you can set a label:
For new LUKS2 containers:
# cryptsetup luksFormat --type=luks2 --label=foobar foobar.img
# blkid /dev/loop0
/dev/loop0: UUID="fda16145-822e-405c-9fe8-fe7e7f0ddb5e" LABEL="foobar" TYPE="crypto_LUKS"
For existing LUKS2 containers:
# cryptsetup config --... | How to specify cryptdevice by label using systemd boot? |
1,470,620,934,000 |
I'm running Debian Testing (Buster) and I'm swapping from Grub2 to systemd as I couldn't get Grub2 to work and someone suggested I try systemd-boot instead.
The boot/root drive is on an eMMC drive on the motherboard, whilst the data drive is on an mSATA SSD.
I have systemd-boot half working and it crashes on boot with... |
On giving this another look, it seems you have a mismatch between PARTUUID=... and UUID=... and that's what's causing this problem.
You mentioned bootloader is configured with:
options root=PARTUUID=2251a5a4-6c18-425c-9264-df971d297b09 rw
But when you manage to boot it, you actually find this UUID under /dev/disk/by... | systemd-boot cannot find my root |
1,470,620,934,000 |
I have Debian Stretch and I would like to have a custom grub entry in order to run the system without a graphical desktop. I thought that would be as easy as running a different runlevel, but reading about that, I was aware that, in systemd everything is different.
After reading this question about Red Hat and also th... |
After some days of researching, I have 3 approaches to the problem of creating custom entries for running a Systemd Debian without graphical desktop from the Grub. I think that the best approach is 1.
1. Creating a new /etc/grub.d/* configuration file
To do that, i copied /etc/grub.d/10_linux file as a template:
sudo ... | Create debian grub custom entry for running systemd multiuser.target |
1,470,620,934,000 |
Looking about, I see that the standard fix is to add this to the kernel boot parameters.
Using systemd-boot, my arch.conf looks like this :
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=PARTUUID="98b3b4f7-e7f9-6f49-be81-a2ee709c7a3e" rw
How do I add ... |
This is a kernel build option, so you cannot "add" it at runtime.
Either build your own kernel, or ask your maintainer to build the kernel with this option which they may or may not do because some kernel options depend on others and those dependencies might be very undesirable, e.g. they could slow down the kernel co... | IOTOP complains: CONFIG_TASK_DELAY_ACCT not enabled in kernel |
1,470,620,934,000 |
I installed Pop-OS in a dual-boot system.
Previously, my EFI partition was around 250mb. Pop Installer told me that it was too small. So instead of resizing and moving (due to possibility of data loss and Windows not booting), I deleted the old EFI partition and created a new EFI partition for install.
Output of efibo... |
From this answer on askUbuntu, I used TestDisk to recover the data in the deleted EFI partition.
I copied the Microsoft folder from /boot/efi/EFI in the deleted EFI partition and copied it to the same destination but in the new efi partition. And Voila! Windows Boot Manger showed up in the systemd-boot menu.
| Deleted the Windows EFI partition, What to do? |
1,470,620,934,000 |
Here's my service file:
[Unit]
Description=Blabla service
Requires=network-online.target nfs-common.service
After=network-online.target nfs-common.service
[Service]
Type=oneshot
ExecStart=/path/to/script
RemainAfterExit=no
[Install]
RequiredBy=php5-fpm.service apache2.service nginx.service
When enabling it looks pr... |
RequiredBy= does not imply that one service should start after another.
In man systemd.unit, the docs for RequiredBy= say:
The primary result is that the current unit will be started when the listed unit is started.
In other words, they could end up started in parallel. I think you want a Before= directive in you... | Systemd RequiredBy directive is ignored |
1,470,620,934,000 |
I'm not able to boot a freshly installed Arch Linux system with its root file system residing on a LVM thinly provisioned logical volume on a LUKS encrypted partition on a GUID partitioned device.
When Systemd's boot loader systemd-boot loads my boot entry Arch Linux it asks me for the passphrase of the LUKS encrypted... |
It looks like that the hook lvm2 run after the hook encrypt during Arch Linux's Initial RAM filesystem phase is not able to activate thinly provisioned logical volumes.
With the same storage configuration as depicted in my question except for normal logical volumes instead of thinly provisioned ones the volume group c... | How to install Arch Linux root file system on LVM thin LVs on LUKS on GUID partitioned device? |
1,470,620,934,000 |
The first thing I do with a new Linux box is to install systemd-boot. Grub, one would think this abomination was made of the hand of MS!
Okay, back to subject:
I just ran an upgrade on my new Debian Buster and a new kernel update was available and the update-package seems to look for grub and it made me think I bett... |
It seem this did the job: apt-get purge grub-common (it will include configurations files which remove will not).
And to remove unused dependencies (at least in my case):
apt-get purge libfreetype6 libfuse2 libpng16-16 mokutil shim-helpers-amd64-signed shim-signed-common shim-unsigned
System booted without problems.
H... | Uninstall grub from Debian (I'am using systemd-boot!) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.