Linux

66K

Solutions

33K

Contributors

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm using Ubuntu and I have a C++ application which uses WxWidgets and sends a string over TCP several times. It works pretty fine only if the router and the connection are OK, otherwise it gets stuck and I need to manually quit the application.
I would like to send the data without blocking the application flow in case of errors.

I call the function in this way:

   
 SendCommand ptr;
    if ( ptr.sendcommand(16,16,1) ){
    printf("Porta Aperta\n");
    } else {
    printf("Errore di comunicazione - porta non aperta\n");
    }

Open in new window


and this is the function:

int SendCommand::sendcommand(int relay_on, int relay_off, int stop){
    printf("eseguo la funzione nella classe\n");

    std::array<uint8_t, 8> command1;
    std::array<uint8_t, 8> command2;

    switch(relay_on){

    case 16: command1 = {0x58, 0x01, 0x12, 0x00, 0x00, 0x00, 0x10, 0x7B}; // switch on the relay 16
    break;

    }

    switch(relay_off){

    case 16: command2 = {0x58, 0x01, 0x11, 0x00, 0x00, 0x00, 0x10, 0x7A}; // switch off the relay 16
    break;

    }

    int sockfd, n;
    struct sockaddr_in servaddr;

    std::string serveraddr = "192.168.1.4";

    sockfd = socket(AF_INET, SOCK_STREAM, 0);

    if ( sockfd < 0 )
    {
        cerr << "Error creating socket! " << strerror(errno) << endl;
        return -1;

    }

    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = inet_addr(serveraddr.c_str());
    servaddr.sin_port

Open in new window

0
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Hi Bash/Shell experts.

Kindly pls help

I have a variable which get value like below. In some scenario I get only one mac address, in other scenario I get two. But I want only one :)

echo $MAC_ADDRESS
06:d1:eb:cf:5f:3c/ 06:f2:21:8a:9c:0a/

My request, How can I get only one even if I get two or more. I tried below, but I think, it will break if I get only one
MAC_ADDRESS=$(echo $MAC_ADDRESS | cut -d / -f 1)

could you help me the best approach please

thanks in advance
0
Pls help...

User http access : sdm.mnd.com (75.68.129.206, Port 80)
Gateway will NAT the IP address & port to reserve Proxy server IP : 152.210.72.4:10118
RH Linux - Reserse proxy server : 152.210.72.4:10118
RH Linux application server : 152.160.85.4:10021

Verified the application server works well with direct IP.
RH Linux reverse proxy server, verified httpd successfully started.
Configuring reverse proxy settings, it is not working.
Can help me/ advise me what went wrong or to be modified...

User will access the URL http://sdm.mnd.com

Reverse proxy server httpd.conf file

<VirtualHost *:10118>
        ServerAdmin admin@mnd.com
        ProxyRequests off
        ProxyPreserveHost On
        ServerName sdm.mnd.com
        ProxyPass               /        http://152.160.85.4:10021
        ProxyPassReverse        /        http://152.160.85.4:10021
</VirtualHost>


Application server server.xml file

-->
      <Connector port="10021" protocol="HTTP/1.1"
      connectionTimeout="20000"

      redirectPort="8443" URIEncoding="UTF-8" />
   
      <!-- A "Connector" using the shared thread pool-->
   
<!--
0
Hi,

need help...
i am having two servers,  web reverse proxy and tomcat application server.

1. tomcat Application server is 120.121.25.16 default port number changed in server.xml file, port number is 28056. I checked the tomcat application server, it works after port change and verified application.

2. RH7.7 reverse proxy server 10.38.11.26
i installed httpd.
/etc/httpd/conf/httpd.conf edited and changed the default port 80 to 29081 in listener.
restartng the httpd, it is failing

After port change the httpd service not coming up...

Error below...
Oct 18 23:04:34 webpxy1httpd[19252]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.250.245.6. Set the 'ServerNa
Oct 18 23:04:34 webpxy1 httpd[19252]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:8011
Oct 18 23:04:34 webpxy1 httpd[19252]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:8011
Oct 18 23:04:34 webpxy1 httpd[19252]: no listening sockets available, shutting down
Oct 18 23:04:34 webpxy1 httpd[19252]: no listening sockets available, shutting down
Oct 18 23:04:34 webpxy1 httpd[19252]: AH00015: Unable to open logs
Oct 18 23:04:34 webpxy1 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Oct 18 23:04:34 webpxy1 kill[19253]: kill: cannot find process ""
Oct 18 23:04:34 webpxy1 systemd[1]: httpd.service: control process exited, code=exited status=1
Oct 18 23:04:34 …
0
On a Linux machine, I need to split product description fields that are up to 256 characters long, into multiple fields no longer than 76 characters.  The catch is, I need to split it up at a space.  So the multiple fields need to be as long as possible but split at a space and no longer than 76 characters.  I am assuming awk or sed can do this but not sure where to start.

