[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Linux Distributions

27K

Solutions

20K

Contributors

A Linux distribution is an operating system made as a software collection based on the Linux kernel and, often, on a package management system and are available for a variety of systems. A typical Linux distribution comprises a Linux kernel, GNU tools and libraries, additional software, documentation, a window system (the most common being the X Window System), a window manager, and a desktop environment. Most Linux systems are open-source software made available both as compiled binaries and in source code form, allowing modifications to the original software. Over three hundred distributions are in active development, including commercially backed distributions (such as Fedora, openSUSE and Ubuntu) and community-driven distributions (such as Debian, Slackware, Gentoo and Arch Linux).

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

Sign up to Post

Let's start with a useless example of input redirection:

less 1< /test.txt

Open in new window


The result is:

Missing filename ("less --help" for help)

This I understand, because:

LESS-PROCESS:
FD 0 <- terminal file (keyboard)
FD 1 <- /test.txt
FD 2 -> terminal file (monitor)

FD 0 needs to get some content from a file, but there is no file in this case. There is /test.txt but it points to the wrong fd. Now let's take a look at a useless example of output redirection:

less 0> /test.txt

Open in new window


LESS-PROCESS:
FD 0 -> /test.txt
FD 1 -> terminal file (monitor)
FD 2 -> terminal file (monitor)

The program doesn't give file descriptor 0 some output, so "nothing" will be written to /test.txt. That why you will always end up with an empty /test.txt file. File descriptor 0 opens /test.txt for writing and not for reading. So the less-process doesn't get any file to read from. Then why the result is not:

Missing filename ("less --help" for help)

Instead, less is acting as it got an empty file as input. The file /test.txt is empty in the end, but this is about output redirection and not about input redirection, so there is no input. That's the reason why I would expect "Missing filename". Why this is not the case?
0
Rowby Goren Makes an Impact on Screen and Online
LVL 12
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

See: https://stackoverflow.com/questions/6170598/can-anyone-explain-to-me-what-the-purpose-of-dev-tty


You can start with the POSIX spec. From there, read about the "controlling terminal" of a process.

But just for example... /dev/tty is how a command like "ssh" can read your password even if its standard input comes from somewhere else:

tar cf - . | ssh dest 'tar xf -'

Open in new window


If ssh decides to prompt you for a password, it will read it from /dev/tty instead of stdin.

Conceptually, /dev/tty is "the keyboard and text terminal". More or less.

Let's say my "terminal-file" of the current session is /dev/pts/1. In such a case, then what's the difference between "/dev/pts/1" and "/dev/tty"? And if they are basically the same, then why  "/dev/tty" is used instead of "/dev/pts/1"?

And:

/dev/tty is how a command like "ssh" can read your password even if its standard input comes from somewhere else

Let's say the standard input comes from somewhere else, so let's say we have:

FD 0 <- file
FD 1 -> /dev/pts/1
FD 2 -> /dev/pts/1

How I see it: the fact that the standard input comes from somewhere else doesn't mean that /dev/pts/1 can not be read? The password comes from the keyboard and /dev/pts/1 represents i.a. the keyboard, right? So I still don't see what exactly the purpose is of /dev/tty?

@noci: I know you know the answer, but I don't understand your explanation so I've made this post so maybe other people can explain it to me in a way that I understand it.
0
I'm reading about "redirection of input" on the internet. I understand what's behind it. For example:

command < file.ext

Open in new window


This is equivalent to:

command 0< file.ext

Open in new window


In general, if you have:

command n< file.ext

Open in new window


then the contents of file.ext go to file descriptor "n" as input. I've checked different websites explaining "input redirection". However, the problem is that I didn't see any good example. I'll discuss some examples I saw:

cat < file.txt

Open in new window


Then I'm thinking, "cat file.txt" does the same, so why do we need it? Another example:

sort < file_list.txt > sorted_file_list.txt

Open in new window


Then I'm thinking, "sort file_list.txt > sorted_file_list.txt" does the same, so why do we need it? Another example:

more < /etc/passwd

Open in new window


Then I'm thinking, "more /etc/passwd" does the same, so why do we need it? That's why these are not really good examples in my opinion. What is a good example to explain the purpose of input redirection in a terminal-window?

Probably internally something like "cat file.txt" is being treated as "cat 0< file.txt" (input redirection), but in a terminal-window ... when it really does make sense to use an "input redirection" in a terminal-window? Does someone have a good example?
0
First I create a regular file with some contents (manual page of find command):

man find > test.txt

Open in new window


Then I use the less command to display some of these contents:

less test.txt

Open in new window


Now I press CTRL-Z to suspend the process. The process is still open, so now I can execute this command:

lsof | grep 'less'

Open in new window


By doing this, I get an idea which files are open with respect to the less-process. My result:

COMMAND  PID    USER  FD   TYPE  DEVICE  SIZE/OFF  NODE       NAME
less     24565  root  cwd  DIR   0,38    4096      21473055   /
less     24565  root  rtd  DIR   0,38    4096      21473055   /
less     24565  root  txt  REG   0,38    149944    22143102   /usr/bin/less
less     24565  root  mem  REG   9,1               22143102   /usr/bin/less (path dev=0,38)
less     24565  root  mem  REG   9,1               22135172   /usr/lib/locale/locale-archive-rpm (path dev=0,38)
less     24565  root  mem  REG   9,1               21741879   /lib64/libc-2.12.so (path dev=0,38)
less     24565  root  mem  REG   9,1               22265955   /usr/local/lib/libpcre.so.0.0.1 (path dev=0,38)
less     24565  root  mem  REG   9,1               21741743   /lib64/libtinfo.so.5.7 (path dev=0,38)
less     24565  root  mem  REG   9,1               21741946   /lib64/ld-2.12.so (path dev=0,38)
less     24565  root  0u   CHR   136,1   0t0       4          /dev/pts/1
less     24565  root  1u   CHR   136,1   0t0       4          /dev/pts/1
less     

Open in new window

0
Let's say I type the following "in a terminal":

echo 'bla'

Open in new window


In my case, the shell is bash, so I assume the shell/bash-process receives "echo 'bla'" as standard input? Then it sees "echo", so a child process will be started. So then we will have at least:

ECHO PROCESS:
fd 0 (standard input)   <- terminal-file (keyboard)
fd 1 (standard output)  -> terminal-file (monitor)
fd 2 (standard error)   -> terminal-file (monitor)

Open in new window


I thought that for this process, only "bla" is the standard input. And then the output is also "bla", so I'll see "bla" on my monitor.

I was just a bit playing with "input redirections" and I noticed that the following does not work:

echo < bla-file.txt

Open in new window


After some Google searches, I found out that "echo" does not read from stdin. However, it prints all of its arguments. So it's working differently than normal. So how I have to see/change this:

ECHO PROCESS:
fd 0 (standard input)   <- terminal-file (keyboard)
fd 1 (standard output)  -> terminal-file (monitor)
fd 2 (standard error)   -> terminal-file (monitor)

Open in new window


I thought every process by default has fd's 0,1,2? But if fd 0 would be there something like this:

fd 0 (standard input)   <- nothing

Open in new window


Then it should be still possible to redirect (input) to something. So this means I can not see it like that. Does this mean that the echo process doesn't have a fd 0 at all? Or I must not see "echo" as a process with a fd table et cetera?

But the echo command displays something on my monitor, so at least this should be there:

fd 1 (standard output)  -> terminal-file (monitor)

Open in new window

1
dup2(int oldfd, int newfd);

Open in new window


This is an equivalent of:

close(int newfd);
dup(int oldfd);

Open in new window


By closing "newfd" first, it becomes the lowest-numbered unused file descriptor (normally). Because of that the oldfd is copied to newfd (dup system call). So far, everything is clear.

Now see: http://codewiki.wikidot.com/c:system-calls:dup2


dup2 is a system call similar to dup in that it duplicates one file descriptor, making them aliases, and then deleting the old file descriptor.

Actually I don't think the old file descriptor will be deleted?

See: http://man7.org/linux/man-pages/man2/dup.2.html

After a successful return, the old and new file descriptors may be used interchangeably.

If the old file descriptor will be deleted, then they would not say something like that. Is wikidot.com just wrong about this?
0
File descriptor table:      Open file table
FD 0 (stdin)                ?
FD 1 (stdout)               ?
FD 2 (stderr)               ?

Open in new window


By default file descriptors 0, 1 and 2 are associated with the terminal. The keyboard input is associated with the standard input. The monitor is associated with the standard output and standard error.

The question is: Do fd 0,1,2 all refer to the same entry in the "open file table"? Or do they refer to two entries?

 
FD 0  -> entry A
FD 1    
       > entry B  
FD 2    

Open in new window


Or do they refer to three entries?

 
FD 0  -> entry A
FD 1  -> entry B
FD 2  -> entry C

Open in new window


This seems a pretty basic question, but I'm reading different things about it on the internet.

See: https://www.usna.edu/Users/cs/aviv/classes/ic221/s16/lec/21/lec.html#orgheadline6

If fd 1 and fd 2 refer to a different entry in the open file table, then this should be also the case for fd 0. So according to this website, they refer to three different entries in the open file table.
 
But now see: https://www.enseignement.polytechnique.fr/informatique/INF422/INF422_8.pdf#page=160    (page 160, example of no redirection)

There, it's like:

 
FD 0  -> entry A
FD 1    
       > entry B  
FD 2    

Open in new window


So according to that website, they refer to two different entries in the open file table.

And see: https://www.experts-exchange.com/questions/29119936/How-the-open-file-table-entries-look-like-for-stdin-stdout-stderr.html#a42694025


the fd[0] , fd[1] & fd[2] should all point to the same central entry

According to this, they all refer to the same entry in the open file table.

I can execute the following command:

lsof | grep 'bash'

Open in new window


This i.a. prints:


Open in new window

0
I am trying to upgrade to Ubuntu 16.04 and I get a message about a conflict with  /etc/apt/apt/conf.d/50unattended-upgrades - says it was locally modified, but I don't think I ever modified this file   I tried to compare, but the diff does not look like any normal diff I have seen and I am not familiar with this file.

Some background - These machines were manually installed by someone as Ubuntu 14.  I gave them instructions that they went through and that included running some scripts that just pull down some other scripts of mine from a central server and set up some cron jobs etc.  (Simple stuff - running apt-get update/upgrade nightly and running a clamav scan, having a script set up that runs every 5 minutes and grabs from my central server so that I can easily put something there that I want to run on all machines in the next 5 minutes, etc)

In any case here are some screenshots.  Do you think it's safe to just "install the package maintainers version"?


initial warning screen
initial warning screen
diff
diffI
0
This is a follow on question to https://www.experts-exchange.com/questions/29115269/Why-Does-Mysql-Keep-Increasing-Memory-Usage.html

Now it appears that the memory leaks are coming from php-fpm and Apache.

Please tell me how to isolate what is using up the memory so quickly.

In less than an hour I have lost .9 GB.
0
I need to upgrade fail2ban 0.8.14 to 0.10.3.  I am on a Linux 2 server which prevents me from loading any repositories or using Yum to install it.

So, I need to know the steps to get my fail2ban upgraded.  

Thanks,
0
OWASP Proactive Controls
LVL 12
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Fail2ban stopped working.  I have scoured the log files and no errors.  It was working and it seems since my last Yum update for security it quit working.  I can do fail2ban-client status and it shows 7 jails.  I can look in the iptables and it shows the jails.  However, when I run fail2ban-regex it shows many hits but none are getting blocked by the iptables.  The iptables are on.

This is 0.8.14 and I am on a Linux 2 Amazon Ami with PHP 7 and Python 2.7.14.

When it was working  it had over 221 ips banned just in one jail.

Please help me get this going.  The bots overrun my system if it isn't in place.
0
I have a php function that I want to call from another php file.  This function creates a button and places a message in Order Notes.  Also, the function isn't the only function in functions.php.

Here is the function
add_action ('woocommerce_before_order_notes', 'member_note', 10); 
function member_note (){
$code = <<< EOT
<button style= "background-color:green; color:white;" onclick="myFunctionMember()">MEMBERSHIP</button>
<script>
function myFunctionMember() {
    document.getElementById("order_comments").innerHTML = "I want membership";
}
</script>
EOT;
echo $code;
}

Open in new window


This function needs to be at the bottom of this yellow box.  https://gyazo.com/fad06970c1cec8be092987e46331a7c3 which is being created with this code.  

<?php if (($val >= 100) && ($val <= 300)) { ?>
<p style="color: black; font-weight:bold; text-align:center; margin:0 auto; background-color: yellow; padding-top:6px; padding-bottom:6px; font-size:16px; font-family:Verdana, Arial, Helvetica, sans-serif;">
		<span class="heading">You've Qualified For FREE SmartStart Membership!</span><br />
		<br />
  $15 product credit for future use, shipping promotions and much more.</span>
	  <br /><br />
	Click The Green Membership Button To Recieve Your Membership Benefits</p>


<?php include('functions.php');
	$returning_value = member_note();								   
echo $returning_value;
 } ?>

Open in new window


This code is at qv_contest.php

You can see my attempt that resulted in this error:

Fatal error: Cannot redeclare member_note() (previously declared in C:\xampp\apps\wordpress\htdocs\wp-content\themes\flatsome-child\functions.php:25) in C:\xampp\apps\wordpress\htdocs\wp-content\themes\flatsome-child\functions.php on line 33

Open in new window

0
My system crashed and I need to find out what caused the crash.  I have atop installed and I can see what process caused the problem by using the log files with atop.  However, I want to know what programs and files were involved in the process.

Is there a way to do this with atop and/or sar?

I am on a Linux 2 AWS instance.
0
I installed dietpi today on a Zero w. (did it on a 3B+ and setup as Hotspot no problem). I wanted to setup the zero as a webcam.
I did this 4 times before I started to install or change the configuration and reboot at least 2 times to make sure all was good.
I changed the setup to US. connected to the Wi-Fi.
Updated to the latest version of dietpi. Update the firmware.
Changed drop bear to ssh.
installed REALVNC.
But when I Install RPI WEB CAM it keeps rebooting and I can't stop it.
As I said after the 3rd time I flashed a fresh image again and rebooted at least 2 times after each change or install until I got to the RPI Web CAM issue.
I get "You're in emergency mode. Enter root password for maintenance or CTRL D.
I tried dietpi for the password and root. CTRL D does nothing but reboot back to the same area.
I'm assuming there is am issue with RPI Web Cam.
And Yes I made sure the power supply is good. I replaced the power supply with one used on my Pi3B+. It's 5.2V, 3amps.
I even tested it with my voltmeter. The issue is this pi Zero W setup works fine with a full version of Raspian and the RPI WEB CAM version I had to manually configure. I switched back to that card and all is fine. I just like the small footprint and ease of setup with DietPi. And it only starts to reboot when I add in the Web Cam distro on DietPi. I even tried some other packages after my 4th attempt, on the card, flashed a new image. In fact I added a few distros to the DietPi setup …
0
I have noticed a bot that is using several ip numbers at the same time that I want to block.  This will take a custom filter but all of the tutorials to create a filter take you up to the status code column.  I want the regex to catch HeadlessChrome.

The problem is that the browser name is much further past the status code as you can see below:


1.1.1.1 - - [05/Aug/2018:17:23:51 -0400] "POST /?wc-ajax=get_refreshed_fragments HTTP/1.1" 200 273 "https://www.theherbsplace.com/Fat_Grabbers_120_Capsules_p_189.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/64.0.3282.119 Safari/537.36"

Please tell me how to build a regex that goes past the status code and picks up the browser name.
0
We are attempting to install an SSL certificate on a website which already has a sub-domain attached to it. So this is the picture:

The website has been installed on product.domain.com and we have an SSL certificate already installed on that domain URL. The Wordpress site is set to force SSL and it works fine. No problem. If someone types in https://product.domain.com the site comes up fine - all good. If someone types product.domain.com the site comes up perfectly with https://product.domain.com.

If someone types www.product.domain.com without the http or https,  the site works fine - it strips the www and reverts to https://product.domain.com so this is all OK.

However, if someone actually types the full thing - as https://www.product.domain.com the site does not strip the https:// or the www so the browser displays a security exception as if the site was not covered by an SSL certificate.

I've tried various configurations in the .htaccess file but nothing I do seems to work.

Any help with this sincerely appreciated.

Cheers
Chris
0
I have a new installation of woo commerce and I have noticed the urls are inconsistent regarding my products on the site.  Some urls are showing the product id and others aren't.  My preference is to not show the id.

https://www.theherbsplace.com/product/sf_p_1458/[code] - With id

[code]https://www.theherbsplace.com/product/neroli-organic-5-ml-100-pure-essential-oil/

Open in new window

- Without id

It seems when the id is in the url it goes to a category page first rather than the single product page.

I have tried changing the perma-links to something else then saving them.  Then immediately putting them back to their original setting and save again but there was no change.

Please show me how to get the product url's consistent with no id on them.
0
I have installed fail2ban on an Amazon Linux 2 instance running Apache 2.4.  I can't start it up because I am using postfix and the default mta is sendmail.  I don't have sendmail installed and I don't want it.

I use google apps for my smtp server.

How can I change over to postfix or use google apps for my fail2ban mail option?

Thanks,
0
I built a LInux 2 Amazon Apache 2.4 instance that uses php-fpm.  I have had several segfaults lately and then the server crashes.  I installed atop and noticed when the server crashed I had several php-fpm pools open.  At 1 PM today I had 1.4 GB free memory and now I have 900 mb free memory.

Something seems to be wrong with php-fpm because when I restart it the free memory jumps back up to 1.3 GB.

Here is my current atop screenshot - https://gyazo.com/5028ec3f184ff973409d6cba079d3767 you can see the last column shows only a small percentage of the processes are using memory.  Yet I keep running out of memory does anyone have any suggestions?  I have atop and sar logging.
0
Exploring SQL Server 2016: Fundamentals
LVL 12
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

I am trying to trace down a segfault error using SAR on a Linux 2 Apache Amazon instance.  I have SAR installed and can see when the memory spikes but how can I find out in the log files what process is causing the memory spike?

Here is what I am seeing using SAR

https://gyazo.com/890b4ab5214fa269a14f3adeec175116

I just need to know what process is causing the memory to increase.  Normally memory usage is in the 40% area.

Thanks,
0
I want to install Fail2Ban on an Apache 2.4 Linux 2 machine.  As a Linux 2 user I can't download the epel repository according to Amazon engineers.

Consequently, I used wget and now have fail2ban-0.8.14 directory in my /etc folder.  I need to install fail2ban but the normal install commands aren't working.  I tried apt-get and it isn't on my server.  So how do I install fail2ban?

Thanks,
0
I need a way to see the dimension of the Woo Commerce product images laid out in a table in this manner. The table would have 4 columns - file name / width / height / link to wordpress media page. And the table would be in order of image size from small to large.

This could be a mysql query or a php program.  Hopefully, tied into a plugin in my wordpress installation. A plugin would be best because I will be referring to this on a regular basis.

I am running php 7.2 and a Maria 10 db.

Thanks,
0
I have a script that reads the access_log files and counts how many times an ip has accessed the site.  This works great and helps me to find bots I want to remove.  My question is, how do I get the access files and error log files to look the same?

I use a vhosts.conf file and in one of the virtual directories we have the following:

<VirtualHost 172.31.8.214:80>
        ServerName www.theherbsplace.com
        ServerAlias theherbsplace.com
        DocumentRoot /data/web/theherbsplace.com

        ErrorLog /data/log/php_errors_thp.log
        CustomLog /data/log/access_thp.log combined

        RewriteEngine On

<Directory /data/web/theherbsplace.com/>
     Require all granted
  </Directory>
</VirtualHost>

Open in new window


When I add the word combined to the error log format line I get the following error:

AH00526: Syntax error on line 7 of /etc/httpd/conf.d/vhosts.conf:
ErrorLog takes one argument, The filename of the error log

Open in new window


The format of the access_log is the one I want the errors log to follow.

So, how can I get the log format the same on both?  This is because it gives me the information I need and also will permit the script to read the error logs too.

Thanks,
0
I have over 2,000 images in a Woo Commerce installation.  I need to know where the image dimensions are stored on the Maria db for the single product image or main image that Woo Commerce uses for each product and how to retrieve the list of them.

I plan to replace all of the images that aren't at least 300x300.  Because on the cart they are showing up blurry.

Doing it through the db will be much quicker than going through each product on the cart.

Thanks,
0
how to find number of count in the unix logs for a grep search keyword say 'nullpointerexception on deviding 109418 with 0' please advise
0

Linux Distributions

27K

Solutions

20K

Contributors

A Linux distribution is an operating system made as a software collection based on the Linux kernel and, often, on a package management system and are available for a variety of systems. A typical Linux distribution comprises a Linux kernel, GNU tools and libraries, additional software, documentation, a window system (the most common being the X Window System), a window manager, and a desktop environment. Most Linux systems are open-source software made available both as compiled binaries and in source code form, allowing modifications to the original software. Over three hundred distributions are in active development, including commercially backed distributions (such as Fedora, openSUSE and Ubuntu) and community-driven distributions (such as Debian, Slackware, Gentoo and Arch Linux).