« first day (3239 days earlier)      last day (1719 days later) » 

2:32 AM
0
Q: Why can’t I create a file with a name prefixed by “passwd.” in “/etc”?

EFanZhI have a PC with Ubuntu 16.04 installed, recently I want to install some packages but have trouble installing them. After some digging, I found that the failure seems to be related to the linux user account system. The problem is that any file with a name prefixed by passwd. cannot be created in ...

 
 
3 hours later…
5:44 AM
how do i get colored output for this command
`ls | less`
like I get when I simply use ls
 
 
2 hours later…
7:19 AM
@AkashKarnatak Are you sure that's what you want?
If yes, what's the output of alias ls ?
 
7:54 AM
@AkashKarnatak use the -R switch for less: ls | less -R or, of that doesn't work, ls --color=always | less -R
 
8:35 AM
o/
 
9:12 AM
@Fabby alias ls='ls --color=auto'
@terdon second command worked
Simply typing ls returns colored output so why doesn't the first command works?
 
9:38 AM
@AkashKarnatak because ls detects that its output is being piped and removes the color.
That's what the color=auto does and color=always disables this check
 
@terdon got it
 
Then, you need -R for less to interpret the colors correctly
 
10:12 AM
   -R or --RAW-CONTROL-CHARS
          Like  -r,  but  only ANSI "color" escape sequences are output in
          "raw" form.  Unlike -r, the screen appearance is maintained cor‐
          rectly  in  most  cases.   ANSI  "color"  escape  sequences  are
          sequences of the form:
 
10:42 AM
How does a command know its output is being piped?
 
It checks what kind of file stdout is.
I'm not sure if I've heard of any programs that specifically check if they are outputting to a pipe, though you can. What is common--and what ls, grep, and a variety of other GNU tools do with --color=auto--is to check whether they are outputting to a terminal or not. The case where standard output is not a terminal covers piping, as well as redirection to regular file, and other such cases.
 
ehm a comand does not know does it?
unless you arrange it :P
 
I'm not sure what you mean. A program can definitely check what kind of file any of its open file descriptors is. Nothing special has to be done by the caller to permit this. (Of course, what's open on FD 1 in the first place is a choice by the caller.)
Programs that detect if one of their file descriptors is a terminal or not usually do this by calling isatty.
 
Oh ok. So ls will call that every time it's invoked. And before it runs, the shell has done the plumbing
I'm sure we can see the details easily in the ls source code
 
@Zanna ls might only call it if it's outputting in a way that is potentially affected by whether or not stdout is a terminal. Ubuntu users usually have ls as an alias for ls --color=auto (because that alias is in /etc/skel/.bashrc, and so is enabled by default for bash in new user accounts created in the usual way). This instructs ls to check if it is outputting to a terminal and to emit colored output if it is.
ls also defaults to multi-column output when its output device is a terminal (and attempts to check the width of the terminal to figure out how many columns to use). This is generally so for ls implementations. But if you were to run \ls -1 or \ls -l, for example, then ls is using an output format that doesn't differ by device and it's not doing any colorization, so I'm not sure if GNU ls checks the type of its output device in such a case or not.
 
@WinEunuuchs2Unix nice!
@EliahKagan oh ok. It probably only checks if it might need to do something about it :)
That wasn't my opinion btw, just an attempted conclusion from what you said
 
Well, my guess is that it always checks. I'm just saying that it doesn't always have to.
 
Because in those situations it won't make any difference?
 
It wouldn't make a difference, and I suspect it would be easier to code.
 
11:35 AM
@Zanna At least in the version of GNU coreutils ls used in Eoan (which I'm testing with), decode_switches calls isatty as one of the sources of information it uses to populate a default configuration. Only afterward does it call getopt_long to actually examine what options have been passed. So it always calls isatty.
I installed coreutils-dbgsym in Eoan and opened ls in gdb (gdb ls), then set a breakpoint for isatty (b isatty) and tried running ls with a few sets of arguments, including one whose behavior shouldn't depend on whether or not stdout is a terminal (run -1 /sbin/nonexistent). Each time, it stops at an isatty call, which bt reveals to be the call in decode_switches.
As expected, unlike ls, the dir and vdir commands don't call isatty in decode_switches -- though they do sometimes get to an isatty call much later for other reasons, as does ls.
But as far as deciding whether or not to use colors is concerned, it looks like this is done as a separate isatty call and that that call may only be made if necessary.
Yeah, and that calls is actually later in decode_switches, so I shouldn't have implied it was after decode_switches returns. Debugging vdir, which doesn't have/do the original isatty call, with run --color=auto /sbin/nonexistent, still stops in decode_switches.
(The "for other reasons" I mentioned above was for entirely unrelated reasons and not for color. It takes place fairly deep in libc, doesn't appear to happen when ls is debugged from a pseudoterminal, and it has to do with buffering.)
 
11:51 AM
:D
Awesome
 
sends @Zanna double dosage of Advil
 
 
2 hours later…
1:29 PM
0
Q: Installing an older version of terragrunt Ubuntu

Stephen MynesThis is my first time trying to install this package. I am on an SSH console to a VM so no GUI. I need to install version 0.18.7 which can only be accessed from the github repo page. I downloaded it and tried to directly point to it using chmod but with no luck. I have also tried installing it ...

 
2:09 PM
Does anybody know how to IP protect FTP with firewall-cmd?
 
2:24 PM
NVM, I did it right the first time xD
 
lol
 
 
1 hour later…
3:31 PM
I think this question, which is asking about much more than environment variables, is too broad.
 
 
1 hour later…
4:49 PM
0
Q: Forward incoming packets on Hotspot wireless interface to Qemu and not on the default motherboard ethernet port

SunnyI am using Qemu to test my Ethernet MAC hardware IP. I am using ubuntu 18.04 LTS server as a hotspot. My qemu runs on Ubuntu and I have an internet access on Qemu. I want to access internet, connecting my laptop to the hotspot network, but I dont want hotspot to the use the motherboard ethernet,...

 
 
2 hours later…
6:52 PM
@EliahKagan CV added and Comment upvoted.
 
 
2 hours later…
8:50 PM
@cl-netbox Do you remember tape drives on Linux?
 
@Fabby skype :P
 
@Rinzwind Care to join here?
@cl-netbox ---^
 
 
1 hour later…
10:02 PM
user image
10
 

« first day (3239 days earlier)      last day (1719 days later) »