Any help would be appreciated.
0
i update (normal update after that upgrade ) my ubuntu 16 domain server(samba4 domain server)
After that not possible to login as domain user only on that server.
Authlog (under /var/log) says: fatal: Access denied for user [REALM]\\\\user by PAM account configuration [preauth]
debug1: do_cleanup
debug3: monitor_read_log: child log fd closed
debug3: sshpam_thread_cleanup entering
debug1: audit_event: unhandled event 12
0
hi,

I have my MySQL 8.0.12 router, shell and community server installed and by some reason once MySQL shelled to the router it will prompt for login and never can login as it prompt for the following message:

 I have bootstrap mysql router and start mysqlrouter accordingly.

first messagge
I connection using MySQL shell and it has error:

 

Any reason why is that?

IP address of DB instance can be ping from that MySQL router node so connectivity is not a problem.

any reason why ?

this is the mysqlrouter.conf:

MysQL-router-3.jpg
0
I have two accounts with the same hosting provider.  They allow SSH access.  I created backup copies of websites on one account that I need to move to the other account.

I can move them individually, explicitly with "wget" but if I try to just pull all files from that one directory it fails.

Here is the command I am using, there are NO other sub-directories, just a bunch of files in one directory that I want to copy over from Account A to Account B.

wget -nc --level=1 --recursive --no-parent --accept jpa <url>/backups/

All I get when I run that command in the SSH portal is an "index.html" file and nothing more.  No error, just that one file (which is then automatically removed because it is not on my accept list).

I see other people (in general) are having a similar issue on StackOverflow (for example).

Server restriction maybe?  Problem with the command?

Thanks. :)
0
I'm consistently failing on the following:
- I have a bash script, say example.sh, a simplified content of which is listed below
- it is called with 0 or 1 argument, the normal value of which is "nomail" when I don't want a mail to be sent in the process
- the script first checks if nomail was provided as an argument and if yes gives the same value to the internal variable NOMAIL (otherwise empty). In the version below, it exports the value, as one of my (failed) attemps to solve the issue
- then runs the script somescript as user postgres (thru su)
- then launches another script mainscript with as argument the content of the NOMAIL variable

What happens:
- when running the example script from command line, everything works as expected, and the call to mainscript does indeed include the non-empty content of NOMAIL as as an argument
- but when running from cron, the call to mainscript is done with an empty value for NOMAIL!!!

(my first attempts were made without export, so I tried that just in despair!)

#

LE_SCRIPT="/root/somescript.sh"


if  [ x$1 == 'xnomail' ] || [ x$2 == 'xnomail' ] ; then
      export NOMAIL='nomail'
fi

su postgres -c "$LE_SCRIPT"


exec /root/mainscript.sh $NOMAIL

Open in new window

0
hi,

I use WinSCP to transfer files between Windows server and linux, and I accidentally delete a MySQL file in the bin directory using winSCP, any way to recover it except backup ?

any undelete?

accidentally delete a files in MySQL bin folder using WinSCP
0
Become a Certified Penetration Testing Engineer
LVL 13
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Our apps architect recommends  Alpine Linux for our
microservices/container environment.

Some time back, a patch management vendor told us
that patching for Alpine can't be managed by Satellite
or BigFix  ie we have to manually download & patch.

Q1:
is the above true or is there something like 'yum' in
RHEL to patch Alpine.

Q2:
Also, there's no CIS hardening benchmark nor any
docs that standardize what to harden for Alpine.

Q3:
Architect further points out that Alpine is the most
secure & efficient Linux to use for microservices;
is this true?  Does Alpine has good development
team that constantly check for vulnerabilities &
release advisories/patches (at least like RHEL)?

https://alpinelinux.org/about/
https://en.wikipedia.org/wiki/Alpine_Linux

Q4:
Where can I view past Alpine's CVEs/vulnerabilities
list & how can we assess how good are support
for Alpine?  Don't want a case where we log a
case for support & there's lack of response &
no solution
0
On a Linux server, I have a user that keeps getting asked for a new password.  I have tried chage -E and that doesn't work.  When I run passwd -S I get the epoch date and can't figure out how to change it.  Here's what it looks like:

servername:/root# passwd -S username
username PS 1969-12-31 0 90 7 -1 (Password set, SHA512 crypt.)

I think it's a pam issue, but I don't know the command and haven't been able to google it.

Thanks,
David
0
just built a vm running fedora 30.  downloaded and compiled apache 2.4.41 but only partially working.  i have ssl configured but https doesn't work.  the log file shows mod_ssl/openssl present, initializing servers for ssl, configuring tls extension handling, shows the certificate and private key, conf file has it listening on 443 but using netstat only shows http.  no errors int he log, selinux is disabled.  can't figure out why this piece isn't working
0
Best Linux Distro for Linux Administrator.

I am not sure what Linux Administrator job encompasses, but I would like to know which Linux Distro is mostly used by Linux Administrators at work.
I mean if I learn Centos or Ubuntu, will that get me a job as Linux Administrator, or it is not enough.

I have also heard about Linux Network Administrator that 's new to me. I know that Networking is dominated by Cisco and Juniper.

Thank you
0
Hello Ee,

I created a local repo for a CentOS 7.6 isolated instance with no internet, and copied a bunch of rpm files over from media to local directory . I created the proper repo file in /etc/yum.repos.d and pointed to the proper directory for the rpms, ran the createrepo ok . Question is , if I wish to add more rpms or delete rpms , how do I update/sync to show the newer packages and package count ? I tried 'yum clean all ' , no luck .
0
Hi experts,

our linux guys use two scripts for their linux file servers.
1. When a user logs on, one script checks the SCRTACH share, if the user has already a folder, if not, the script creates one.
2. Another script deletes the content of the SCRATCH folders.

Is it possible to to do the same for a windows fileserver ?
Do you have some hints and ideas ?
0
Hello EE,

I have a RHEL8 instance running in vmware player , mounted a usb stick to /media/usb and downloaded numerous rpm packages using the --downloadonly option and copied them to /media/usb. The usb is in vfat formatting. Next, I wish to use the usb stick as a repo on a seperate isolated centos7 instance . I  mount the same usb stick in a centos7 instance ok to /media/usb , however i cannot see the rpm files previously written to the usb stick, however if I "ll" , it states 33 files . Do I simply need to mount back on the RHEL8 instance and chmod 777 all files and directories ? Is there other steps I should be doing here for best practices ?
0
Hi tesseract OCR experts,

I’ve just installed tesseract on my Raspberry Pi running Linux (Raspbain) and I’m trying to extract text from PNG screen shots taken on my phone.  (I have hundreds of these screen shots, all in the same size & format, taken over the last year using the LeafSpy Lite app, for the Nissan LEAF EV, and I'll be extracting text from all of them.)

The problem I have is, some of the text is not being extracted.

When I run this command:
$ tesseract sample1.png sample1
It produces sample1.txt (attached), which includes plenty of useful figures, but it excludes:
-      “11.84V” near the bottom left (nice to have this voltage figure, but not vital), and
-      “32.0%” at the bottom (I really need this SOC figure).

I tried feeding tesseract a negative (created with IrfanView on Windows) of the image, in case it was a black/white issue, but that gave the same output.
I tried cropping the 11.84V and 32.0% figures out to TIF files (see sample1_voltage.tif & sample1_soc.tif attached, also created with IrfanView on Windows) then running them through tesseract, and that:
-      failed for the 11.84V (see empty sample1_voltage.txt attached), but
-      worked for the 32.0% (see sample1_soc.txt attached).

I know bash and Perl scripting.  I don’t know Python, but Python is installed so it could be used if necessary, if someone else writes the code, but it's not my preference.
ImageMagicK is also installed, in case I need to use it for cropping or whatever.…
0
Hi there.

My brother got an issue with a Seagate Central network disk. The network part doesn't work anymore, and he wants to rescue the data and copy to a usb-disk/computer drive etc...
The challenge is that Seagate utilizes a file format related to Ubuntu/Linux. He tried to pull out the hard disk from the storage unit and hook up to a Windows computer via USB. That didn't work that well, because the 3TB drive apparently is formatted in like 500GB partitions with a Ubuntu/Linux format. That is not recognized by Windows.
So the task is how to move/copy data to a "normal" disk that will work with Windows.
I found a Gparted software that is supposed to do the trick, but we're a bit insecure about what to do and if this is the right procedure.
Did any of you out there try a similar task? We would prefer if it's possible to do the whole thing with a Windows based software.
Looking forward to your suggestions.  :-)

Best regards

Ulrich
0
Become a CompTIA Certified Healthcare IT Tech
LVL 13
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

I created an Azure VM using the CIS Hardened Ubuntu image. When setting up the VM I chose to use a public/private key to access the VM. This was in April of this year. Now when I logon its telling me my password has expired but we never gave the user a password.

I'm guessing that this is due to the hardened CIS image and it wants us to change the password. However we dont know what the old password would be. Using the serial console in Azure I can create another admin user and i tried to use chage -d -1 <user> but that doesnt seem to work.

I'm wondering if anyone else has come across this issue or can help me find a way to remove the password expiration.
0
Hi Experts,

we have an old linux file server with some shares. Lets say we have here 100GB data.
Now we want to go to a new windows file server Windows Server 2019.
The file server is already installed with DFS and DFSR.

Do you know an easy way to migrate the files and permissions to the new filer ?

Can I use ROBOCOPY for it maybe  ?
0
Hi,

I'm using Chrony to configure the ntp client and it seems like every evening I keep losing the NTP synchronization which makes the time leap forward.

Sep 30 22:10:00 xxxxxxx chronyd[32710]: Forward time jump detected!
Sep 30 22:10:00 xxxxxxx chronyd[32710]: Can't synchronise: no selectable sources
Sep 30 22:13:13 xxxxxxx chronyd[32710]: Selected source 193.190.253.212
Sep 30 22:13:13 xxxxxxx chronyd[32710]: System clock wrong by -7439.358171 seconds, adjustment started
Sep 30 22:18:38 xxxxxxx  chronyd[32710]: Selected source 194.78.244.172

Open in new window


Lists of NTP Servers I'm using:

server 0.be.pool.ntp.org iburst
server 1.be.pool.ntp.org iburst
server 2.be.pool.ntp.org iburst
server 3.be.pool.ntp.org iburst

restarting chrony resolves the issue, but it keeps happening
0
I have a CentOS 7.7-1908 clean install on a sever.  I was having trouble with YUM updating packages and I attempted to clear out the broken YUM records and start fresh.  I made it worse, and now the server isn't working at all.  I keep getting a message:

[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>


Only there are no repositories in the list when I try to run the suggest commands.  Is there any way to get this back without wiping the server and starting over?  Tried some research but nothing seems to work.
0
I'm having serious problems to make my kiosk printer (Nippon Primex NP-VK30) work correctly under Ubuntu 19.04.
The manufacturer provides no support for Ubuntu, but I've found on Github a very simple library made in Python.
I attached the Python files to this topic.

I tried to launch "test.py" and my printer worked fine!

Since I need to print some text strings from my C/C++ application, I would like to translate the python code into C/C++ code so I can easily import it in my original application.

Unfortunately, I'm just a beginner and I never coded in Python.
Can you help me, please?

Thank you!

This is the code for test.py:

#!/usr/bin/python
from w2k203dpi import Printer

p = Printer()

p.println('test')

p.bold(True)
p.println('test')
p.bold(False)

p.underline(True)
p.println('test')
p.underline(False)

p.qrcode('test')

p.fullcut()

Open in new window


This is the code for the class file:

class Printer:

    def __init__(self):
        DEVPATH = '/dev/usb/lp0'
        self.f = open(DEVPATH, 'w')
        self.mode = 0x00

    def raw(self, data):
        for i in data:
           self.f.write(i)
        self.f.flush()

    def esc(self, data):
        self.raw('\x1b' + data)

    def font(self, value):
        if value:
            self.mode |= (1 << 0)
        else:
            self.mode &= ~(1 << 0)
        self.esc('!' + chr(self.mode))

    def bold(self, value):
        if value:
            self.mode |= (1 << 3)
        else:
         

Open in new window

0
How do I check a history of commands executed by sudo?
I checked /home/username/.bash_history file but it contains only commands executed by the user.
I use RedHat 7.4. It's appreciate if I can know how to check sudo command history.
0

Linux

66K

Solutions

33K

Contributors

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.